Message 1 of 15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I'm still a lisp newbie. I need a lisp function to:
1) offset a polyline by a fixed value inside. (Somehow it doesn't ask for offset value or which side to pick. )
2) picks a vertex (any vertex is acceptable) of the newly offset polyline to a "getpoint" command that comes after.
here are my code so far that doesn't work right from ChatGPT.
(defun c:offsetpl (/ selSet offsetDist)
(setq selSet (ssget "X" '((0 . "LWPOLYLINE"))))
(if selSet
(progn
(command "_offset" "1.0" selSet)
(princ "\nOffsetting polyline completed.")
)
(princ "\nNo polyline selected.")
)
(princ)
)
and this for the second part which doesn't work at all :
(defun c:plcoord ()
(setq selSet (ssget "X" '((0 . "LWPOLYLINE"))))
(if selSet
(progn
(setq polylineObj (vlax-ename->vla-object (ssname selSet 0)))
(setq vertexCount (vlax-get-property polylineObj 'NumberVertex))
(if (> vertexCount 0)
(progn
(princ "\nPolyline Coordinates:")
(setq i 0)
(while (< i vertexCount)
(setq vertex (vlax-curve-getPointAtParam polylineObj i))
(setq x (car vertex))
(setq y (cadr vertex))
(setq z (caddr vertex))
(princ (strcat "\nVertex " (itoa (1+ i)) ": (" (rtos x 2 6) ", " (rtos y 2 6) ", " (rtos z 2 6) ")"))
(setq i (1+ i))
)
)
(princ "\nThe polyline has no vertices.")
)
)
(princ "\nNo polyline selected.")
)
(princ)
)
How can I get it to work smoothely?
Solved! Go to Solution.