- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I was wondering if someone could help out getting Vertices inserted into multiple polylines (simultaneously) at a specified interval. It must work with arcs as well.
I've searched the web and I've found the following LISP, which works fine but only selects 1 object at a time.
(defun c:demo ( / add_vtx pl int in pt flag )
(vl-load-com)
(defun add_vtx ( obj add_pt ent_name / bulg )
(vla-addVertex
obj
(1+ (fix add_pt))
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray vlax-vbdouble (cons 0 1))
(list
(car (trans (vlax-curve-getpointatparam obj add_pt) 0 ent_name))
(cadr (trans (vlax-curve-getpointatparam obj add_pt) 0 ent_name))
)
)
)
)
(setq bulg (vla-GetBulge obj (fix add_pt)))
(vla-SetBulge obj
(fix add_pt)
(/
(sin (/ (* 4 (atan bulg) (- add_pt (fix add_pt))) 4))
(cos (/ (* 4 (atan bulg) (- add_pt (fix add_pt))) 4))
)
)
(vla-SetBulge obj
(1+ (fix add_pt))
(/
(sin (/ (* 4 (atan bulg) (- (1+ (fix add_pt)) add_pt)) 4))
(cos (/ (* 4 (atan bulg) (- (1+ (fix add_pt)) add_pt)) 4))
)
)
(vla-update obj)
)
(setq pl (car (entsel "\nSelect pline entity")))
(if (not (wcmatch (cdr (assoc 0 (entget pl))) "*POLYLINE"))
(progn
(alert "\nPicked entity isn't polyline - quitting")
(exit)
)
(if (and (or (eq (cdr (assoc 70 (entget pl))) 0) (eq (cdr (assoc 70 (entget pl))) 1)) (eq (cdr (assoc 0 (entget pl))) "POLYLINE"))
(progn
(setq flag T)
(command "_.convertpoly" "l" pl "")
)
(if (not (eq (cdr (assoc 0 (entget pl))) "LWPOLYLINE"))
(progn
(alert "\nYou picked 3d polyline - quitting")
(exit)
)
)
)
)
(setq int (getdist "\nEnter Interval: "))
(setq in int)
(while (setq pt (vlax-curve-getPointAtDist pl int))
(add_vtx (vlax-ename->vla-object pl) (vlax-curve-getparamatpoint pl (vlax-curve-getclosestpointto pl pt)) pl)
(setq int (+ int in))
)
(if flag
(command "_.convertpoly" "h" pl "")
)
(princ)
)
Solved! Go to Solution.