MaxStudio Posted February 20, 2009 Share Posted February 20, 2009 Anyone know of a way to set all layers to "hidden"? I haven't been able to find anything. I think that if I can't get them to hide all at once... maybe there is a way to cycle through the layers one at a time, regardless of the layer name. I know in Vectorworks you can cylce through the layers using "Shift" and the Arrow keys. That being said I feel there should be some way to have a script cycle through the layers. If I can cycle through the layers I can set the visibility of each one to "hidden" individually and loop the script until all layers are hidden. See the problem is... i have developed a script which asks the user to input a string variable. Lets say the string variable is "1st Floor". The script then creates a list of design layers using the string variable: 1st Floor Openings 1st Floor Walls 1st Floor Shade I give each layer a handle and then assign the visibility of each. Then I create 3 saved views: 1st Floor Construction Plan 1st Floor Power/Telephone Plan 1st Floor Reflected Ceiling Plan then the script ends. Up until that point the script works fine. The problem is when I run the script a second time. If i run the script a second time the saved views will not be created correctly. Lets say I run the script again this time the string variable is "2nd Floor". The script then creates a list of design layers using the string variable: 2nd Floor Openings 2nd Floor Walls 2nd Floor Shade I give each layer a handle and then assign the visibility of each. Then I create 3 saved views: 2nd Floor Construction Plan 2nd Floor Power/Telephone Plan 2nd Floor Reflected Ceiling Plan These Saved Views are created incorrectly because I have no way of changing the visibility of the other "1st Floor" layers in the file. I don't want to have to rely on the name of the layer to hide it. The reason I don't want to rely on the name is because I'm not sure the names will always be the same. This is why I am looking for a way to hide all layers in the file. Quote Link to comment
Pat Stanford Posted February 20, 2009 Share Posted February 20, 2009 I did not run this so treat it as pseudocode, but I think it is right. Procedure HideAllLayer; var H1: Handle; Begin H1:=FLayer; While H1<>Nil do begin SetObjectVariableInt(H1,153,-1); {-1 invisible; 0 visible, 2 greyed} H1:=NextLayer(H1); end; End; Run(HideAllLayer); Quote Link to comment
MaxStudio Posted February 23, 2009 Author Share Posted February 23, 2009 Hey Pat, The script compiled successfully, but it did not hide the layers. I'm going to use what you provided me as a starting point. silly question. What does the "<>" operator stand for? I think this is a great start. thanks again! Quote Link to comment
MaxStudio Posted February 23, 2009 Author Share Posted February 23, 2009 okay was able to find it online. "Not Equal" Quote Link to comment
MaxStudio Posted February 23, 2009 Author Share Posted February 23, 2009 ok forget what I said about it not working... your script DOES work. I was watching the Navigation window while I ran the script. The visibilities of the layers did not change in the Navigation Window. Meaning the little eye icon did not become an 'x'. Then I decided to try it with items drawn on each layer. Then I ran the script... it worked. For some reason, even though the layers become hidden, the icon in the Navigation window does not change until I change to a different project window or a different program and then return to vectorworks. Just a little glitch. I think this will work tho! THANKS A LOT!! Quote Link to comment
mike m oz Posted February 23, 2009 Share Posted February 23, 2009 MaxStudio there is no need to run a script to 'Hide' all of the Layers. On a Mac if you Option Click in one of the Visibility columns on the Navigation Pallette it will change all of the Layers to that visibility (Alt click on a PC). So therefore if you do that in the Invisible column on the Navigation palette it will 'Hide' all of your Layers. Quote Link to comment
MaxStudio Posted February 23, 2009 Author Share Posted February 23, 2009 Thanks mike, that is definitely good advice, but this is part of a larger script that I am working on used to create a list of user defined layers which in turn are used to create a list of saved views. I could have the user manually hide the layers (as you have suggested) and then run the script,but that is just another step that I believe should be automated. basically a user will be open up the template, click on the scipt, type in a string "1st Floor", a list of layers will be created. Next, a set of Saved Views will be created using the recently developed list of layers. I can not rely on the user to always input the exact same string. I also can't rely on the user to only use the layers which the script develops.. there for I needed a way to hide all the layers so the script could properly create the saved views. Pat has helped me solve this problem. Quote Link to comment
Pat Stanford Posted February 24, 2009 Share Posted February 24, 2009 If you add one more line just at the end of the script, it will cause the Nav Palette to update. Layer(GetLName(ActLayer)); Quote Link to comment
MaxStudio Posted February 24, 2009 Author Share Posted February 24, 2009 thanks Pat! Quote Link to comment
MaxStudio Posted February 27, 2009 Author Share Posted February 27, 2009 Ok new problem... When a user runs the script a string dialog pops up and asks for the user to put in a string variable. I can then push 'OK' or I can push 'Cancel' When I push 'OK' the layers and saved views are created as expected. When I push 'Cancel' it still creates the layers and saved views. How do i get Cancel to end the script correctly without creating the layers and the views? Quote Link to comment
panta rhei Posted February 27, 2009 Share Posted February 27, 2009 (dialog) IF NOT DIDCANCEL THEN BEGIN main_program END; or, better still (dialog) IF NOT DIDCANCEL THEN main_program_as_a_procedure; END; Quote Link to comment
Miguel Barrera Posted February 27, 2009 Share Posted February 27, 2009 If you want the layers and associated views to be consistent, I would suggest that you also substitute the text entry with a popup that gives the user only available choices. Otherwise you are going to end up with files with different names (i.e. 1st Floor, floor 1, first flr, etc.) for the same type of layer. Quote Link to comment
MaxStudio Posted February 27, 2009 Author Share Posted February 27, 2009 Miguel, thats a good point. At the moment the user can type in whatever they want "basement", "first floor", "coca-cola", and it creates the list of layers. I guess I could use a pull down menu or check boxes to list a predetermined list of names. That way it stays consistent throughout different projects. panta, I'm going to have to look into that a little further. I'm a little confused on what your code is saying. Thanks Quote Link to comment
panta rhei Posted February 27, 2009 Share Posted February 27, 2009 Why do I think that setting up a template would do a lot of this work? Layers, classes, visibilities, class attributes, viewports, symbol libraries etc. all consistent through different projects. Quote Link to comment
MaxStudio Posted February 27, 2009 Author Share Posted February 27, 2009 I could set up a template... that is exactly what I am doing, but I want the user to have the option to easily choose how many floors they want. I could make a template with layers and views for the basement first floor and second floor, but what if there is a third floor? or what if there is no work on the second or basement? That would leave the user deleting or creating extra layers. Then if they created new layers, for say a "third floor", then they would have to go and setup all the saved views for that floor. Or they could just work with all the extra layers and just not think about it... but I find having extra layers and saved views in a project as sloppy. The idea is to make a template and only create the layers you need for that specific project. It's much like standard viewports, but our office works in a very specific way so I have to adapt. Quote Link to comment
panta rhei Posted February 27, 2009 Share Posted February 27, 2009 Fair enough. The Model Set-up command & additional commands don't work for you? (No, they definitely don't work for me, either. One of the truly amusing details is that according to the Wizard of Tex, a building shall have no more than two basement levels.) Quote Link to comment
MaxStudio Posted February 27, 2009 Author Share Posted February 27, 2009 ha, exactly. Our firm doesn't use the wall tool... yet. Which means we don't work in 3d either. Everything is still done in 2d only because it is more economical, at the moment. Quote Link to comment
panta rhei Posted February 28, 2009 Share Posted February 28, 2009 (edited) Not using the wall tool does not sound economical at all. It can be used in 2D-only fashion, too. I find 3D much more economical than 2D, but then again, I consider the course of the entire project, not just the task at hand. Edited February 28, 2009 by panta rhei Quote Link to comment
MaxStudio Posted March 2, 2009 Author Share Posted March 2, 2009 I'm not disagreeing with you but its hard to convince busy people. IF NOT DIDCANCEL THEN main_program_as_a_procedure; END; what do you mean by "main_program_as_a_procedure;"? that is a little confusing to me. can i not just add the following code? IF DIDCANCEL THEN END; Thanks Quote Link to comment
MaxStudio Posted March 2, 2009 Author Share Posted March 2, 2009 OK, i played around with it for awhile and figured it out. I thought the code went at the end of the script. Apparently the code goes at the beginning of the script. I thought the script stated "If cancel is pushed then end." when in reality it states "If cancel is not pushed then begin." Quote Link to comment
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.