Jump to content

Recommended Posts

Posted

Hi All,

 

I'm producing some record drawings and would like to automate a task that I need to do on hundreds of drawings. 

 

  • Deleting all dimensions
  • Deleting all MText containing words such as SET, CL, IL, °

 

Could anyone please help me with this? I'm competent in python programming but this is my first time ever looking at automating anything in cad and I'm unfamiliar with any of these languages 

 

Cheers 

Fil

Posted (edited)

Deleting all write-enabled dimensions (i.e. those residing on unlocked layers) from a drawing is relatively straightforward and can be achieved by iterating over the drawing database and deleting all objects whose objectname property matches "AcDb*Dimension*", as the following code demonstrates:

(defun c:deldim ( )
    (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
        (if (= :vlax-false (vla-get-isxref blk))
            (vlax-for obj blk
                (if (and (wcmatch (vla-get-objectname obj) "AcDb*Dimension*") (vlax-write-enabled-p obj))
                    (vla-delete obj)
                )
            )
        )
    )
    (princ)
)
(vl-load-com) (princ)

The above will remove all dimensions from all layouts & block definitions.

 

However, deleting MText containing specific words isn't quite so easy, as the MText content could potentially be interspersed with MText formatting codes, which would need to be removed prior to testing whether the content contains one of the target words.

Edited by Lee Mac
  • Like 3
Posted

Maybe to delete your Mtexts you'll have to use the command find, hit the select all button and then delete them, it's not a program but it'll save you time. or if your Mtext contains the same string let's say CL30 or just CL, you can use qselect and select them all at once and then delete them, but the command qselect just select the texts or Mtexts with the exact same content. Just hope it helps you.

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