Display full version of the post: region2poly error

w64bitcad
15.07.2021, 14:25
When I use region2poly 1.1 on AutoCAD 2021, I receive an error:Invalid option keyword.; error: Function cancelledIs there anything I can do in order to fix this?

Vladimir Michl
15.07.2021, 14:39
It probably doesn't like one of the options. Please try the following LISP code:[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));[/CODE]

w64bitcad
15.07.2021, 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" "" ""))

w64bitcad2021-07-16 12:16:39