Insert into block line

Insert into block line

W_T_
Advocate Advocate
1,313 Views
11 Replies
Message 1 of 12

Insert into block line

W_T_
Advocate
Advocate

At the point of inserting the block into the line,
Can it be trimmed automatically?

 

W_T__0-1692448076764.png

 

0 Likes
Accepted solutions (2)
1,314 Views
11 Replies
Replies (11)
Message 2 of 12

Kent1Cooper
Consultant
Consultant

That's another one just like another recent one, in which a WIPEOUT as part of the Block definition could handle the "breaking" [visibly only] of the underlying Line.

Kent Cooper, AIA
0 Likes
Message 3 of 12

paullimapa
Mentor
Mentor

Give this a try...code requirements are:

1. Block name must be included in this case "VV"

2. Length of Block when inserted at a scale of 1 in this case is 10

; iBlkTrm after insert block trim around Line or Pline
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/insert-into-block-line/m-p/12182369#M453516
(defun c:iBlkTrm (/ ang blocklength blockname en ent osmode pt1 pt2 scl)
  (setq blockname "VV" blocklength 10) ; provide block name & block unit length
  (setq osmode (getvar"osmode")) ; save osnap
  (while (not ent)
    (setq ent(entsel"\nSelect Line or Pline To Insert Block: "))
    (if ent
      ; check to make sure selected is Line or Pline
      (if 
        (not
         (or
          (= (cdr (assoc 0 (entget (car ent)))) "LINE")
          (= (cdr (assoc 0 (entget (car ent)))) "LWPOLYLINE")
         )
        )
        (setq ent nil) ; try again
        (progn
         (setvar "osmode" 0) ; turn off osnap
         (setq en (car ent) pt1 (osnap (cadr ent) "_nea")) ; get entity & point on entity
         (setvar "osmode" osmode) ; retore osnap
         (vl-cmdf "_.Insert" blockname pt1) ; start block insert
         (while (> (getvar "CMDACTIVE") 0) (vl-cmdf pause)) ; fill in scale & rotation
         (setq obj (vlax-ename->vla-object (entlast)))
         ; check to make sure last object is the block
         (if
           (and
             (= (vla-get-ObjectName obj) "AcDbBlockReference")
             (= (vla-get-EffectiveName obj) blockname)
           )
           (progn
             (setq ang (vla-get-Rotation obj)) ; get block rotation angle
             (setq scl (vla-get-XScaleFactor obj)) ; get block scale
             (setvar "osmode" 0) ; turn off osnap
             (setq pt2 (polar pt1 ang (* scl blocklength))) ; locate pt2 based on pt1, angle & scale factored by length of block
             (vl-cmdf "_.Erase" (entlast) "") ; temporarily erase block
             (vl-cmdf "_.Break" pt1 pt2)      ; trim around block using break pt1 pt2
             (vl-cmdf "_.Oops")               ; bring back erased block
             (setvar "osmode" osmode)         ; restore osnap
           ) ; progn
         ) ; if 
        ) ; progn
      ) ; if
    ) ; if
  ) ; while
  (princ)
) ; defun

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 12

W_T_
Advocate
Advocate

Thank you so much.
But to simplify the steps,
I want the scale of the fixed block to be 1.0,
Other steps are unchanged, but without success. . .

 

(vl-cmdf "_.Insert" blockname pt1 "1" "") 

0 Likes
Message 5 of 12

paullimapa
Mentor
Mentor
Accepted solution

should be this:

(vl-cmdf "_.Insert" blockname pt1 1 1)

attach includes this modification


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 12

W_T_
Advocate
Advocate

👍👍👍

0 Likes
Message 7 of 12

paullimapa
Mentor
Mentor

glad to have helped...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 12

W_T_
Advocate
Advocate

I modified the ends of the VV block slightly,
But this seems to affect the trim,
Why is this?

 

W_T__0-1692500605834.png

 

0 Likes
Message 9 of 12

paullimapa
Mentor
Mentor
Accepted solution

Recall that I stated in my prior post that the code has these two requirements:

Block Name & Unit Length.

Since you revised the length of the block, this information needs to be updated in the code here:

(setq blockname "VV" blocklength 11.051) ; provide block name & block unit length

Use attach updated code.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 10 of 12

W_T_
Advocate
Advocate

I just now understand what that 10 means.

 

👍👍👍

0 Likes
Message 11 of 12

paullimapa
Mentor
Mentor

very good...now you know how to customize the code as needed...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 12 of 12

Sea-Haven
Mentor
Mentor

The other alternative is to replace the line or pline with a new pline that includes the wavy section, a Pline supports arcs as part of a pline definition, this is used a lot for insulation. You can code the 180 arcs as part of a pline.

SeaHaven_0-1692579448129.png