Jump to content
Developer Wiki and Function Reference Links Read more... ×
ChadL

Create Classes

Recommended Posts

I'm not a scripter, and in my limited research I was not able to successfully do this. I want to create a tool (marionette node, vectorscript, anything) that when I run it it will create a series of classes in the active document. I know what I want all those classes to be, just don't know how to make this script.

 

Thanks,

 

Share this post


Link to post

You don't need a script, you just need a resource.

 

Create a file with all of the classes you want. 

Create one object in each class. This could be something big or even just a locus. It actually does not matter if you have more than one object in each class, just that there is at least one in each class.

Select all of the object and Create Symbol. Name it something like "Create Class Set 1"

Store the symbol in your symbol library.

 

When you want the classes imported into the file, just go to the library and import the symbol. Any classes that do not already exist in the file will be created.

 

Of course if you want to learn scripting this could be scripted, but if you just want the end result, this will be much faster than debugging a script. If you do want to learn scripting just say so and we will give you a starting point.

Share this post


Link to post

HI Pat, thanks for the reply. I have done the resource before, I was using this as a project to start learning scripting.

 

Thanks, 

 

Share this post


Link to post

OK.

 

Here is the outline that you need to do this in Vectorscript. Just add NameClass lines as necessary. Ask again if you need more help.

 

Procedure Create_My_Classes;

Begin
	NameClass('MyFirstClass');
End;

Run(Create_My_Classes);

 

Share this post


Link to post

And here is a way to do it in Marionette.  By wiring each String node to the Dummy End node, you make the whole thing into a single Network that can be run at once. You could Wrap the entire network into a single Node and then save that as a symbol (with Convert to Group checked so it comes back into the drawing as a node that can be run). The class names are typed into the Resouce Browsers for each String node.

 

Share this post


Link to post

@ChadL

It looks like @Pat Stanford's post doesn't include the Marionette file, so I'm attaching my example here. For each class you want to add to your document, you would define the name in the OIP when a String node is selected.

There are many other ways to define the list of names for your classes, but this is the most native. It's also possible to read them from a text file, or you could prompt the user for the names.

 

In 2018 Marionette can create Menu Commands, which I think would also be useful; say you knew you would be using these classes in various projects but didn't want to create a template file. You could store this Marionette Network as a Marionette Menu Command and access it in whichever document you want to add the classes to.

 

Please let me know if you have any questions.

Marionette_CreateClasses.vwx

Share this post


Link to post

There was a screen shot attached when I posted it :-( Here it is now.

 

@Marissa Farrell solution is much more elegant, but I think both ways show useful information about using Marionette.

 

Screen Shot 2017-10-11 at 8.13.30 AM.png

Share this post


Link to post

Thanks, this is super helpful. I played around with this for about 30 minutes yesterday, making me excited again to try to learn marionette.

 

Share this post


Link to post

Okay, I've been playing with this and I like it. However, now that I got a taste, I want to go deeper. I have been struggling to create a class and assign it line colors and fill colors without having an object to pull that info from. I think the problem is in how I am compiling my RGB values. Right now I have 3 int nodes with my RGB value, then I've tried using a series node, or an ordered list. Nothing I've done so far sets a color.

Share this post


Link to post

I've tried that too. I have 3 int nodes feeding a 3d point node, feeding a set pen color node. AAhhhhh, that is probably the problem, i used 255

 

Edited by ChadL

Share this post


Link to post

Here is what I currently have. the only Int with a value higher than 0 is the bottom one, which is set to 65535

 

 

Screenshot 2017-10-16 11.08.06.png

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

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.

×