Scottcad94 Posted August 15, 2018 Posted August 15, 2018 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 Quote
BIGAL Posted August 16, 2018 Posted August 16, 2018 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 Quote
steven-g Posted August 16, 2018 Posted August 16, 2018 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. Quote
Scottcad94 Posted August 16, 2018 Author Posted August 16, 2018 @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? Quote
steven-g Posted August 16, 2018 Posted August 16, 2018 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. Quote
BIGAL Posted August 17, 2018 Posted August 17, 2018 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 Quote
Scottcad94 Posted August 24, 2018 Author Posted August 24, 2018 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? Quote
BIGAL Posted August 25, 2018 Posted August 25, 2018 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. Quote
Scottcad94 Posted September 3, 2018 Author Posted September 3, 2018 @BIGAL no snaps is already off and ucs set to world Quote
BIGAL Posted September 4, 2018 Posted September 4, 2018 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. Quote
Recommended Posts
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.