AutoCAD Electrical Forum
Welcome to Autodesk’s AutoCAD Electrical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Electrical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete block and replace script

7 REPLIES 7
Reply
Message 1 of 8
MTE Controls
4336 Views, 7 Replies

Delete block and replace script

Hello all. Eric Here.

Looking to replace the existing TB with an improved one.

I am looking for help on writing a script to pick a block and erase (delete) it. Then I'll purge it out and replace it with a new one of the same name.

The purge and replace I have but it's the erase I am having problems with.

This is my purge:
;; PURGE BLOCK
;; EDIT "yourblockname" TO SUIT
_PURGE
_B
"yourblockname"
_N
_QSAVE
;END SCRIPT

This is the insert new one:
;;INSERT A BLOCK AT 0,0
;; EDIT "yourblockname" TO SUIT
_INSERT
"yourblockname"
0,0


;THE ABOVE 2 CARRIAGE RETURNS
;ARE REQUIRED
;Ortho Angle
0
_ZOOM
_A
_QSAVE
;END OF SCRIPT

Both work even combined, again it's the select a block and erase that I can not seem to get to work.

Thanks.
Eric.
7 REPLIES 7
Message 2 of 8
Peter_KSBE
in reply to: MTE Controls

Hi Eric,

Why don't you use the "Swap/Update Block utility wich is inside AE. You can swap or update for the entire project or on drawing.
Think you need option B "update a block"
Where do you find this. Well when you click and hold the "insert component" icon it is at the bottom end.

Peter
Message 3 of 8
MTE Controls
in reply to: MTE Controls

Hi Peter,

I'm looking for this function "Swap/Update Block utility" but do not seem to locate it. I'm running AcadE 2007. If this works that would be great.

Thanks
Eric
Message 4 of 8
Peter_KSBE
in reply to: MTE Controls

See picture where to find it.
Like I told you it is at the bottom of the "insert component" flyout.
Message 5 of 8
MTE Controls
in reply to: MTE Controls

Thanks just found it. This will help alot.

Thanks
Eric
Message 6 of 8
MTE Controls
in reply to: MTE Controls

For those following this thread and the "Title Block Update" here is a script that works but keep in mind it does not keep current "Values" nor "Scale". But with TB updater that is not mutch of a problem.

Have fun people:

;; FIND AND ERASE BLOCK
;; EDIT "yourblockname" TO SUIT
(setq ss (ssget "_X" '((0 . "INSERT") ( 2 . "yourblockname"))))
;; Find all blocks named "yourblockname"
(if ss (command "_.ERASE" ss ""))
;; PURGE BLOCK
;; EDIT "yourblockname" TO SUIT
_PURGE
_B
"yourblockname"
_N
_QSAVE
;; END SCRIPT
;; INSERT A BLOCK AT 0,0
;; EDIT "yourblockname" TO SUIT
_INSERT
"yourblockname"
0,0


;; THE ABOVE 2 CARRIAGE RETURNS
;; ARE REQUIRED
;; Ortho Angle
0
_ZOOM
_A
_QSAVE
;; END OF SCRIPT
Message 7 of 8
controlsgirl
in reply to: MTE Controls

MTE Controls, thanks for the post. I just wanted to simply delete a block and purge it so I used your script minus the add. Now I just have to find a good quick reference guide that shows me what "ss" stands for(and other similar code) and how it's used :). It doesn't look quite as simple as entering what I normally would type if I were typing commands. 

Message 8 of 8

Look for AutoLisp help.

"ss" is the generic name assigned to the block and not an instruction; it is done on this line:

(setq ss (ssget "_X" '((0 . "INSERT") ( 2 . "yourblockname")))) 

 

From the help file:

setq = Sets the value of a symbol or symbols to associated expressions

 

Hope this helps,

Stefan

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost