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

Pop up list question

Recommended Posts

Posted (edited)

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?

1712246451_ScreenShot2019-06-26at5_40_56PM.thumb.png.90391394ec78a0b245f461f93e503c09.png

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

 

 

@Marionette.NodeDefinition
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

Share this post


Link to post

Taking a quick look at your script, this may be as easy as adding quotations around your output values (I am assuming these are the strings you use for naming your profile?)

For example

 

if input == 3:
        self.Params.output.value = "K5"

 

Share this post


Link to post

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'

Share this post


Link to post

Taproot, welcome to the amazing world of Marionette!

 

If you prefer a more visual way of selecting a symbol, you could try the custom node "Get Symbol from Folder":

 

Share this post


Link to post

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:

 

1924765490_ScreenShot2019-06-27at9_52_58AM.thumb.png.7fe7cc5b4b977fb4e212e70bef142197.png

 

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

 

2087433646_ScreenShot2019-06-27at1_48_21PM.thumb.png.dcab9cf0bfe325b47611c7429267dd52.png

 

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

611836855_ScreenShot2019-06-27at1_44_36PM.thumb.png.de48791d469d63222718767a95033920.png

 

And discovered that it had reverted to a default:

1115638976_ScreenShot2019-06-27at1_51_01PM.thumb.png.de90d981931d03349eb676010f4c5c50.png

 

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?

 

Thanks.

 

Share this post


Link to post

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!

Share this post


Link to post

Hi Marissa,

 

Very helpful!

Yes, I think the Marionette Object is the direction that I would like to take this.  Can you point me to the examples or resources that I would need to learn how to do this?

 

 

Share this post


Link to post

Great!  I'll review that information.  Thanks.

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.

×