Jump to content
Boh

Custom “Assign to [class name]” script.

Recommended Posts

I can’t write script but I do use the inbuilt custom selection and visibility tools to create my own custom scripts a lot. 

 

I can’t figure out how, using the Vw menu commands, to create a simple script that simply assigns a currently selected object or objects to a class.

 

Can anyone point me in the right direction?

 

ive started using object styles a lot however for plug in style symbols there is no option to assign a class on insertion. They simply go to the active class.

 

We always leave “none” as our active class so I’m repeatedly having to reassign the class of some plug-in style symbols as soon as I insert them. 

 

It would be nice to have a set of little scripts tucked in a palette off to the side which when run will assign the selected object(s) to a predetermined class. 

 

Can anyone help?

 

Its probably one line of script?...

Share this post


Link to post

You could try this:

 

SetClassN(FSActLayer, 'my class name', True);

 

I likely won't work in groups or symbols though. If used on a group (not in a group), the last argument (true or false) will determine if all the objects in the group also get the class assignment.

Share this post


Link to post

Hi guys, lately i' ve been searching for exactly same script, but I cant make it work

I paste line

SetClassN(FSActLayer, 'my class name', True);

in script window (python), change 'my class name' to my custom one...and save it to resource browser. However when I have selected some object and initiate script i get error messages

 

Am I missing something? In terms of scripting I am beginner.

Thanks you in advance for directing me right way.

Pavol

 

 

 

Snímka obrazovky 2019-09-19 o 9.33.38.png

Edited by drelARCH

Share this post


Link to post

Set the above script to be Vectorscript, not Python. If you can't do that, in python it will be something like this:

 

vs.SetClassN(vs.FSActLayer(), 'my class name', True)

 

but I know nothing about python.

Share this post


Link to post

It’s working perfect for me.

 

If Julian’s suggestions don’t work there is  a chance your browser may be introducing erroneous characters when you copy and paste. This has happened to me before but when I did exactly the same copy and paste but with a different browser (firefox in that case) it worked. 

 

Try a different browser or simply type the script yourself rather than copy and paste.

Share this post


Link to post

Thanks @Boh for quick response. 

It's working now for me too. I had to change scripting language to Vectorscript.

 

Pavol

  • Like 1

Share this post


Link to post
On 9/18/2019 at 9:46 AM, Julian Carr said:

I likely won't work in groups or symbols though. If used on a group (not in a group), the last argument (true or false) will determine if all the objects in the group also get the class assignment.

This little script is great@Julian Carr.

 

Unfortunately it doesn't seem to work in viewport annotation space. Is it easy to fix this?

Share this post


Link to post

I can't seem to get this to work. 

This is what I have, and I get error messages.  As I understand it, I have the object selected that I want to change all of its parts and pieces to the current active class, run the command, and it will do this?  

image.thumb.png.293a06a72e3c8b103fb9b175972161cc.png

Share this post


Link to post
Posted (edited)
4 hours ago, grant_PD said:

As I understand it, I have the object selected that I want to change all of its parts and pieces to the current active class

No, that script changes the selected object to a particular class - In that case a class called 'my class name'.

 

I don't know of a script that will change objects to the current active class though I imagine that it wouldn't be hard to write one - unfortunately I don't know how to script.

 

I always have 'none' as the active class. If you do that too then you could change 'my class name' in the script to 'none' and the selected objects will then be placed in the none class. It doesn't work within groups or annotations.

Edited by Boh

Share this post


Link to post

Thanks.  I often get confused whether to class everything inside a group/symbol in its proper class, or just the symbol/group itself.  I find that classing everything is preferable because it makes the class visibility option work better, but it is a pain to do consistently.

Share this post


Link to post

I always keep the none class as the active class so that I don’t inadvertently create objects on random classes they shouldn’t be on. The none class is always set to visible so I always create the objects on the none class then class them as required (hence why I wanted this “assign class” script).

 

With this way of working groups will always be on the none class with the objects inside classed. That way the grouped objects vp visibilities is only dependant on the class they are on and not also the class the group is on.

 

For most “standard” symbols I do it the other way around where the symbol instance is on a class and the objects inside the symbol are on the none class. I do it this way so:

1. I can set up the symbol to insert straight into a specified class (in edit symbol options).

2. The symbol can be used in different files without bringing in additional classes. 

3. The symbol’s visibility still only relies on a single class.

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.


 

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