Hi Guys,
I'm trying to create an option in my menu to move everything on certain layers to the back (draworder > back).
So far I have in my mnu file which will become my cuix file:
ID_Draw_Order [Draw Order]
-layer _off * _yes _on Windows,Doors; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _off * _yes _on "Sanitary Fittings",Stairs; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _off * _yes _on "External Wall Finishes","Roof Finishes"; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _off * _yes _on Hatching; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
[--]
I can get the window and doors to the back, so the issue must be the names of the layers which have spaces in them. I added quotation marks in the hope that the layer name would be recognised, but no luck.
I then tried to rename the layers:
ID_Draw_Order [Draw Order]
-layer _rename "sanitary fittings"; sanitaryfittings;;
-layer _rename "external wall finishes"; externalwallfinishes;;
-layer _rename "roof finishes", rooffinishes;;
-layer _off * _yes _on Windows,Doors; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _off * _yes _on SanitaryFittings,Stairs; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _off * _yes _on ExternalWallFinishes,RoofFinishes; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _off * _yes _on Hatching; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _rename sanitaryfittings; "Sanitary Fittings";;
-layer _rename externalwallfinishes; "External Wall Finishes";;
-layer _rename rooffinishes, "Roof Finishes";;
[--]
but still no luck.
Any ideas?
TIA
Solved! Go to Solution.
Scripts in Autocad can be fussy when it comes to spaces but without seeing the results from your command line when you run one of these scripts it is hard to guess at what the real problem is. Can you run one of these scripts and then make a copy of the command history and paste it into a plain text document (notepad) and attach that to your next post. Someone should be able to work out what is going wrong from that.
Thanks for the response, Steven.
Here's the output:
Command: -layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _off
Enter name list of layer(s) to turn off or <select objects>: * Really want layer "0" (the CURRENT layer) off? <N> _yes Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _on
Enter name list of layer(s) to turn on: Windows,Doors
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:
Command: _draworder
Select objects: _window
Specify first corner: 0,0,0 Specify opposite corner: 1000000,1000000,0
2 foundSelect objects:
Enter object ordering option [Above objects/Under objects/Front/Back] <Back>: _back
Command: -layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _on
Enter name list of layer(s) to turn on: *
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:Command: -LAYER
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: -layer
Invalid option keyword.
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: *Cancel
You can see it works for windows and doors i.e., sends everything on their layers to the back, but it stalls when I get to sanitary fittings. I'm pretty sure this is due to the space between "sanitary" and "fittings" i.e. AutoCAD is trying to find a layer called "sanitary" not "sanitary fittings".
In the second part of my original post, I tried to rename 3 layers, "sanitary fittings", "external wall finishes" and "roof finishes" and, after their layers had been sent to the back, rename them back to their original layers. The result was the same i.e. it stalls at the space between "sanitary" and "fittings".
If I can figure out how to force AutoCAD to accept a layer with a space separating two words it would be easy.
BTW I'm not using a .scr for this, I'm using a .cuix on my menu bar.
Thanks
Colin
@Anonymous wrote:Thanks for the response, Steven.
Here's the output:
Command: -layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _off
Enter name list of layer(s) to turn off or <select objects>: * Really want layer "0" (the CURRENT layer) off? <N> _yes Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _on
Enter name list of layer(s) to turn on: Windows,Doors
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:
Command: _draworder
Select objects: _window
Specify first corner: 0,0,0 Specify opposite corner: 1000000,1000000,0
2 foundSelect objects:
Enter object ordering option [Above objects/Under objects/Front/Back] <Back>: _back
Command: -layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: _on
Enter name list of layer(s) to turn on: *
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:Command: -LAYER
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: -layer
Invalid option keyword.
This is where your macro is failing, the problem is an extra space or semi-colon in your code that is telling AutoCAD to rerun the last command used.
If you look at the command history where the command -LAYER is shown in blue, this is actually in response to an extra space or semi-colon which restarts the last command used. Autocad issues the prompt asking for an option and it is then that your macro sends -layer (green) to the command line, as you see Autocad gives you the error Invalid option keyword.
A macro won't stop after it encounters an error it just tries to continue with the sequence of commands it receives but it has already failed.
I'm not familiar with the method you are using to create the macros, do you actually use multiple lines? but at a guess the answer is yes, in which case that is the source of your problem you end the first line with a double semi-colon which is correct to end the '-layer' command, but there is then a line-feed and AutoCAD sees this as yet another <enter> I would remove one of the semi-colons from the end of each line of code and then pay attention to what the command history tells you then.
In .mnu files you need to add a + character at the end of each line (except the last one) of the macro to tell the menu compiler that the macro continues on the next line.
This is why only the first line of your macro is being compiled and executed.
Menu file formatting is no longer described in the help files. I recommend that you start using the CUI command for this type of task.
As I said I am not familiar with the method used, but the results shown in the OP's command history, do point to the second line of code being implemented and not that the code just stops after the first line, but the line-feed going to the second line of code being interpreted as an extra <enter> key.
Thanks, Paul.
Just to let you know, I'd posted without everything being in a line to make things easier to read.
🙂
Thanks, Steven,
I have the solution and you are more or less correct.
There were a few rogue spaces in my code, so the final solution which works is as follows (on separate lines for ease of reading 🙂😞
-layer _rename "sanitary fittings";sanitaryfittings;;
-layer _rename "external wall finishes";externalwallfinishes;;
-layer _rename "roof finishes";rooffinishes;;
-layer _off * _yes _on Windows,Doors; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _off * _yes _on SanitaryFittings,Stairs; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _off * _yes _on ExternalWallFinishes,RoofFinishes; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _off * _yes _on Hatching; _draworder _window 0,0,0 1000000,1000000,0; _back -layer _on *;;
-layer _rename sanitaryfittings;"Sanitary Fittings";;
-layer _rename externalwallfinishes;"External Wall Finishes";;
-layer _rename rooffinishes;"Roof Finishes";;
Thanks to everybody that helped me resolve this
Because a macro will keep on running and not stop at an error it can be hard to spot, where the actual problem occurs, they don't normally completely break down. Very often you get an error like 'Invalid option keyword' but after the next one or two lines, Autocad starts to perform in the correct sequence again so things look reasonable at the end of the command history. Which is why debugging is one of the hardest parts of scripts and macro's.
Good to hear it is working now.
Can't find what you're looking for? Ask the community or share your knowledge.