TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Marc'Antonio Alessi on November 26, 2014, 09:59:28 AM
-
Is this a valid test?
(defun c:LwPolyIsClosed ( / EntNam EntObj)
(or
(eq
:vlax-true
(vla-get-closed (setq EntObj (vlax-ename->vla-object (setq EntNam (car (entsel))))))
)
; (= 1 (logand 1 (cdr (assoc 70 (entget EntNam)))))
(equal (vlax-curve-getStartPoint EntObj) (vlax-curve-getEndPoint EntObj))
)
)
-
My attempt .
(defun c:ClosedPoly
-p
(/ s
) (princ "\n Select LWpolyline ..") )
)
-
My attempt .
(defun c:ClosedPoly
-p
(/ s
) (princ "\n Select LWpolyline ..") )
)
...but "also apparently" > perimeter is closed manually (flag 70 = 0)...
-
Marc'Antonio, I use essentially what you have posted except I use the optional fuzz factor for the (equal) comparison. Using a fuzz of 0.0001 helps to eliminate any errors due to computer rounding issues.
-
Marc'Antonio, I use essentially what you have posted except I use the optional fuzz factor for the (equal) comparison. Using a fuzz of 0.0001 helps to eliminate any errors due to computer rounding issues.
Ok, so vlax-curve-isclosed is not always valid.
Thanks.
-
(defun closedPoly (entname / entdata res)
(cond
((eq (type entname) 'ENAME) (setq entdata (entget entname)))
((eq (type entname) 'VLA-OBJECT) (setq entdata (entget (vlax-vla-object->ename entname))))
)
(if entdata
(if
(eq 1 (cdr (assoc 70 entdata)))
(setq res 1)
(progn
(if
(eq (vl-princ-to-string (assoc 10 entdata))
(vl-princ-to-string (assoc 10 (reverse entdata)))
)
(setq res 3)
(setq res 2)
)
)
)
)
res
)
;(closedPoly (car (entsel)))
1 = Closed
2 = not closed
3 = not closed but the last point correspond to the first point
-
...
(eq (vl-princ-to-string (assoc 10 entdata))
(vl-princ-to-string (assoc 10 (reverse entdata)))
)
...
Why not: (equal (assoc 10 entdata) (assoc 10 (reverse entdata)) [fuzz]) ?