webster Posted May 22, 2021 Posted May 22, 2021 Hi all, Fairly new to scripting and have hit a roadblock. Essentially, the attached file works if I execute the commands by typing it out from the command line. Except when I am dropping the scr version in, it seems to stop and get confused after selecting all. All I am trying to do (so far) In this script is the following, I switch to model space select all and change all Lineweights and Linetypes of selected objects to 'by layer' then setting All layer Lineweights to 0 then setting layer 0 to a lineweight of 0.2 Can anyone spot what I am doing wrong here? Appreciate the help. Set_LW.txt Quote
tombu Posted May 22, 2021 Posted May 22, 2021 At a glance for changing properties both Ltype & Ltscale start with LT. Changing LT to Ltype may help. As Lineweights are real numbers setting them to 0.0 instead of 0 may help. I believe the stopscript command may be used in other software but not in AutoCAD? I'm a lisper who hasn't written any scripts in a long time. 1 Quote
steven-g Posted May 22, 2021 Posted May 22, 2021 Run your script and then press F2 for the command history, you should be able to see where the problem is, if there is a problem you would probably see something like 'invalid command' or some other error message before the script tries to go onto the next command or input from your script. (a script won't stop at an error it just tries to blindly continue on so you need to look for the first error) then it is just a question of fix the error and try again. If you are not sure then run the script then copy your coomand history and post it here. 1 Quote
webster Posted May 23, 2021 Author Posted May 23, 2021 12 hours ago, steven-g said: Run your script and then press F2 for the command history, you should be able to see where the problem is, if there is a problem you would probably see something like 'invalid command' or some other error message before the script tries to go onto the next command or input from your script. (a script won't stop at an error it just tries to blindly continue on so you need to look for the first error) then it is just a question of fix the error and try again. If you are not sure then run the script then copy your coomand history and post it here. Hi, thanks for that. This is exactly what I tried to do, but it isn't making much sense to me. I have copied what I can see from F2. What is bizzare, is that typing it out I can't replicate it? Quote : TILEMODE New current value for TILEMODE [1 for ON/0 for OFf] <1 for ON>:1 : -LAYER Layer [? to list/New layer/Make new current layer/Set layer as current/Color/Linetype/LineWeight/TRansparency/MATerial/Plot/stAte/turn layer ON/turn layer OFf/Freeze/Thaw/LOck/Unlock]:U Layer(s) to Unlock: * Layer [? to list/New layer/Make new current layer/Set layer as current/Color/Linetype/LineWeight/TRansparency/MATerial/Plot/stAte/turn layer ON/turn layer OFf/Freeze/Thaw/LOck/Unlock]: : SELECT Select entities to include in set [selection options (?)]: ALL Entities in set: 18 Select entities to include in set [selection options (?)]: : CHANGE Select entities to change [selection options (?)]: P Entities in set: 18 Select entities to change [selection options (?)]: LT A point is needed. Please try again. Entities in set: 18 Select entities to change [selection options (?)]: BYLAYER A point is needed. Please try again. Entities in set: 18 Select entities to change [selection options (?)]: LW A point is needed. Please try again. Entities in set: 18 Select entities to change [selection options (?)]: BYLAYER A point is needed. Please try again. Entities in set: 18 Select entities to change [selection options (?)]: Change point [special Entities/Properties...]:-LAYER Unable to recognize entry. Please try again. Change point [special Entities/Properties...]:LW Unable to recognize entry. Please try again. Change point [special Entities/Properties...]:0 Number of objects filtered out: 18 No entities selected. Entities selected were not changeable. Quote Quote
webster Posted May 23, 2021 Author Posted May 23, 2021 17 hours ago, tombu said: At a glance for changing properties both Ltype & Ltscale start with LT. Changing LT to Ltype may help. As Lineweights are real numbers setting them to 0.0 instead of 0 may help. I believe the stopscript command may be used in other software but not in AutoCAD? I'm a lisper who hasn't written any scripts in a long time. Hi There, I am seeing that LT is for "LineType" and S is for "Linetype Scale" Quote
steven-g Posted May 23, 2021 Posted May 23, 2021 1 hour ago, webster said: : TILEMODE New current value for TILEMODE [1 for ON/0 for OFf] <1 for ON>:1 : -LAYER Layer [? to list/New layer/Make new current layer/Set layer as current/Color/Linetype/LineWeight/TRansparency/MATerial/Plot/stAte/turn layer ON/turn layer OFf/Freeze/Thaw/LOck/Unlock]:U Layer(s) to Unlock: * Layer [? to list/New layer/Make new current layer/Set layer as current/Color/Linetype/LineWeight/TRansparency/MATerial/Plot/stAte/turn layer ON/turn layer OFf/Freeze/Thaw/LOck/Unlock]: : SELECT Select entities to include in set [selection options (?)]: ALL Entities in set: 18 Select entities to include in set [selection options (?)]: : CHANGE Select entities to change [selection options (?)]: P <<<<<< Autocad is expecting you to make a selection here and reads 'P' as meaning (P)reviuos Entities in set: 18 <<<<<< Autocad tells you it has detected 18 entities as being selected and now expects an ENTER or SPACE to finish the selection Select entities to change [selection options (?)]: LT <<<<<< So when it reads 'LT' this is seen as an ERROR reported in the next line A point is needed. Please try again. <<<<<<<<<THIS IS THE ERROR MESSAGE anything after this is your script is broken The error message you recieve here shows up where the problem is. In fact the error is with the 'CHANGE' command, but this is the difficult bit you need to decipher what is happening You have just used the 'SELECT' command to select all objects but running the 'CHANGE' command is then prompting you too select objects (scripts often don't work with a preselection and expect the selection to occur after the command is issued). So your script issues the 'CHANGE' command and Autocad prompts for a 'selection' coincidently in this case your next line in the script is 'P' which you are using for the 'PROPERTIES' option of the CHANGE command, but Autocad is expecting a selection so it is seeing 'P' as standing for PREVIOUS selection. To fix this you need to rewrite the script order to this. TILEMODE 1 -LAYER U * CHANGE ALL P LT BYLAYER LW BYLAYER -LAYER LW 0 * LW 0.2 IRR_ELECTRICAL _stopscript You will still see an error at the end though. As pointed out by @tombu 'stopscript' is not an Autocad command so this results in an error message Command: _stopscript Unknown command "STOPSCRIPT". Press F1 for help. But this is at the end of your script so doesn't break your script it just gives the error message shown (in Autocad scripts automaticaaly stop at the end) 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.