Ish Posted April 26, 2021 Posted April 26, 2021 Dear team, I have more than 200 object (as image attached) in a cad file. This object have line and text only. I want to make block of each that object. Automatically make block and keep Block name series like c1,c2. Without change position, location or orientation. Thanks Quote
mhupp Posted April 26, 2021 Posted April 26, 2021 46 minutes ago, Ish said: Without change position, location or orientation. I'm guessing the 200 objects are at different locations and you want to make them blocks at their perspective locations? This should be what your looking for. ;;----------------------------------------------------------------------;; ; Creates a C_# block from selected objects at LL point (defun C:foo (/ SS i BlkName LL UR oLL oUR) (setvar 'clayer "0") (if (setq SS (ssget)) (progn (BBox) ;overall bounding box of selected objects (setq i 1 BlkName (strcat "C" (itoa i))) (while (tblsearch "BLOCK" BlkName) (setq BlkName (strcat "C" (itoa (setq i (1+ i)))) ) ) (vl-cmdf "_.Block" BlkName "_non" LL SS "") (vl-cmdf "_.Insert" BlkName "_non" LL 1 1 0) (print (strcat BlkName " Is Made")) ) ) (ENDCHECK) ) ;;----------------------------------------------------------------------;; ;Get Bounding box of entity (defun BBox (/ i) ; = Object's Bounding Box corners (setq i 0) (vla-getboundingbox (vlax-ename->vla-object (ssname SS i)) 'minpt 'maxpt) (setq oLL (vlax-safearray->list minpt) ; Object's Lower Left oUR (vlax-safearray->list maxpt) ; Object's Upper Right ) (setq LL oLL UR oUR) ; initial overall LL & UR [of first object] (repeat (1- (sslength SS)) (setq i (1+ i)) (vla-getboundingbox (vlax-ename->vla-object (ssname SS i)) 'minpt 'maxpt) (setq oLL (vlax-safearray->list minpt) ; Object's Lower Left oUR (vlax-safearray->list maxpt) ; Object's Upper Right ) (setq LL (mapcar 'min oLL LL) ; least of each component UR (mapcar 'max oUR UR) ; greatest of each component ) ) (princ) ) my 2 cents don't just use a generic block name with a rolling #. try to make them unique. like Drawing_name_C# or something. If you use these block in your daily process. copying C3 from one project to another will not be good since its already defined in both. Quote
tombu Posted April 26, 2021 Posted April 26, 2021 Just wondering where those 200 tables came from. Seems like they'd already be blocks with attributes or AutoCAD or Civil tables. Cannot imagine someone drawing and filling in values for every one of them when they could have been added programmably. 1 Quote
Ish Posted April 26, 2021 Author Posted April 26, 2021 Sir Thats 200 table came from Mx Road software. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.