Project Wide Utilities using script and action.

Project Wide Utilities using script and action.

SeedyNotions
Advocate Advocate
1,423 Views
7 Replies
Message 1 of 8

Project Wide Utilities using script and action.

SeedyNotions
Advocate
Advocate

So I recorded and action, named QWE. That action highlights an area, deletes the contents and purges blocks. Then I copy a good block with a basepoint of 0,0.

 

I wrote a quick script:

(command "QWE")
(command "_pasteclip" "0,0")
(command ".qsave")
(princ)

 

When I run this script using Project Wide Utilities, it stalls at the first page, until I click in the drawing window. Then it moves to the next drawing in the project.

 

Here's the command log:

 

Command: (command "QWE")
QWE Regenerating model.
_.ACMRSELECT
Select objects: _Crossing
Specify first corner: -11.59525917117410,4.032727427062099 Specify opposite corner: 15.28275920647508,-8.470227418184485 1 found

Select objects:
Command: ERASE
Select objects:   1 found

Select objects:
Command: -PURGE
Enter type of unused objects to purge [Blocks/DEtailviewstyles/Dimstyles/Groups/LAyers/LTypes/MAterials/MUltileaderstyles/Plotstyles/SHapes/textSTyles/Mlinestyles/SEctionviewstyles/Tablestyles/Visualstyles/Regapps/Zero-length geometry/Empty text objects/Orphaned data/All]: Blocks Enter name(s) to purge <*>: * Verify each name to be purged? [Yes/No] <Y>: _N Deleting block "PLCIO_I_2TERM".
1 block deleted.

Command: Playback of action macro complete

nil

Command: (command "_pasteclip" "0,0")
_pasteclip Substituting [simplex.shx] for [romansl.shx].
Specify insertion point: 0,0
Command: nil

Command: (command ".qsave")
.qsave
Command: nil

Command: (princ)

Command:

 

 

If you see something let me know. I miss leaning back and letting the magic happen.

 

Thank you,

 

J.

0 Likes
1,424 Views
7 Replies
Replies (7)
Message 2 of 8

jamorrison
Advocate
Advocate

I have had this happen if the drawing is in paper space, so I add the command MODEL first, to put in in model space.

I usually do this with the ACAD.lsp file, so the project wide utilities likely works different.

Just wondering though, is the block you are changing, the same name in each drawing? you could just use a Swap/Update block, it works for any block.

0 Likes
Message 3 of 8

SeedyNotions
Advocate
Advocate

You're right. I forgot that the model space matters as well. I'm trying to teach some guys how to insert good IO blocks into a drawing set. They've altered the templates that I gave them so now the IO blocks don't work. Problem is I've kept the original block the same in the original library path. I keep everything I've altered one level up and add that path to the support file location path so AutoCAD defaults to the new location. So since the path was already embedded in the drawing I wanted to make certain the new block was the one that was added. I'll just through (command "_.TILEMODE" "1") into the script file first and things should work out fine. It's been awhile since I've had to alter an entire drawing set with such an integral part.

 

Thanks for the reminder, I'll give it a shot tonight and post back results.

 

Thanks,

 

J

0 Likes
Message 4 of 8

dougmcalexander
Mentor
Mentor
I'm just curious why you can't use Update block. It deletes, purges, and replaces with a newer version of the block, drawing-wide or project-wide.

Doug McAlexander
Design Engineer/Consultant/Instructor/Mentor
Specializing in AutoCAD Electrical Implementation Support
Phone: (770) 841-8009
www.linkedin.com/in/doug-mcalexander-1a77623

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 5 of 8

Anonymous
Not applicable

I am having a similar problem, but I am trying to update a title block.

 

I have tried to do a project-wide swap/update block command, and it almost works.  It will update the non-attribute parts of the title block, but it leaves the attributes associated with the original title block setup.

 

When I delete the title block and purge the blocks, then i can insert the exact same block and the attributes will work properly.

 

I have set up a script that will delete, purge, and insert the block, and this works well when I then do a title block update.  But when I try to run the script on all pages using the project utilities command, it hangs on the first one.

 

Here is the script I am using:

 

(command "erase" (SSGET "X" '((0 . "INSERT") (2 . "PNL_ACADE_TITLE_VERT"))) "")
(setvar 'ATTDIA 0)
(command "-purge" "B" "PNL_ACADE_TITLE_VERT" "N")
(command "_.-insert" "PNL_ACADE_TITLE_VERT.dwg" "0,0" "1" "1" "0")
(setvar 'ATTDIA 1)
(command "_regenall")

 

Any help would be very appreciated.

 

Tyler D

 

 

UPDATE:  I discovered that I had an extra carriage return at the very end and that this is what was causing the script to hang.  After deleting the blank line, it works on a project wide basis.

0 Likes
Message 6 of 8

jamorrison
Advocate
Advocate

When you do a Swap/Update block on something with attributes, you might need to do the ATTSYNC command. This will force the attributes to behave.

Then do the swap/update block again, because the ATTSYNC sometimes loses the layer information (text colors). Try the command on a drawing and you will see what I mean.

 

0 Likes
Message 7 of 8

Anonymous
Not applicable

I tried the ATTSYNC command, and it had no effect on the attributes of the title block. 

 

I found that if I explode the title block and redefine it with the title block setup, this also makes it so the attributes are in their new positions.

 

The new title block does not have all the same attributes as the old one, and the attributes are linked to different lines in the project descriptions.  I think that the unique functionality of the title block is what is responsible for its resistance to the swap/update block command.

0 Likes
Message 8 of 8

SeedyNotions
Advocate
Advocate
It's not a smart drawing set. They had made the set in LT. I just added them to a project to get rid of their drives in the schematics. There was more than just the blocks that were to be deleted. A rectifier bridge and some other stuff. That's why I needed an action instead of a swap block.
0 Likes