Joe. Posted May 12, 2022 Posted May 12, 2022 Hello I have hundreds of object on straight polyline (with uneven distances) and I need to make that straight line into curve/spline so that objects stay on the line and distance between the objects (along the line curve) will remain the same as they were on straight line. The objects on the line are luminaire blocks, but could be circles/points etc, so I can paste luminaires on desired positions afterwards. Anyone have an idea or existing lisp to achieve that? I searched the Internet and did not find any lisps that I could use. Acad array path function unfortunately did not work. Any help would be appreciated. Quote
mhupp Posted May 12, 2022 Posted May 12, 2022 Don't quite understand what your asking for can you upload a sample drawing? Quote
Joe. Posted May 12, 2022 Author Posted May 12, 2022 Attached simplified dwg. Basically I would like to have objects from blue straight line to curved red line. And the object distances must remain the same (measured along the line). ObjectOnLine.dwg Quote
scj Posted May 12, 2022 Posted May 12, 2022 See the attachement. Is this the solution you are looking for? Regards Jochen www.black-cad.de ObjectOnLine_scj.dwg Quote
mhupp Posted May 12, 2022 Posted May 12, 2022 (edited) Maybe someone can figure out how to make a list of distances by selecting the blocks but this is semi manual. Also this depends on the direction the polyline is drawn. (defun C:foo (/ mspace dist ent blk obj path pt) (vl-load-com) (setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) dist 0.0 blk (cdr (assoc 2 (entget (car (entsel "\nSelect Block: "))))) obj (vlax-ename->vla-object (car (entsel "\nSelect Path: "))) path (vla-get-length obj) ) (while (< dist path) (setq dist (+ dist (getdist))) (setq pt (vlax-curve-getpointatdist obj (+ (vlax-curve-getdistatparam obj (vlax-curve-getstartparam obj)) dist))) (vlax-invoke mspace 'InsertBlock pt blk 1 1 1 0) ) (princ) ) Edited May 12, 2022 by mhupp updated code to exit the while function. 1 Quote
BIGAL Posted May 13, 2022 Posted May 13, 2022 Mhupp "Also this depends on the direction the polyline is drawn." Pick near end you then check the two end points compared to the pick point and if necessary just reverse the line or pline. There is a problem the straight line is 50.000000 the curved line is 49.9997023888379 so they are different. Given the diff 0.001 in say m or mm its within tolerance for the fudge I have done. Only effects the last point. ; copys blocks from a pline to another (defun C:WOW (/ lendist ent blk blksc obj obj2 path pt pti d1 d2 ss) (vl-load-com) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq ent (entget (car (entsel "\nSelect Block: "))) blk (cdr (assoc 2 ent)) blksc (cdr (assoc 41 ent)) ) (setq ent (entsel "\nSelect line: ") pt (cadr ent) obj (vlax-ename->vla-object (car ent)) ) (setq obj2 (vlax-ename->vla-object (car (entsel "\nSelect Path: ")))) (setq len (vla-get-length obj2)) (setq end (vlax-curve-getendpoint Obj) start (vlax-curve-getstartpoint Obj) d1 (distance pt end) d2 (distance pt start) ) (if (< d1 d2) (command "pedit" ent "R" "") ) (setq ss (ssget (list (cons 0 "Insert")(cons 2 blk)))) (repeat (setq x (sslength ss)) (setq pti(cdr (assoc 10 (entget (ssname ss (setq x (1- x))))))) (setq dist (vlax-curve-getdistatpoint obj pti)) (setq pt (vlax-curve-getpointatdist obj2 dist )) (if (= pt nil) (command "-Insert" blk (vlax-curve-getendpoint Obj2) blksc "" 0) (command "-Insert" blk pt blksc "" 0) ) ) (setvar 'osmode oldsnap) (princ) ) (c:WOW) 2 Quote
Joe. Posted May 17, 2022 Author Posted May 17, 2022 WOW, thank You guys! That lips works like a charm. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.