Jump to content

Recommended Posts

Posted

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

images (1).png

Posted
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.

Posted

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.

  • Like 1
Posted

Sir Thats 200 table came from Mx Road software.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...