Jump to content

Can't Escape Previous Commands In A Script - AutoCADLT


Scottcad94

Recommended Posts

Hi,

 

Recently been testing the water with writing scripts to try and automate some of the functions that I do repetitively so a newbie to this. Unfortunately only have access to AutoCAD LT so can't use LISP or anything. Have tried the ^C^C and (command) suggested in other forums.

 

Essentially my script something like this:

 

-layer set Datum

 

LINE 0,-14000 850000,-14000

 

-INSERT BLOCK1 10000,20000 1 1 0

 

20000,20000 1 1 0

 

30000,20000 1 1 0

 

-INSERT BLOCK2 37000,7000 1 1 0

 

When I run it in CAD it keeps asking for an insertion point for BLOCK1 (even though I don't want more than 3 in the drawing) - how do I escape this command and move onto next line of commands (insert BLOCK2). Essentially I want equivalent of escape key. Can't find answer anywhere.

 

Thanks in advance

Link to comment
Share on other sites

You may need the block1 for each line, a blank line means enter so you are already doing the -insert second time.

My version, Watch out for space on end of lines.

LINE 0,-14000 850000,-14000

-INSERT
B1
10000,20000
1
1
0

B1
20000,20000
1
1
0

B1
30000,20000
1
1
0

B2
20000,30000
1
1
0

Link to comment
Share on other sites

The problem would appear to be having the blank line after your third insert. That is actually starting the insert command again, which then expects a coordinate. and be careful with the spaces, you have a space character at the end of each line (impossible to see visually). Bigals method of using a linefeed to separate each item is a much better way of writing your code.

Link to comment
Share on other sites

@BIGAL, @steven-g, that works well for inserting my second block, thanks very much. But how then do I move from inserting blocks to a completely new command ie line or something different?

Link to comment
Share on other sites

Just make sure you don't have any extra spaces at the end of the last command, run your script and watch the command line or open the command line history (F2) you should be able to see what is going on. Once you have your script finishing cleanly from the insert commands then just add your next command, so long as your commands accept command line input (no dialogue boxes) then you can make a script as long as you want.

Link to comment
Share on other sites

Like Steven-g you have already done it, you have a blank line between the "line" command and the "-insert" so starts a new command alltogether.

 

Oh pasting to command line produces a different result to loading a script file hence the single line way

 

Script version, note blank line at end needed to stop line command

LINE 0,-14000 850000,-14000

-INSERT 001 10000,20000 1 1 0

001 20000,20000 1 1 0

001 30000,20000 1 1 0

002 20000,30000 1 1 0
LINE  850000,-14000 0,0

Link to comment
Share on other sites

That's great thanks it works now with creating new functions etc. One problem I do encounter with the script is that sometimes when I run it, it inserts everything exactly where I have defined, and other times it is off location? Why does it do this? Do I need to add pauses?

Link to comment
Share on other sites

2 things add osmode 0 this will turn off snaps can cuase funny thing to occur sometimes where it will snap to a end of line etc, the second is have you set a UCS other than World.

Link to comment
Share on other sites

  • 2 weeks later...

Sometimes if you can not see the area of interest AutoCAD can do some funny things, your inserts are at big numbers. Try adding a "zoom C pt scale" use say the 1st insert point, x,y and a scale, this is a known bug for us that have been writing code for a long time. 

Link to comment
Share on other sites

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