@cclawsonD6QHU hi,
OK check this program. wrap this code lines in drills.lsp.
also attached sample_panel.dwg, test this on this file, load the lisp
the dwg contains a modified square panel block which is not annotative anymore (and it should stay 😀)
do not try to run this on your existing blocks, simply it will not work
Once you stretch the block (by it's dynamic hor/ver grip handles) the drill holes will be scattered - job done 🙏
Note:
The first time you insert "square panel" block (still not stretched) it's name is "square panel". once you stretch it, it's name changes to *Unnn
this called Anonymous Block (it's copy of the origin) but AutoCAD know it's derived from origin . my lisp program works on the anonymous block.
manually updating the origin "square panel" (BEDIT \ block edit) all the drill holes are vanished, they are not part of the origin block.
so you need to take care about this. each activation drags regenerating drawing to reflect the change.
you can also invoke DRILLS command to scatter drill holes (updating the block)
; define some const global
(setq MA:BLKNAME "square panel")
(setq MA:DRILL_LINE_LAYER "guide lines")
(setq MA:DRILL_HOLES_LAYER "+drill holes")
the above 3 variables, defines the block name + layers
if you need to change the block name and\or layers, you need to modify these lines.
the lisp adds an event (known in AutoLISP as Reactor) to monitor each stretch actions. if lisp is not responding, probably the reactor is not
loaded \ installed. best practice is to close AutoCAD and start over.
enjoy
Moshe
(vl-load-com) ; load activex support
(defun process_drills (ss1 / clear_existing_drill_holes ; local function
adoc blocks ss radius-feet radius-inches AcDbBlkRef bname ; local variables
AcDbBlkTblRec AcDbEntity len n p0 p1 p2 d0 AcDbCircle) ; local variables
; clear existing drills holes
(defun clear_existing_drill_holes (ent / BlkRef bname BlkTblRec)
(setq BlkRef (vlax-ename->vla-object ent))
(setq bname (vla-get-name BlkRef))
(setq BlkTblRec (vla-item blocks bname))
(vlax-for Entity BlkTblRec
(if (and
(eq (vla-get-objectName Entity) "AcDbCircle")
(eq (strcase (vla-get-layer Entity)) (strcase MA:DRILL_HOLES_LAYER))
)
(vla-delete Entity)
)
(vlax-release-object Entity)
)
(vlax-release-object BlkTblRec)
(vlax-release-object BlkRef)
); clear_existing_drill_holes
; here start (process_drills)
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
(vla-startUndoMark adoc)
(setq blocks (vla-get-blocks adoc))
(setq radius-feet (/ 1 16 12.0)) ; 1/16 inch expressed as feet
(setq radius-inches (cvunit radius-feet "feet" "inches")) ; convert to inches decimal
(foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1)))
(clear_existing_drill_holes ename)
(setq AcDbBlkRef (vlax-ename->vla-object ename))
(setq bname (vla-get-name AcDbBlkRef))
(if (eq (strcase (vla-get-effectiveName AcDbBlkRef)) (strcase MA:BLKNAME))
(progn
(setq AcDbBlkTblRec (vla-item blocks bname))
(vlax-for AcDbEntity AcDbBlkTblRec
(if (and
(eq (vla-get-objectName AcDbEntity) "AcDbLine")
(setq len (vla-get-length AcDbEntity))
(> len 2.0)
(eq (strcase (vla-get-layer AcDbEntity)) (strcase MA:DRILL_LINE_LAYER))
)
(progn
(if (= len 12)
(setq n (/ len 12.0))
(setq n (1+ (fix (/ len 12))))
)
(setq p0 (vlax-safearray->list (vlax-variant-value (vla-get-startPoint AcDbEntity))))
(setq p1 (vlax-safearray->list (vlax-variant-value (vla-get-endPoint AcDbEntity))))
(setq d0 0 step (/ len n))
(while (<= d0 len)
(setq p2 (polar p0 (angle p0 p1) d0))
(setq AcDbCircle (vla-addCircle AcDbBlkTblRec (vlax-3d-point p2) radius-inches))
(vla-put-layer AcDbCircle MA:DRILL_HOLES_LAYER)
(vlax-release-object AcDbCircle)
(setq d0 (+ d0 step))
); while
); progn
); if
(vlax-release-object AcDbEntity)
); vlax-for
); progn
); if
(vlax-release-object AcDbBlkTblRec)
(vlax-release-object AcDbBlkRef)
); foreach
(vlax-release-object blocks)
(vla-regen adoc acActiveViewport)
(vla-endUndoMark adoc)
(vlax-release-object adoc)
(princ)
); process_drills
; define some const globals
(setq MA:BLKNAME "square panel") ; const
(setq MA:DRILL_LINE_LAYER "guide lines") ; const
(setq MA:DRILL_HOLES_LAYER "+drill holes") ; const
; for manual activate
(defun c:drills (/ ss0)
(if (setq ss0 (ssget (list '(0 . "insert") (cons '2 (strcat MA:BLKNAME ",`*U*")))))
(process_drills ss0)
)
); c:drills
; callback
(defun MA:OnCommandEnded (Reactor cmd^)
(if (and
(eq (car cmd^) "GRIP_STRETCH")
(setq ss (ssget "_P"))
)
(c:drills)
)
); MA:OnCommandEnded
; install Reactor
(if (not MA:cmdReactor)
(setq MA:cmdReactor (vlr-command-reactor nil '((:vlr-commandEnded . MA:OnCommandEnded))))
)