Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Looking for API documentation for all variations of "value" for doing update and validate handlers in Python

Message 1 of 5
199 Views, 4 Replies

Looking for API documentation for all variations of "value" for doing update and validate handlers in Python

Does someone have a link to something that describes the change and validation handlers for all the control inputs along with all of the attributes on their corresponding events?  I'm getting really bogged down in hunting stuff down. Is there something really obvious I am missing?  I often miss things.

I added an I
ntegerSpinnerCommandInput and my validate handler is throwing an exception. The same code works for FloatSliderCommandInput, IntegerSliderCommandInput, bool value, value input, but not IntegerSpinnerCommandInput

For the Slider commands, the ".valueOne" attribute works but I had to get that from a forum question and not in either the "reference" API nor the type hints.

I have concluded that parts of this code just have attributes tacked on at runtime and not mentioned in the __init__ or in any type hints. None of this is reachable in the API "reference" because it leaves out arguments, references to events, and so on.

For future reference, maybe Autodesk could clean up all the added-on attributes and add the missing documentation to the "reference" pages? I believe this would be well worth the effort. You might take a look at how the Java folks use "Javadoc". Once you get used to Javadoc you get pretty spoiled -- like me!
                  val = None
                    if isinstance(theControl, (FloatSliderCommandInput, IntegerSliderCommandInput)):
                        if hasattr(theControl, "valueOne"😞
                            val = theControl.valueOne
                        val = inputChangedEvent.input.value
Message 2 of 5

@tim.collins29V9X I may not have fully understood the requirement. But, I believe this can give some insight into what you are looking for. Fusion comes with a sample add-in named CommandSample. The Everything command of this add-in shows how to use different control units. Can you check if the command implementation is what you are looking for? When edit/debug the add-in VSCode look for under commands>Everything. 

Hope it helps.


If my reply was helpful, please click the "Accept as Solution" button. It helps others get the answer quickly! A "Like" is always welcomed.

Rushikesh Kadam
Senior QA Engineer
Quality Assurance
Autodesk, Inc.

Message 3 of 5

Thanks @Rushikesh.kadam  I had forgotten about that sample code. This is probably my best hope for success.

As far as I can tell there is not even a single example of validating inputs. I only one example of ".value" in just one of change event handlers, for a text box.


There are two "log_command_inputs" functions which have a bunch of tests using "hasattr()" calls. However, there is no guarantee that the validate or the changed events match the the command execute event. I could use "log_command_inputs" as my starting point and code many hassattr() tests and defensive "if" and "try" statements and wait for the change and validate handlers to fail as I add new controls.  


This is what I was hoping to avoid. I was hoping I could just use F12 in Visual Studio Code. I am a big fan of the Liskov substitution principle. I'm not sure they still teach this stuff any longer.


I'll wait a day to see if anyone else wants to add to this conversation before marking this "solved".

Message 4 of 5



I'm not sure I understand what you mean about these attributes being missing in the API reference. I can see that the documentation for IntegerSliderCommandInput documents that it has a valueOne and a valueTwo property (sliders can have two values if they are double ended sliders) while the documentation for IntegerSpinnerCommandInput has only a single value property (for its singular value). If there are any specific attributes (part of the formal interface) that you are not seeing in the documentation, can reference the type and method/property? There should be no attributes (part of the supported, documented interface) "added-on", so if you have any examples of those, please let me know.


Those generic 'log_command_inputs' from the sample using all those 'hasAttr' calls would not be a good pattern to replicate in real application code. (That was just a shortcut taken for a dump of generic control values.) Normally, you would switch on the CommandInput's 'id' property and perform validation (or other event) handling for that specific input. The type and meaning of the input would be a known in your application. (E.g. The input with id 'length' is a float spinner type, and I want to limit it to values in a specific range, or snap them to intervals.) Instead of using 'hasAttr' all over, it is often better to switch based on the object's type (using either 'isinstance' or the 'cast' method on our types as documented in the Python Specific Issues help topic).


Code hints should also be available for all of these types (again, let me know of specific omissions you notice so we can take a look). But I suspect the reason is that you are only looking at the base (CommandInput) typed variables in your code. Since the event args are generic for all input types, they provide the base CommandInput type. If you want to call methods/properties from a subtype, you will only get type hints from the IDE if you use a variable of that sub type. For example, if in an event handler you have an 'input' variable of type CommandInput, the IDE won't know that it has a value attribute (but you can call it anyway if you want). For example, you won't get any code hints for subclass members with:

val = input.value

But if you tell the IDE that it is a subtype with something like:

if == 'length' and isinstance(input, adsk.core.FloatSpinnerCommandInput):
    val = input.value

You will get code hints from the IDE because the isinstance check tells the IDE the specific sub type. Likewise, you could also use a 'cast' in which case the return type is the casted object type (check for a 'truthy' response to check if it was that type). Or you can just assign into a variable of the sub-type if you know what the type is (e.g. from the check of the 'id'). For example:

if == 'length':
    float: adsk.core.FloatSpinnerCommandInput = input
    val = float.value



Kris Kaplan
Message 5 of 5

Thanks @KrisKaplan for your good advice, I will use all of it.

I incorrectly assumed that events would be abstract "foo has changed to 3" (from my somewhat pedantic notions of model-view-controller) rather than "hey, this UI object changed somehow, go check it out."  This is perhaps the only event-listener API I've used where the new value isn't actually in the event. My bad.

I any case don't think I'll have trouble adjusting my little MVC framework. I can easily find the CommandInput created per ID.

I am a bit spoiled by Javadoc. Event types that use an object class in a callback (listener) end up having links on both event and the object and the interface spec so it is simpler to bounce back and forth. I am pretty sure Python doesn't have this.

The API page for  ValidateInputsEventArgs  doesn't have "input" on it,  nor does the inherited class EventArgs nor does Base. I hope this is useful for someone.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report