- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am pretty new here so please take it easy on me. HAHA.
I am in need of some help. We use a lisp routine at work in Civil3D 2023 that allows us to move Cogo points to a selected polyline to save us some time. This lisp allows us to select one polyline and then we select the group of Cogo points we would like to move to that polyline. It works, but I am trying to find a way to make the LISP more efficient. I have provided the base code that I have come up with so far below:
(defun c:MoveCOGOPointsToNearestPolyline (/ ss i ent pt1 pt2 elist p ss2)
(princ "\nSelect polylines: ")
(if (setq ss (ssget '((0 . "LWPOLYLINE"))))
(progn
(setq elist (ssnamex ss))
(princ "\nSelect COGO points: ")
(if (setq ss2 (ssget '((0 . "AECC_COGO_POINT"))))
(progn
(repeat (setq i (sslength ss2))
(setq ent (ssname ss2 (setq i (1- i))))
(if (= "AECC_COGO_POINT" (cdr (assoc 0 (entget ent))))
(progn
(setq pt1 (cdr (assoc 10 (entget ent))))
(foreach x elist
(setq p (vlax-curve-getClosestPointTo
x
pt1
)
)
(if (< (distance p pt1) (distance pt2 pt1))
(setq pt2 p)
)
)
(command "_.move" ent "" pt1 pt2)
)
(princ "\nInvalid selection. Please select a COGO point.")
)
)
)
)
)
)
(princ)
)
When I run this LISP. I get the following result:
Activate command
Select Polyline
Enter
Select Cogo Points
Enter
I then get Error: unable to get ObjectID (entity name: this info changes depending on the cogo points selected)
The end result I am looking for is:
I would like to be able to select all the polylines in a drawing and then select all the cogo points in a drawing and move those points to the closest selected polyline at the same time. i would also like it to prompt where to move the point whether is nearest, end points, or midpoints.
- Thank You
Solved! Go to Solution.