Jump to content

Objects from straight polyline to spline


Joe.

Recommended Posts

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by mhupp
updated code to exit the while function.
  • Like 1
Link to comment
Share on other sites

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)

 

  • Like 2
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...