TheSwamp
CAD Forums => CAD General => Topic started by: Andrea on December 01, 2006, 10:08:48 AM
-
Hi all...
I'm not familar with region...
I know we can convert a closed polyline to region...
but can we do region to polyline with AutoCAD ?
:|
-
I don't know about converting a region to a polyline but you can use the bpoly command to create a polyline from a region.
-
You can explode it, to its primitives then if applicable polyline join those, if not there are probably splines and or ellipses involved.
-
For the moment...i've wrote this..
Region to Polyline...
;;RETOPO
(defun c:retopo (/ w1)
(setvar "cmdecho" 1)
(setq w1 (entget (car (entsel "\nSélectionnez votre région: "))))
(if w1
(progn
;;is layer lock ?
(if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 w1)))))))
(command "_layer" "_U" (cdr (assoc 8 w1)) "")
)
;;si c'est une REGION
(if (eq (cdr (assoc 0 w1)) "REGION")
(progn
(command "._explode" (cdr (assoc -1 w1)))
(setq w1 (entget (entlast)))
(if (eq (cdr (assoc 0 w1)) "LWPOLYLINE")(command "._pedit" "_l" "_J" "_P" "" ""))
(if (and (/= (cdr (assoc 0 w1)) "CIRCLE")(/= (cdr (assoc 0 w1)) "LWPOLYLINE"))
(command "._pedit" "_l" "_Y" "_J" "_P" "" "")
)
(princ "\nConversion en polyligne réussi.")
(setq w1 (entget (entlast)))
(command "_area" "_O" (cdr (assoc -1 w1)))
(getretopoinfo)
)
(progn
(command "_area" "_O" (cdr (assoc -1 w1)))
(getretopoinfo)
))))
(princ)
(c:retopo)
)
;;;;;;;;;;;;;;;;;;;;;;;
(defun getretopoinfo ()
(alert (strcat "Superficie: " (rtos (getvar "AREA") 2 8)
"\nPerimètre : " (rtos (getvar "PERIMETER") 2 8)))
)