select multiple objects at midpoint and align the objects on a (poly)line.

select multiple objects at midpoint and align the objects on a (poly)line.

C_Wauw
Explorer Explorer
429 Views
2 Replies
Message 1 of 3

select multiple objects at midpoint and align the objects on a (poly)line.

C_Wauw
Explorer
Explorer

Hi there,

Is there a function or a LISP routine that allows for the selection of multiple objects or blocks at their midpoint near a polyline, and aligns them at their midpoints to the selected polyline?

Problem:
Cyrano_malawauw_0-1718410163152.png

good:

Cyrano_malawauw_1-1718410405469.png


Who can help me?:) 

 

0 Likes
Accepted solutions (1)
430 Views
2 Replies
Replies (2)
Message 2 of 3

Sea-Haven
Mentor
Mentor

If I understand correctly, you have placed a concrete railway sleeper based on a picture but need it vertically adjusted to train centre line. Why not pick points on train centre line and insert sleeper at 90 degrees to pline automatically. So works on curves also. 

Message 3 of 3

calderg1000
Mentor
Mentor
Accepted solution

Saludos  @C_Wauw 

Pruebe este código, para comenzar...

 

(defun c:mblk (/ sb nl sc i sn sv p pc pr a)
  (princ "\nSelect Blocks and curve to move: ")
  (setq sb (car (entsel "Select Block Base...:"))
        nl (cdr (assoc 8 (entget sb)))
        sc (car (entsel "\nSelect Curve to Move Blocks: "))
  )
  (princ "\nSelect Blocks to move...:")
  (setq
    sn (vl-remove-if
         'listp
         (mapcar 'cadr (ssnamex (ssget (list '(0 . "INSERT") (cons 8 nl)))))
       )
  )
  (foreach i sn
    (setq
      sv (vlax-ename->vla-object i)
      p  (vlax-get sv 'insertionPoint)
      pc (vlax-curve-getClosestPointTo (vlax-ename->vla-object sc) p)
      pr (vlax-curve-getparamatpoint (vlax-ename->vla-object sc) pc)
      a  (angle '(0. 0. 0.)
                (vlax-curve-getfirstderiv (vlax-ename->vla-object sc) pr)
         )
    )
    (vla-move sv (vlax-3d-point p) (vlax-3d-point pc))
    (vla-put-rotation sv a)
  )
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.