Jump to content
Developer Wiki and Function Reference Links ×

Script to hide all layers?


MaxStudio

Recommended Posts

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.

Link to comment

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

Link to comment

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.

Link to comment

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.

Link to comment

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?

Link to comment

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

Link to comment

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.

Link to comment

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

Link to comment

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

Link to comment

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