Script Help For User Entry Dialog Box

Script Help For User Entry Dialog Box

Anonymous
Not applicable
580 Views
1 Reply
Message 1 of 2

Script Help For User Entry Dialog Box

Anonymous
Not applicable

I am very new to programming and i have tried to struggle through teaching myself how to do this but i have come to the conclusion that i will not be able to do this without some assistance.

 

My father purchased a CNC router that he will use to scribe/engrave wood and Plexiglas, the issue is he has zero knowledge on how to use CAD. so i would like to be able to create a script to automate as much as possible for him.

What i am trying to do is make a dialog box that he can enter in a length width and height in inches and select a image to have placed on the top surface. from this it will create a rectangle extrusion with the image on the top surface.

 

I have been able to create a script to extrude a rectangle and a script to create a dialog box with boxes for numerical values to be entered.

 

i am struggling with how to relate what is entered in the box to the dimensions in the sketch and extrude feature.

I have not even attempted to try and create the script to add the image to the top surface.

 

The image will be simplified line art that he will use for the engravings. this might be something as simple as someones name or a sports team emblem.

0 Likes
581 Views
1 Reply
Reply (1)
Message 2 of 2

BrianEkins
Mentor
Mentor

I assume you've created a command and are creating ValueCommandInput objects in the command create.  When the command is executed, you can get the information from the ValueCommandInput objects.   It has a "value" property that will return the value of whatever the user entered in internal units (which is always centimeters).  This way the user works in whatever units they want (which defaults to the document units) but Fusion handles any conversion needed and will always return centimeters.  The ValueCommandInput object also has an "expression" property, which is the string that the user entered.  For example, if the document units are inches and they enter 1 into the input box, then the expression property will return "1" and the value property will return 2.54.  They could also enter something like "2/1" or "3 mm + 5 in" or "Length / 2".  For the last one, it's referring to an existing parameter.  The "expression" property will return the string the user entered.  The value will return the evaluated result, in centimeters.

 

When you draw the sketch you use the value you get using the "value" property to draw the geometry because the values are always expected in centimeters.  When you create something that results in the creation of a parameter, like the extent of the extrusion, the input if a ValueInput object.  You can use either the createByReal or createByString methods to create a ValueInput object.  If you input a ValueInput object that contains a real value then the API will treat is as internal units (centimeters).  If you input a ValueInput object that contains a string, then it will use that as the expression for the created parameter.

 

This was probably a much longer and more complicated answer than you were looking for, but hopefully it helps.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes