Align blocks to multiple lines in one go.

Align blocks to multiple lines in one go.

q_Q25S5
Participant Participant
494 Views
3 Replies
Message 1 of 4

Align blocks to multiple lines in one go.

q_Q25S5
Participant
Participant

Hello,

I currently am doing some work in Autocad where i have to place a couple of 100 blocks at the endpoint of lines, however all rotations are different. (See picture)

q_smitsQ25S5_0-1680509807355.png

Is there a way with a LISP or something like that to align these blocks with the lines?

I could do them all manually, but it would be nice if there is another way to do this.

Thanks in advance. 🙂

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

ВeekeeCZ
Consultant
Consultant

Post a small sample dwg with states before and after.

0 Likes
Message 3 of 4

komondormrex
Mentor
Mentor
Accepted solution

hey, check this

 

(defun c:place_align_block_line (/ target_block_name line_data pick_point line_start_point line_end_point block_rotation)
  (setq target_block_name (vla-get-effectivename (vlax-ename->vla-object (car (entsel "\nSelect target block: ")))))
    (while t
    (setq line_data (entsel "\nSelect line end to place block at: ")
            pick_point (osnap (cadr line_data) "_endp")
            line_start_point (cdr (assoc 10 (entget (car line_data))))
          line_end_point (cdr (assoc 11 (entget (car line_data))))
            block_rotation (if (equal pick_point line_start_point 1e-3)
                   (angle line_end_point line_start_point)
                   (angle line_start_point line_end_point)
             )
    )
      (vla-insertblock (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
           (vlax-3d-point pick_point)
           target_block_name
           1 1 1
           block_rotation
    )
  )
)
0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

Yes, please post a sample drawing or image with before and after conditions, and using a Block with a more obvious direction if that mattersFor example, using one with an obvious "right way up," is this kind of orientation what you want [with the Text upright at zero rotation, but with the insertion's rotation determined by the other end of the Line], or should this Block be spun around 180° to read in the more upright direction?

Kent1Cooper_0-1680523477264.png

Also, am I correct that you're talking about the rotations being calculated in the process of Inserting the Blocks, rather than fixing the roatations of Blocks that are already Inserted?

Kent Cooper, AIA
0 Likes