Print Page | Close Window

region2poly error

Printed From: CAD Forum
Category: EN
Forum Name: ARKANCE (CAD Studio) applications
Forum Description: Questions and discussion about applications by ARKANCE and Be.Smart - T4R, T4I, Civil Tools, DWGtext, GeoRefImg, XLSparam, FLAY, JobTime, GeoCode, TRANS, LT Extension,...
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=13615
Printed Date: 09.Jul.2026 at 23:32


Topic: region2poly error
Posted By: w64bitcad
Subject: region2poly error
Date Posted: 15.Jul.2021 at 14:25
When I use region2poly 1.1 on AutoCAD 2021, I receive an error:
Invalid option keyword.
; error: Function cancelled
Is there anything I can do in order to fix this?




Replies:
Posted By: Vladimir Michl
Date Posted: 15.Jul.2021 at 14:39
It probably doesn't like one of the options. Please try the following LISP code:

; Convert Region to Polyline (by Arkance Systems)
;
;1.1 - multiple
;
(defun c:region2poly (/ cmde ss reg reg1 lay etyp i)
 (setq cmde (getvar "CMDECHO"))
  (setvar "cmdecho" 0)
  ;(setq reg (entsel "\nSelect a region: "))
  ;(if reg
  (setq ss (ssget '((0 . "REGION"))))
  (if ss
   (progn
   (setq i 0)
   (while (< i (sslength ss))
   ;(setq reg1 (entget (car reg)))
   (setq reg1 (entget (ssname ss i)))
   (setq lay (cdr (assoc 8 reg1)))
   (setq etyp (cdr (assoc 0 reg1)))
;is layer locked?
(if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" lay)))))
 (command "_LAYER" "_U" lay "")
)

;region?
;     (if (eq etyp "REGION")
;          (progn
(command "._explode" (cdr (assoc -1 reg1)))
(setq reg1 (entget (entlast)))
(setq etyp (cdr (assoc 0 reg1)))

(if (eq etyp "LWPOLYLINE")(command "._PEDIT" "_L" "_J" "_P" "" ""))

(if (and (/= etyp "CIRCLE")(/= etyp "LWPOLYLINE"))
 (command "._PEDIT" "_L" "_Y" "_J" "_P" "" "")
)
(princ "\nConverted to polyline.")
;)
;(princ " Not a region!")
;) ; if
(setq i (1+ i))
) ; while
))
(setvar "cmdecho" cmde)
(princ)
);



-------------
Vladimir Michl (moderator)
ARKANCE - https://arkance.world" rel="nofollow - https://arkance.world - Autodesk Platinum Partner


Posted By: w64bitcad
Date Posted: 15.Jul.2021 at 14:45
I did some digging.
The problem is with PEDITACCEPT.

Instead of:
(if (eq etyp "LWPOLYLINE")(command "._PEDIT" "_L" "_J" "_P" "" ""))
(if (and (/= etyp "CIRCLE")(/= etyp "LWPOLYLINE"))(command "._PEDIT" "_L" "_Y" "_J" "_P" "" "")
this seems to work:
(if (= (getvar "PEDITACCEPT") 1)(command "PEDIT" "_L" "_J" "_P" "" "")(command "PEDIT" "_L" "_Y" "_J" "_P" "" ""))




Print Page | Close Window