Message 1 of 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
At the point of inserting the block into the line,
Can it be trimmed automatically?
Solved! Go to Solution.
At the point of inserting the block into the line,
Can it be trimmed automatically?
Solved! Go to Solution.
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.
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
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" "")
should be this:
(vl-cmdf "_.Insert" blockname pt1 1 1)
attach includes this modification
glad to have helped...cheers!!!
I modified the ends of the VV block slightly,
But this seems to affect the trim,
Why is this?
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.
very good...now you know how to customize the code as needed...cheers!!!
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.