
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello folks,
I have 2 LISPS and I would like to know if its possible to make 1 other LISP out of them: my goal is to create an ACAD Point in the centroid of a Polyline from upper left to down right. 99,9% of the cases are polylines of rectangular shapes (4 vertices).
For this task, I have a first lisp that finds the centroid of each selected polyline (I can select all polylines at once) and places a point in its centroid, but in random order:
(defun c:PC ( / acdoc acspc acsel reg ) (vl-load-com)
(setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))
acspc (vlax-get-property acdoc (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace))
)
(if (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1)))
(progn
(vlax-for obj (setq acsel (vla-get-ActiveSelectionSet acdoc))
(vlax-invoke acspc 'addpoint
(trans (vlax-get (setq reg (car (vlax-invoke acspc 'addregion (list obj)))) 'Centroid) 1 0)
)
(vla-delete reg)
)
(vla-delete acsel)
)
)
(princ)
)
(c:PC)
(princ)
Then, after running the first LISP, I need to convert all the randomly ordered points that were created to circles and then run this second LISP that converts all the circles at once to ACAD Points, but now in correct order (from upper left to down right):
defun c:C2P (/ s)
(cond ((setq s (ssget ":L" '((0 . "circle"))))
(foreach p (vl-sort (mapcar '(lambda (x) (cdr (assoc 10 (entget x))))
(setq s (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
)
'(lambda (a b)
(if (equal (cadr a) (cadr b) 1e-8)
(< (car a) (car b))
(> (cadr a) (cadr b))
)
)
)
(entmakex (list '(0 . "point") (cons 10 p) '(8 . "0")))
)
;; Uncomment the line below to delete the circles
;; (mapcar 'entdel s)
)
)
(princ)
)
(vl-load-com)
Is there any way to run just one LISP that is going to find the centroid of those polylines and create ACAD Points in their centroids from upper left to down right at once?
Someone can help to get this task done? Thanks a lot.
Solved! Go to Solution.