Automating repetitive tasks in AutoCAD

Automating repetitive tasks in AutoCAD

tabeertariq
Participant Participant
3,223 Views
13 Replies
Message 1 of 14

Automating repetitive tasks in AutoCAD

tabeertariq
Participant
Participant

I have a series of projects which are all similar. The first task is to clean CAD files. Select layers and delete them. Then, Explode other a few layers and clean them.

 

This takes so much time manually. I would appreciate some suggestions on how to automate this. What steps/path should i take? Any scripting extension software? What would be the most easiest and efficient way to go about this?

0 Likes
3,224 Views
13 Replies
Replies (13)
Message 2 of 14

whitney_jeff
Collaborator
Collaborator
Accepted solution

go to CADIG.com and download the freee AutoScript thing.
Using scripts and lisp you can automate a lot, but as far as layer names they all need to be close to the same, or at least have some commonality so that you can use wildcards - same with blocks and other objects you want to manipulate

 

0 Likes
Message 3 of 14

paullimapa
Mentor
Mentor
Accepted solution

Please provide in detail exactly what the repetitive tasks are. When you say clean do you mean purge? Select exactly the same layers on all dwgs to delete? What happens if those layers cannot be deleted?  Do you want everything exploded  including Dimensions/Mtexts or only certain Blocks?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 14

cadffm
Consultant
Consultant
Accepted solution

Hi 

 

learn to use native commands in commandline, like Command LAYDEL

-PURGE ..

If you have a working Script(for using in the current file),

you can use a 3rd party Tool for the "Batch" part.

 

1000 tutorial

and F1 informations

https://help.autodesk.com/view/ACD/2022/ENU/?guid=GUID-BE44AE86-7638-48C9-BE5B-C1DF8E4C8808

 

Or start to learn LISP (or another API, if you are familiar with .bet or vba?)

 

 

 

 

 

Sebastian

0 Likes
Message 5 of 14

VincentSheehan
Advisor
Advisor
Accepted solution

You can write a script or LISP to run the tasks. If you have access to Civil 3D , you can use the Batch Save Utility to run the script/Lisp on multiple drawings.

 

This may help with writing scripts.

https://www.autodesk.com/autodesk-university/class/AutoCAD-Quick-Scripting-Spreadsheets-2021 

 

 

Vincent Sheehan

Sr. Civil Designer
Poly In 3D Blog

0 Likes
Message 6 of 14

TomBeauford
Advisor
Advisor
Accepted solution

Like Paul Li said Please provide in detail exactly what the repetitive tasks are. While the LAYDEL (Command) works great for discarding things you no longer need the EXPLODE (Command) can cause issues like dramatically increasing the size of your drawing. Having a corrected block saved somewhere that could be used to update those defined in that drawing would be quicker and produce better results.

Attaching small before & after examples might allow specific answers to your question.

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
0 Likes
Message 7 of 14

tabeertariq
Participant
Participant

The CAD file i am receiving has alot of layers and blocks. There are standard steps in all of the projects when we recieve these files. We need to:

1) Open X REFS and delete building shell and site background REF. Then Bind all.

 

Next...

This file ultimately has to be Linked to Revit. Its a large file and we dont want to make the model heavy. We are also doing this to achieve graphic clarity because the CAD has alot of information. 

 

Hence..

2) We need to Turn off and freeze certain layers. These layers are usually same on all dwgs and they have to freeze and be turned off. Some of these layers have text in them and the others have polygons. 

 

3) Moving on to certain blocks. These blocks have gates and its annotations. We want to explode the block and delete the extra annotations and text. As a result we will be left with the gate only. Creating it into a block again is not required. 

 

Then we save as with a new name and load it to BIM 360. 

 

0 Likes
Message 8 of 14

tabeertariq
Participant
Participant
Accepted solution

Hello Tom, these are the details of the tasks i am trying to automate. 

 

The CAD file i am receiving has alot of layers and blocks. There are standard steps in all of the projects when we recieve these files. We need to:

1) Open X REFS and delete building shell and site background REF. Then Bind all.

 

Next...

This file ultimately has to be Linked to Revit. Its a large file and we dont want to make the model heavy. We are also doing this to achieve graphic clarity because the CAD has alot of information. 

 

Hence..

2) We need to Turn off and freeze certain layers. These layers are usually same on all dwgs and they have to freeze and be turned off. Some of these layers have text in them and the others have polygons. 

 

3) Moving on to certain blocks. These blocks have gates and its annotations. We want to explode the block and delete the extra annotations and text. As a result we will be left with the gate only. Creating it into a block again is not required. 

 

Then we save as with a new name and load it to BIM 360. 

0 Likes
Message 9 of 14

tabeertariq
Participant
Participant

Hello, 

 

I wanted some guidance on which API is best suited for these tasks? LISP, .bet or vba? I have mentioned the tasks below. 

 

 

The CAD file i am receiving has alot of layers and blocks. There are standard steps in all of the projects when we recieve these files. We need to:

1) Open X REFS and delete building shell and site background REF. Then Bind all.

 

Next...

This file ultimately has to be Linked to Revit. Its a large file and we dont want to make the model heavy. We are also doing this to achieve graphic clarity because the CAD has alot of information. 

 

Hence..

2) We need to Turn off and freeze certain layers. These layers are usually same on all dwgs and they have to freeze and be turned off. Some of these layers have text in them and the others have polygons. 

 

3) Moving on to certain blocks. These blocks have gates and its annotations. We want to explode the block and delete the extra annotations and text. As a result we will be left with the gate only. Creating it into a block again is not required. 

 

Then we save as with a new name and load it to BIM 360. 

 

0 Likes
Message 10 of 14

paullimapa
Mentor
Mentor

1) Open X REFS and delete building shell and site background REF. Then Bind all

Bind all xrefs can be accomplished as command in a Script file like this::

-XREF _Bind *

But may not be possible to open the xrefs and identifying those objects to delete

 

2) We need to Turn off and freeze certain layers. These layers are usually same on all dwgs and they have to freeze and be turned off. Some of these layers have text in them and the others have polygons. 

This also can be done as commands in a script file. For example to turn off & freeze layer names: A-BLD-TXT, A-BLD-DIM then the command is:

-LAYER _Set 0 _Off A-BLD-TXT, A-BLD-DIM _F A-BLD-TXT, A-BLD-DIM 

 

Make sure you have an additional empty line following above command in script to to complete command

 

3) Moving on to certain blocks. These blocks have gates and its annotations. We want to explode the block and delete the extra annotations and text. As a result we will be left with the gate only. Creating it into a block again is not required. 


This might be possible to script assuming the Block name is always the same but you'll have to provide examples of the Block to see what those annotations/texts are made of.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 11 of 14

cadffm
Consultant
Consultant

You don't need to answer for each the same text separately :×

 

"which API is best suited for these tasks?"

99-100% of this task, you don't need an API to do this, so every API is okay for it.

 

If you are not familiar with these APIs, I would start with simple scripts 

with a handfull of Lisp statements, which makes thinks like object selection easier.

Simple controlling by standard (commandline) commands,

which makes thinks like object selection easier

 

(Tasks like yours are common and often discussed here and in next door - customization board)

Sebastian

Message 12 of 14

tabeertariq
Participant
Participant

Can you help me with one step? How t=do i write the following in a script?

 

In the first part we need to open Xref and delete civil background file and site background file. Then we have to bind the remaining my bind all and saveAs the file in a new location. 

 

Then step 2 follows which includes deleteing and editing stuff.

0 Likes
Message 13 of 14

paullimapa
Mentor
Mentor

"open Xref..."

This part can only be done in a script if it knows what the name of the xref is....

But that's a big if...how does one know this without user intervention?

 

"and delete civil background file and site background file"

This is another difficult part to do in a script...

Again how does the computer know which objects are on civil & site backgrounds vs the ones that are not?

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 14 of 14

cadffm
Consultant
Consultant

If both are .dwg-Xrefs in your Main file and you want to detach them:

Is the namesyntax unique, so other Xrefs won't detach?

_-XREF

_detach

A*

for all xrefs with names starting with A

or similar.

-XREF is the command

_detach the option

and now, look for a working wildcard pattern.

Sebastian

0 Likes