Exposing canvas ports to Maya for UI

I noticed that in Maya, if you expose a port on the left side of Canvas, it will in certain cases give you the correct UI for their input in "Other Attributes" of the Canvas Node, but others dont.

Is there a list of which port types create what UI element. Also Maya lets you create custom attributes using Attributes > Add Attribute.., but only certain types, like Number, String, Enum

I am specifially looking for:

  1. File Path picker (non of the file ports show in the node editor or Other Attributes)

  2. Enum (ie. a dropdown list) - Maya lets me create this and it is shown as input and output on the Canvas Node in the Node Editor, but is not available inside canvas

  3. A box where I can drag in another Maya object, like a polygon object or a curve (like you do in MASH)

Thanks for any help or pointers in the right direction.

Best, Armin.

Tagged:

Comments

  • EricTEricT Administrator, Moderator, Fabric Employee Posts: 305 admin

    Maya doesn't understand all of the Fabric types because well, it doesn't have an equivalent type itself. The types that are supported are here:
    http://docs.fabric-engine.com/FabricEngine/2.3.0/HTML/DCCIntegrations/Maya/canvas.html#adding-ports-attributes

    For what you're looking to do, my recommendation would be to create a UI / set of custom attributes that is hosted on a group object that then connects into the Canvas node and feeds different ports that your graph needs.

    Secondly, you'll probably have to break down the different types where you can to be able to do this too. For example the file type isn't going to be supported in the Maya UI, however the file object should be able to take a string for a filepath so you should expose that instead. Additionally, you can't pass a Maya object name and have the canvas node find it. You'll have to connect it to the port.

    You could create a Maya plugin and UI that does all of this for you and is what I would recommend doing if you're looking to create a more sophisticated tool. I believe MASH does the same. It provides a nice UI that then has triggers for when text fields are changed which then fire off commands to disconnect / connect ports on the underlying nodes.

    Eric Thivierge
    Kraken Developer
    Kraken Rigging Framework

  • Daniele NieroDaniele Niero Posts: 233 ✭✭

    Hi,

    As far as I know, Maya uses templates to control aspect and feeling of certain attributes in the attributes editor. These templates are mel scripts (maybe also python) and they are node-related. One script per registered node.
    So the file path attribute with a click button on the side, is actually just a string attribute (attributes on nodes are really few in Maya) but if a template is assigned on that specific node type, then you might have the attribute displayed differently, with the button etc. As far as I know also the combo boxes are just Integer attributes with a template associated to them.

    Now, if I'm right on all these points (I really dislike how attribute editor templating works in Maya, so I've always avoided) it means it's quite tricky to do what you are after in a generic multi porpoise node like the Canvas Node, where attributes are created dynamically. A template cannot know what attributes there are.

    Now, there could be a different way I'm not aware of, but It might be impossible to do what you ask. Let's see what others have to say.

    Other considerations:
    In Canvas if you have a port of type FilePath it's displayed with the browse button, but in Maya is undisplayable, because it is of a type that Maya doesn't know about.

    A box where you drag another Maya object is something I've never seen. Is it a Maya thing?
    The closest thing I know is what you have in a aimConstraint, the worldUpObject attribute where you can put the name of an object. However what is happening is that a connection is made under the hood. In the aimConstraint what is really going on is that the object's worldMatrix[0] is plugged to the constraints' worldUpMatrix... so it's a matrix connection. I don't even thing the worldUpObject attribute exists on the node, I guess it's again a template trick...

    So, don't really trust what Maya shows you, I guess, is my point :)

  • seltzdesignseltzdesign Posts: 80

    Thanks to both of you, for your thorough explanations. I am sure I can find workarounds for those things.

    The one that kind of baffles me and the one that would be really nice to get to work is the enumeration (dropdown menu). Is there a way to get access to the underlying integers in Canvas somehow? It is shown on the canvas node in the node editor, but I am not sure how to get to it inside canvas.

    I will have a look around on how to do some of those things. Automatic connections in Node editor - that sounds good!

  • EricTEricT Administrator, Moderator, Fabric Employee Posts: 305 admin

    @seltzdesign said:
    The one that kind of baffles me and the one that would be really nice to get to work is the enumeration (dropdown menu). Is there a way to get access to the underlying integers in Canvas somehow? It is shown on the canvas node in the node editor, but I am not sure how to get to it inside canvas.

    Not sure exactly what you're asking about here. Could you be more specific?

    Eric Thivierge
    Kraken Developer
    Kraken Rigging Framework

  • seltzdesignseltzdesign Posts: 80

    I guess how to get the enumeration into the canvas node. If I get you right, then I would just create an integer in port in canvas and then somehow link the enumeration created as an Attribute in Maya to the integer input of canvas. The question would be where I put that "somehow". Can I do this with set driver and driven?

    Im really sorry about all my noob questions. Maya is a bit overwhelming even after using it for some time now and I am still new to Canvas and KL.

    Tomorrow I will do some reasearch on Custom Attributes and UI building in Maya.

  • EricTEricT Administrator, Moderator, Fabric Employee Posts: 305 admin

    Yes when you expose an Integerport in Canvas you can set the Enum options for use within the Canvas UI. To get the options you'd have to do some graph introspection using the Canvas API via Python. Checkout this thread that was posted recently about how to do that:
    http://forums.fabricengine.com/discussion/710/parsing-a-graph#latest

    Your script / tool can do a query into the graph and find out those options and create an integer attribute and an Enum control in your Maya UI and then connect it up. I don't have specific code on how to get the enum options but that thread should get you started and you should be able to print the graph / node descriptions which should show you where the data lives and then you can pull it from there.

    Eric Thivierge
    Kraken Developer
    Kraken Rigging Framework

Sign In or Register to comment.