Jump to content
Altivec

Controlled Drop Down Menu

Recommended Posts

I'm loving Marionette. This is an awesome addition to VW

Is there a way to have a drop down menu in the OIP where you control what is shown.

I want to be able to change classes to certain parts of the geometry but instead of showing hundreds of classes, I just want to have the option to see and pick from only 2 or 3 of them.

I was hoping there was a marionette object called Menu, where you can enter a list of strings that I could just attach to the Set Class Object. This seems to be my most missed functionality of Marionettes. I can see many instances where I would want to give a few listed options to pick from in the OIP

Does anybody know if there is such functionality that I just can't seem to find or any suggestions for a work around.

Share this post


Link to post

Thanks Dave

Although I have done scripting before, I do not know python at all. So when I go off the GUI method and go into actual editing of the script, there is a big learning curve on my part.

I was able to accomplish what I initially asked for from reading the link you referred me to along with a lot of experimentation. Now that I've done that, I figured I would like to make the marionette object I created more flexible so that it can be used in the GUI for ease of use in other functions as well.

What I'm trying to do I believe should be simple to anyone that knows python, but would take me a ton of time to research and figure out. If anyone would be kind enough to steer me in the right direction, it would be greatly appreciated.

All I'm trying to do is have the inputs for choice 1 and choice 2 show up in the menu. This is my entire script:

@Marionette.NodeDefinition

class Params(metaclass = Marionette.OrderedClass):

this = Marionette.Node( 'PopUp Menu 2' )

this.SetDescription( 'Pop Up Menu for 2 choices' )

menu1 = Marionette.PortIn( 0 )

menu2 = Marionette.PortIn( 0 )

out = Marionette.PortOut()

k = Marionette.OIPControl( 'Popup', Marionette.WidgetType.Popup, 0, [ 'menu1', 'menu2'])

def RunNode(self):

self.Params.out.value = self.Params.k.value

The script works great but obviously what shows up in the pop up menu are the words "menu 1" and "menu 2" instead of the input values. What I am wondering is what syntax I should use to have the inputs show up instead.

Sorry for these noob questions which I am sure might annoy some but I'm learning.

Share this post


Link to post

Marionette does not have dynamic menu support, which might be what I think you're talking about? BTW I just started learning Python and Marionette on Friday and it's fun!

Share this post


Link to post

You might pass a list from an input node to this node through the menu1 port, and try setting the 4th parameter of the OIPcontrol to the input port? So ", 0, menu1)" (not sure if this would work)

Edit: I tried this and it didn't work for me. I passed a list from an input node to a port that was initialized to PortIn([]) and used that as the parameter to OIPControl but that didn't work.

Edited by Dave Donley

Share this post


Link to post

Nice Try Dave,

Its fun learning but I wish I knew it all already. I have all these great ideas but I can't get them to work. Its definitely going to be a long process.

I felt I was getting too ambitious for my knowledge level so I scaled back my plans to just get it to work. I thought it was working but its not. This is my simplified script:

@Marionette.NodeDefinition

class Params(metaclass = Marionette.OrderedClass):

this = Marionette.Node( 'PopUp Menu 2' )

this.SetDescription( 'Pop Up Menu for 2 choices' )

out = Marionette.PortOut()

k = Marionette.OIPControl( 'PopUp', Marionette.WidgetType.Popup, 1, ['Exterior-Finish', 'Exterior-Finish Detail'])

def RunNode(self):

self.Params.out.value = self.Params.k.value

Although the popup menu shows up with the 2 class selections I want, it does not get passed on to the output. I know this because I have my out connected to the 'styleClass' input of the Set Class marionette object. When I run everything I can see that the object is not taking on the attributes of that class and when I convert the object to group, I see that a class named '0' was applied to those objects, instead of one of my choices in the popup.

Share this post


Link to post

Hi Altivec, right now we don't have the capability to create a dropdown menu from input ports in Marionette (if we do it would take a much better coder than me), but I have attached a node that I think might work. It is based on the node "Choice Item" in the "Records and IFC" category. you have to change the actual strings within the node to change the dropdown.

However, if you are looking instead for an either/or option, where there is a test within you definition that decides which value, I would use the If node. just make sure that whatever node or definition you use for the "test" input ends with a boolean value. Examples of such nodes are those whose names have the words "Is" or "Equal."

Hope that helps!

Share this post


Link to post

Thank You sbarrett,

your scripts work great and solves my problem. I guess I just have to cool it a bit while I wait for Marionette to mature a little more. Just got excited with the ability to make my own tools.

I think a downdown menu input object would be an excellent addition to Marionette 2.0. lol

Another one I would like to see for input is mouse click coordinates. I created my fancy tool and turned it into a symbol but no matter where I click, the object gets produced at 0,0. I'm sure there is a way of getting mouse info using python but as you can see, i'm really new to this and although Marionette is easy to learn, python is not.

Hopefully the community embraces Marionettes and shares some of these functions with us guys that are still learning. Thanks again.

Share this post


Link to post

So there is no possibility to create a list and attach it into a pop-up node? I want to let a boolean decide which list must be choosable in the pop-up node.

For example:

If the boolean cars is true the popup node displays a list of cars. If the boolean boats is true the popup node displays a list of boats.

Share this post


Link to post

@VerhoevenJ

Unfortunately at this time this is not possible. I will make sure there is a documented wish for this in our tracking system. (I'm pretty certain one already exists, and I will add your use case to the report.)

Share this post


Link to post

Visiting this topic as it's something I'm looking to do in Vectorworks 2019, does anyone know if this is implimented?

 

I'm trying to create a few objects where the values are determined by pre-define input nodes but also a custom option where a value can be manually added by the user. Is this possible?

  • Like 1

Share this post


Link to post

Yes, @Dishav Vasudev there is now a node in the default library that allows you to do this. Its called the Popup Dialog node and its in the User Interaction folder. the way it works is that it takes a list input generated by the script and when you run the script, a dialog pops up and allows you to choose from a dropdown of that list. 

  • Like 3

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