Jump to content
Developer Wiki and Function Reference Links ×

Klasses skript If-else


Recommended Posts


Hello everyone,

I would like to create a script with which I can make class groups visible or invisible.

I have already found the following function references.

HideClass ('▲ 00 standard - hairline 0.18');

and ShowClass ('▲ 00 standard - hairline 0.18');

My question is. How can I design the script in such a way that I can switch the class visible or invisible with a script, depending on the class visibility at the moment. I was thinking of an if / else query.




Link to comment

This is an excellent example of something a tiny script is good at doing.  This script is simple enough that it can be done without variables, and without all the formalities of Procedure and Run statements.


Obviously you've found the developer page online or the local copy w/ your VW installation.  You need one other function:  GetCVis(className);  


It will return   0 if the class is visible, -1 if the class is hidden and 2 if the class is gray.


Instead of an IF/THEN/ELSE it might be faster to use a CASE. (check out the VS Language Guide:  https://developer.vectorworks.net/images/7/72/VectorScriptGuide.pdf)


CASE GetCVis('Test1') OF
	0 	: HideClass('Test1');
	-1	: ShowClass('Test1');


CASE GetCVis('Test2') OF
	0 	: HideClass('Test2');
	-1	: ShowClass('Test2');



Of course it would be great if the script also checked to see if the class even exists in the drawing.  But this works 🙂 




  • Like 1
Link to comment

I don 't think you can.  Sub classes are just classes with a dash in the name.  So you would need to list every class.  You could do it as a loop to make managing the list easier.  If you're ready for that step post back 🙂.  We'll walk you through it.


PS.  This occurred to me as another option.  It does the same thing as above, but adds a beep if the class is grey.


CASE GetCVis('Test1') OF
	0 	: HideClass('Test1');
	-1	: ShowClass('Test1');

	2	: Sysbeep;



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.

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