Jump to content
Sign in to follow this  
GioPet

Tools to set Class/Layer Visibility of a selected object

Recommended Posts

Here are the scripts for some simple tools to turn On/off a layer/class visibility by clicking on an object, or to set them as Active layer/class, or to turn off all the others.

I was scripting these procedures to use them inside the script for one plugin, but I thought they could be useful also individual procedures.

See the attached Plug-ins, the scripts on the following links:

Hide the Layer of s Selected Object:

http://pastebin.com/spkutw5t

Hide the Class of a Selected Object:

http://pastebin.com/PG3myeWF

Set as Active the Layer of a Selected Object:

http://pastebin.com/bBKiN6Z8

Set as Active the Class of a Selected Object:

http://pastebin.com/9AnTzBsa

Gio

Share this post


Link to post

Hello Gio, great resource, i was searching for this and you decided to post it. Thx very much :)

i am an newbie at vectorscript but i am trying to change your script so that when the class is allready "isolated" , after you call the command it will un-isolate everything.

But its not working the way i script it. can you help me ?

PROCEDURE SetObjectClass;

VAR

h : HANDLE;

Active_class : STRING;

x, y :REAL;

BEGIN

IF SetClassOptions<>1 THEN BEGIN

GetPt(x, y);

h := PickObject(x, y);

IF h<>NIL THEN BEGIN

Active_class:= GetClass(h);

NameClass(Active_Class);

SetClassOptions(1);

SetTool(-240);

END;

ELSE BEGIN

SetClassOptions(5);

SetTool(-240)

END;

END;

END;

Run(SetObjectClass);

Edited by orlando Teixeira

Share this post


Link to post

Hi Orlando,

In an IF THEN ELSE statement, you cannot have a semi-colon between END and ELSE. A semi-colon there tells the compiler that your IF statement ends after the THEN clause. The ELSE should be kicking an error. Use a semi-colon only after the last END.

Use this format:

IF ( ) THEN begin

end

ELSE begin

end;

I haven't run your script, so I cannot comment further.

Happy scripting,

Raymond

Share this post


Link to post

Hi Orlando.

Great Idea!

THis Works out:

Introduce the var Class_Options to use the GetClassOptions command.

PROCEDURE SetObjectClass;

VAR

h : HANDLE;

Active_class :STRING;

x, y :REAL;

Class_Options :Integer;

BEGIN

GetPt(x, y);

h := PickObject(x, y);

IF h<>NIL THEN BEGIN

Class_Options:=GetClassOptions;

IF Class_Options<>1 Then Begin

Active_class:= GetClass(h);

NameClass(Active_Class);

SetClassOptions(1);

SetTool(-240);

End else

SetClassOptions(5);

SetTool(-240);

End;

END;

Run(SetObjectClass);

Edited by Gio Pet

Share this post


Link to post

Hello Mulling and Gio , cant it be automatic ?

like this:

1)see if classoptions is 1

2)and if it is then changes it to 5 and ignores the rest of the script...

this is what i was trying to do but failed at if then else statement lol

Edited by orlando Teixeira

Share this post


Link to post

..that's what the last script i posted does..

IF Class_Options <>1

..

End else

SetClassOptions(5);

SetTool(-240);

End;

Edited by Gio Pet

Share this post


Link to post

yes i saw it but what script allways asks to select an object.

cant he first GetClassOptions

and if the result is 1 then he changes to 5 ?

thx

Edited by orlando Teixeira

Share this post


Link to post

I See!! you want this to work without object selection!

then you only need this..

PROCEDURE SetObjectClass;

VAR

Class_Options :Integer;

BEGIN

Class_Options:=GetClassOptions;

IF Class_Options<>1 Then Begin

SetClassOptions(1);

SetTool(-240);

End else

SetClassOptions(5);

SetTool(-240);

End;

END;

Run(SetObjectClass);

Share this post


Link to post

more like: but thats it

thz very very much :)))

PROCEDURE SetObjectClass;

VAR

Class_Options :Integer;

h : HANDLE;

x, y :REAL;

BEGIN

Class_Options:=GetClassOptions;

IF Class_Options<>1 Then Begin

GetPt(x, y);

h := PickObject(x, y);

Active_class:= GetClass(h);

NameClass(Active_Class);

SetClassOptions(1);

SetTool(-240);

End else

SetClassOptions(5);

SetTool(-240);

End;

END;

Run(SetObjectClass);

Edited by orlando Teixeira

Share this post


Link to post

THis is more like it:

PROCEDURE SetObjectClass;

VAR

Class_Options :Integer;

h :HANDLE;

x, y :REAL;

Active_class :String;

BEGIN

Class_Options:=GetClassOptions;

IF Class_Options<>1 Then Begin

GetPt(x, y);

h := PickObject(x, y);

Active_class:= GetClass(h);

NameClass(Active_Class);

SetClassOptions(1);

SetTool(-240);

End else

SetClassOptions(5);

SetTool(-240);

END;

Run(SetObjectClass);

Share this post


Link to post

I wonder if this would be more useful when it was switching the Visibility of the Classes from Visible to invisible...

Share this post


Link to post

thx , i will try it whenever i arrive at work.

well now thats what i was looking for:

sometimes it is handy to turn off all the classes except one. its usefull even when you are trying to copy something, this way i do not have to use selection by class anymore :))))

perhaps one of this days i will have the time to study vectorscrit he!he!he!

indeed its allways very usefull

Thx againg for the help

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...