Skip to content

FeatReq: Define JSON schema for command inputs #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jakefrommars64 opened this issue Jul 8, 2024 · 0 comments
Open

FeatReq: Define JSON schema for command inputs #16

jakefrommars64 opened this issue Jul 8, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@jakefrommars64
Copy link
Owner

Is your feature request related to a problem? Please describe.
n/a

Describe the solution you'd like
Fusion 360 Add-Ins are separated into separate commands located in separate directories within the root/commands/ directory. Within the entry.py file in each command directory in the function command_created is where the definitions for the command inputs are defined. I would like to create a JSON schema that allows easier definition and customization of the command inputs.

For example, the sample commandDialog sample inlcludes the following sample command inputs:

def command_created(args: adsk.core.CommandCreatedEventArgs):

    # https://help.autodesk.com/view/fusion360/ENU/?contextId=CommandInputs
    inputs = args.command.commandInputs

    # Create a simple text box input.
    inputs.addTextBoxCommandInput("text_box_1", "Some Text", "Enter some text.", 1, False)
    
    # Create a value input field and set the default using 1 unit of the default length unit.
    defaultLengthUnits = app.activeProduct.unitsManager.defaultLengthUnits
    default_value = adsk.core.ValueInput.createByString("1")
    inputs.addValueInput("value_input_1", "Some Value", defaultLengthUnits, default_value)

To implement my idea, the command inputs would instead be defined in a schema file:

{
    "sampleCommandDialog": {
        "inputs": {
            "textBox": {
                "id": "text_box_1",
                "name": "Some Text",
                "formattedText": "Enter some text.",
                "numRows": 1,
                "isReadOnly": false
            },
            "valueInput": {
                "id": "value_input_1",
                "name": "Some Value",
                "initialValue": "1"
            }
        }
    }
}

The python code would be replace with this:

def command_created(args: adsk.core.CommandCreatedEventArgs):

    # https://help.autodesk.com/view/fusion360/ENU/?contextId=CommandInputs
    inputs = args.command.commandInputs
    
    jsonSchemaInterpretingFunction("command_inputs.json", inputs)

The function jsonSchemaInterpretingFunction would read the schema and automatically add the command inputs defined in the schema to the inputs variable in the command_created function.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@jakefrommars64 jakefrommars64 added the enhancement New feature or request label Jul 8, 2024
@jakefrommars64 jakefrommars64 changed the title Define JSON schema for command inputs FeatReq: Define JSON schema for command inputs Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant