Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Script or lisp program for delete and insert

8 REPLIES 8
Reply
Message 1 of 9
Jason-Cad-123
2564 Views, 8 Replies

Script or lisp program for delete and insert

Can anyone write a script or Lisp that will work through a list of drawings in excel. then open each drawwing and erase two items. and then inserts a new block and explode and close. I have to do this for about 100 drawings.

 

Open first drawing in list

erase, crossing, 790,19 790,28 (Coords)

erase, crossing, 553,83 560,103 (Coords)

insert, 0-Revision P2.dwg at 792.5, 17.5

then explode and close the drawings.

 

opens next drawings in exel list and do the same thing until finished

 

I have attached some samples                           

8 REPLIES 8
Message 2 of 9
dmfrazier
in reply to: Jason-Cad-123

You can easily start this process yourself by writing a script using the info you posted.

 

In Help, there are examples of how scripts work:

http://docs.autodesk.com/ACD/2013/ENU/files/GUID-95BB6824-0700-4019-9672-E6B502659E9E.htm

and info about how to write a script.  For example:

http://docs.autodesk.com/ACD/2013/ENU/files/GUID-9F648910-2D8C-4AED-B796-FD977D52872E.htm

 

"erase, crossing, 790,19 790,28 (Coords)

erase, crossing, 553,83 560,103 (Coords)

insert, 0-Revision P2.dwg at 792.5, 17.5

then explode and close the drawings."

 

Open one of your DWGs and enter all that on the command line.  Before you close the DWG, hit F2, copy all your inputs (and the prompts) and paste it all into a new, plain text file using Notepad.  Remove all the prompts so that the file contains only your inputs (commands, options, etc.) and spaces to represent <Enter>.  Save the file with a meaningful name and an SCR extension.  Save it in a folder that is included in your Support Files Search path.

 

In the process, you will have learned how to write a script and run a script, and you will get one of your 100 DWGs done.

 

For the next step, learn about ScriptPro, which helps you to run a script on multiple DWG files.  Here's a link to get you started:

 

http://autodesk.blogs.com/between_the_lines/2012/06/scriptpro-for-autocad-32bit-and-64bit.html

 

The experience of doing this yourself will be much more valuable to you in the long run than having someone else do it for you.

 

 

 

 

 

Message 3 of 9
hmsilva
in reply to: dmfrazier


@dmfrazier wrote:
...

 

The experience of doing this yourself will be much more valuable to you in the long run than having someone else do it for you.

 


Agreed!

 

As for Scriptpro, links are broken, I don't know if it was discontinued or not, and can't find a functional link. Maybe someone else can post a functional link, because it is a very useful program.

 

Henrique

EESignature

Message 4 of 9
dmfrazier
in reply to: hmsilva

Bummer about ScriptPro.  (I don't actually use it, but I know it has been a popular tool.)

 

I suppose this might be a suitable alternative (no experience): http://www.cadig.com/products/autocad-script-pro.php

 

My preference is to use LISP, anyway, but I thought that it would be asking too much of the OP to start there.

Message 5 of 9
hmsilva
in reply to: dmfrazier


@dmfrazier wrote:
...

My preference is to use LISP, anyway...



Mine too...

 

Cheers

Henrique

EESignature

Message 6 of 9
dmfrazier
in reply to: hmsilva

I just tested Cadig's AutoScript and it's quite nice.  Installed easily, nice user interface, does what it says it does.

 

If the OP has successfully produced a valid script, I see no reason why he shouldn't have this project completed by lunchtime.Smiley Wink

Message 7 of 9
hmsilva
in reply to: dmfrazier

I did tested Cadig's AutoScript also, and everything went as expected.

It's a a good tool too.

 

Henrique

EESignature

Message 8 of 9

Jason,

I think that the taks which you have detailed could be done without the need for any script or lisp by using the

 tools called “BatchInDatabase” and “BatchInEditor”  which are FREE and available to download from Autodesk Exchange Apps, links are below

http://apps.exchange.autodesk.com/ACD/en/List/Search?query=batchindatabase&facet=&collection=&sort=d...

http://apps.exchange.autodesk.com/ACD/en/List/Search?query=batchineditor&facet=&collection=&sort=dat...

 

In BatchInDatabase , the drawings will not be opened in AutoCAD editor but operations are being done in memory, so the process time will be significantly less.

See the YouTube video for the command in action http://www.youtube.com/watch?v=k3l3JhJCVJ8

 

In BatchInEditor, the drawings will be opened in editor, so as to run user defined commands( lisp, script etc..)

 

Both tools are powerful with lots of built-in commands, so make the CAD Managers and User less dependent on developing lisp and script for additional CAD solutions and CAD enhancement.

 

Steps:

1. Load all the files into "BatchInEditor" or "BatchInDatabase"

2. open any one of the file into AutoCAD, this is just to get the entities you want to delete (condition: entities are exist in the same location in all files), double click the command "Entity-Erase" then select the entities, in your case , first the Mtext entities and then Revision text then apply to add the command to list

3. Add the second command "Block-Insert" with option of explode and insertion points

4. add these 2 commands to all the files loaded into the application then, "testRun" to check, everything is working as expected

5. if it is satisfactory then run the batch to process rest of the files in the list.

 

Entity-Erase.JPG

Insert block.JPG

 

Give it a try and let me know.

 

 

Regards,

AbubakarS

Message 9 of 9

FWIW: The installer for ScriptPro 2.0 can be downloaded from here: ScriptPro 2.0 installer

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

Post to forums  

Autodesk Design & Make Report

”Boost