& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
I need to separate polyline by point on it and add a curve from a polyline to this point like it drawn on picture with option to reverse this curve and join polyline after all..
Is it possible to do it programmatically (via lisp function)?
Any help or suggestions will be very appreciated
Solved! Go to Solution.
Would this always be in a single-line-segment Polyline as in the picture [which shouldn't be too difficult], or would it sometimes be in segment within a longer Polyline [much more complicated, I think]?
Try this lisp. Tested in WCS and UCS, but not for 3D rotated polylines; new vertex only on straight segments, IF there is enough space to draw the arcs. Also, feel free to add your favorite error trap.
;Add vertex to polyline ;Stefan M. 30.10.2018 (defun c:adv ( / *error* add_vertex e p1 p2 d a b1 b2 u q g) ;;; (setq *error* (err)) (defun add_vertex (e a p) (vla-addvertex e a (vlax-safearray-fill (vlax-make-safearray vlax-vbDouble '(0 . 1)) (list (car p) (cadr p)) ) ) ) (if (and (setq e (ssget "_+.:S:L" '((0 . "LWPOLYLINE")))) (setq e (vlax-ename->vla-object (ssname e 0))) ) (while (setq p1 (getpoint "\nSpecify point to add vertex: ")) (setq p1 (trans p1 1 0) p2 (vlax-curve-getclosestpointto e p1) a (fix (vlax-curve-getparamatpoint e p2)) ) (if (and (equal (vla-getbulge e a) 0.0 1e-8) (setq d (distance p1 p2) b1 (vlax-curve-getpointatparam e a) b2 (vlax-curve-getpointatparam e (1+ a)) ) (and (> d 0) (> (distance b1 p2) d) (> (distance b2 p2) d) ) (setq u (angle b2 b1) q (< (* (- (cadr p1) (cadr b1)) (cos u)) (* (- (car p1) (car b1)) (sin u)) ) g (* (if q 1 -1) (1- (sqrt 2))) ) ) (progn (add_vertex e (+ 1 a) (polar p2 (angle p2 b1) d)) (add_vertex e (+ 2 a) p1) (add_vertex e (+ 3 a) (polar p2 (angle p2 b2) d)) (vla-setbulge e (+ 1 a) g) (vla-setbulge e (+ 2 a) g) ) ) ) ) ;;; (*error* nil) (princ) )
Wow phanaem !
It's genius! I thought about how to reverse curves depends of point destination and how to join segments after transforming, but here all my questions find appropriative answer
Thank you Stefan M for your master and brief solution
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name