Jump to content
Developer Wiki and Function Reference Links ×

Pop up list question


Recommended Posts

I'm new to Marionette and after going through all of the tutorials, I thought that I would start off by trying to customize Alan Woodwell's gutter script. 


That network starts with a 'String Input' which is then applied to a 'Get Symbol' using the "symname" node connection.

My goal is to instead use a pop-up menu that includes all of my pre-selected symbols for ease of use.


After reviewing the pop-up threads etc... I've figured out how to customize the number and name of options, but it appears that the output from this node is an integer rather than a string.  As such, I can't just connect the 'Popup' node to the 'Get Symbol' node.  How should I go about doing this?


Here's a copy of the script (so far):



class Params(metaclass = Marionette.OrderedClass):
    this = Marionette.Node( 'Popup' )    
    this.SetDescription('This node demonstrates the use of a Popup OIP control. The values returned by this node will be integers based on your selection starting with 0 for the first option and increasing by 1 for consecutive options.')
    input = Marionette.OIPControl( 'Popup', Marionette.WidgetType.Popup, 0, ['Half-Round 4', 'Half-Round 5', 'K Style 4', 'K Style 5'])
    input.SetDescription('an OIP control representing the options designated within the script editor')
    output = Marionette.PortOut('int')
    output.SetDescription('an integer corresponding with the option selected in the OIP. Returned values range from 0 to one less than the number of options.')
def RunNode(self):    
    input = self.Params.input.value
    if input == 0:
        self.Params.output.value = HR4
    if input == 1:
        self.Params.output.value = HR5
    if input == 2:
        self.Params.output.value = K4
    if input == 3:
        self.Params.output.value = K5


Thanks for your help.

Edited by Taproot
Link to comment
  • Vectorworks, Inc Employee

You are on the right track and very close.


If you want the output value to be a symbol name, it needs to be a string. In order to create a string in your script, you must use quotation marks. Assuming that HR4 is the symbol name, you simply have to put quotation marks around it to make it a string.


   if input == 0:
        self.Params.output.value = 'HR4'
    if input == 1:
        self.Params.output.value = 'HR5'
    if input == 2:
        self.Params.output.value = 'K4'
    if input == 3:
        self.Params.output.value = 'K5'

Link to comment

Wow - that is very helpful and it worked!  I used single quotes to bracket the output, but does it matter if I use single or double quotes ... or does it achieve the same result?  Marissa and Sarah each recommended one or the other.


And Antonio, I didn't even know that was possible, so I'll use that somewhere further in my development.


There is definitely a learning curve!  My next endeavor is to assign a path for the profile.  Currently, it is set up to a named object.  My plan was to just draw a polygon and then have it selected when I ran the script.  My first attempt crashed VW.  So, I learned to use the debug mode - glad you included that!


A little more help would be wonderful ... as I think I'm starting to get the hang of it.


In order to use a selected object for input, I used the 'Object by Criteria' node. 

Here is how I set it up:




And here it is in the OIP.  It looks like the criteria is set correctly.




When I run the script in debug mode... 16 objects show up in the debug output wire, while only one is selected.  I can guess that this is BAD... so I checked the criteria again...



And discovered that it had reverted to a default:



Here the objects say "25" (not "16") so I assume this is just the default setting for Criteria and that the Criteria set in the OIP is still active ... but I can't fathom how with one object selected I got a result of 16.


So I tried replacing the criteria with "Visible Selection State" and then reran the script.  This time I received 0 in the ouptut wire. 


Sorry to ramble at length, just thinking that this step by step might help other users who are struggling with the same issues. 


Can you tell me what I'm doing wrong - or help me understand how I can best use an existing polygon as the source geometry via selection rather than needing to manually enter a name for it each time?




Link to comment
  • Marionette Maven

1) You can use either single or double quotes, it does not matter as long as you open and close with the same type.

2) Marionette networks cannot be run on selected objects unless you convert them to a Marionette Menu Command, though I am not certain, I am assuming that is why you are getting a false count of 16 while running in debug mode.

3) Currently, using the button on the Objects by Criteria node will always revert that dialog back to the defaults. As long as you don't hit OK in that dialog, your previous criteria will remain the same. There is currently a request in to have the Criteria dialog display the current criteria from the OIP when the button is pressed.

4) You can use Control Geometry to define your source geometry as an alternative to the name node and then create a Marionette Object (which is basically a Plug In Object that uses a Marionette script as its code). I'm not sure if this would fit your needs, but if you'd like more information on it, I'd be more than happy to go into further explanation.


Hope this helps!

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