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: 

Creating an Add-in using FloatSliderCommandInput to modify point3D co-ordinates.

Message 1 of 1
209 Views, 0 Replies

Creating an Add-in using FloatSliderCommandInput to modify point3D co-ordinates.

I have created a sample ladder frame chassis and have input parameters from an input box, but I am struggling to create an Add-in that can also modify point3D using addFloatSliderCommandInput.

Here, I created a body and mirrored it. The width parameter I used, dynamically changes with Command Dialog slider add-in. i.e., dimension of chassis changes in real time when I use slider add-in.
This snippet of chassis script:



# User Parameters
widthValue='65.7 cm'
newInputName=ui.inputBox("Enter a new User Parameter Name: ", "New User Parameter",Width)
newInputNumber=ui.inputBox("Enter a User Parameter Value: ","New User Parameter",widthValue)
realValueInput=adsk.core.ValueInput.createByReal(realInputNumber)  value=design.userParameters.add(newInputName[0],realValueInput,unitsMgr.defaultLengthUnits,'')

# Create a Mirror of body
planeInput = planes.createInput()
offsetDistance = adsk.core.ValueInput.createByString(width) #################
planeInput.setByOffset(face1, offsetDistance)
plane = planes.add(planeInput)
inputEntites = adsk.core.ObjectCollection.create()
mirrorFeatures = features.mirrorFeatures
mirrorInput = mirrorFeatures.createInput(inputEntites, plane)
mirrorFeature = mirrorFeatures.add(mirrorInput)



Now, if I use the same distance i.e. width(valueInput) in point3D, it gives an error.
TypeError: Wrong number or type of arguments for overloaded function 'Point3D_create'



offsetDistance = adsk.core.ValueInput.createByString(Width)
pointA = adsk.core.Point3D.create(-15, -4.3, 0)
pointB = adsk.core.Point3D.create(offsetDistance, -4.3, 0)
lineAB = lines1.addByTwoPoints(pointA, pointB)



This somewhat worked for me, but it doesn't change the dimensions in real time with slider.



pointB = adsk.core.Point3D.create(realInputNumber, -4.3, 0)

# or

Width = design.userParameters.itemByName(Width).value
pointB = adsk.core.Point3D.create(Width, -4.3, 0)



It appears that the variable Width is initialized only once when it is first set to the value of design.userParameters.itemByName(Width).value. After this, the value of Width remains constant, even if I change the value of the slider Add-in.

What I am looking to do is to dynamically change the width in real-time using a slider in the Command Dialog slider add-in, and perform operations on the width in Point3D, such as adsk.core.Point3D.create(width*2, -4.3, 0). This is only possible if width is a number, not a valueInput or string.

If it is not possible to modify the Point3D using User Parameters, then I would appreciate alternative methods for dynamically modifying a sketch created with Point3D using slider parameters.

Alternatively, if it is not possible to achieve this using a slider, then I am open to creating a single Add-in that can change the value of width after I click "ok". (P.S. I am not an expert in User Parameters with Add-ins.)


Screenshot (134).png





Here is my whole code:
EV Chassis Code

Slider Add-in Code:


My previous question link:



I have uploaded a GIF where a selected part is supposed to change the dimensions with respect to slider. 


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