Jump to content

Automatic Class Assignment for a bunch of objects

Recommended Posts

Hello helpful people in the know. 


I have never used VW scripting to date - however thought it might be useful for the following : 

- I have a file with about 150 or so objects. 

- They are all named

- They all have the same record format attached 

I would like to create an animation where they all come on one by one (basically like an installation instruction). So I thought the easiest to do that would be if I had each of these objects sitting in its own class, and then use animation works to create what I'm after. 

From what I've read so far it sounds like it should be fairly straightforward to create a little script that: 

- goes through all the objects , one by one, and

- reads either (a) a field from the record format (that contains an ID number) , or (b) reads the objects name from the OIP data set , as a selection criteria, and then 

- automatically creates a new class with (a) or (b) as class name, and then

- puts the object into that new class. 

- then moves on to the next object. 

Is that easy to do ? Can anyone point me in the right direction or help me with this? 


Also, can you point me to a resource pointing out the differences / thought approaches between Vs , python etc ? (I used to some pascal programming about 30 years ago so thought the vector script sounds like it may be most down my alley 🙂 ? ) Would love to play wiht all this a bit more once I get some starting points going... 

Thanks !


Share this post

Link to post

Yes, everything you want to do can be readily easily done in either VectorScript of PythonScript. If you remember any of your Pascal and don't mind the Begins/Ends it requires, then Vectorscript is probably your best bet. If Begins/Ends drove you crazy, then you might want to consider Pythonscript instead, but then you get to deal with it being "white space" delimited and an extra space will put something at a different indent (and therefore subroutine group) level.


Here is some pseudocode.


Procedure Create-Set-Class;

Procedure Make_It_So(H1:Handle);
{procedure to be called by ForEachObject}
	NameClass(S1); {Note Class names can only be 20 characters long}

	ForEachObject(Make_It_So,((R IN ['Your-Record-Name'])));



The above was typed into the forum, so please excuse any typos or other errors. You may want to change the criteria in the ForEachObject to limit it to just objects that are on a specific layer or have specific field values. You will definitely need to change the record and field names to match what you are using.


Good luck and let us know if you need more help.

  • Like 1

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.

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