@BrianEkins @kandennti
Apologies, if my previous responses were unclear.
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
Width='Width'
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)
realInputNumber=unitsMgr.evaluateExpression(newInputNumber[0],unitsMgr.defaultLengthUnits)
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)
plane.isLightBulbOn=False
inputEntites = adsk.core.ObjectCollection.create()
inputEntites.add(body1)
mirrorFeatures = features.mirrorFeatures
mirrorInput = mirrorFeatures.createInput(inputEntites, plane)
mirrorFeature = mirrorFeatures.add(mirrorInput)
Now, if I use the same distance 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
realInputNumber=unitsMgr.evaluateExpression(newInputNumber[0],unitsMgr.defaultLengthUnits)
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 seems that the above variable Width is only initialized once when I first set it to the value of design.userParameters.itemByName(Width).value.
After that, the value of Width remains the same even if I change the value of the slider Add-in.
What I want is to change the width dynamically using Point3D using Command Dialog slider add-in in real time. I also want to perform some operations on width in Point3D, like adsk.core.Point3D.create(Width*2, -4.3, 0).
Here is my whole code:
EV Chassis Code
https://github.com/purushottamnawale/cad-customization-of-ev-chassis/blob/main/Chassis.py
Slider Add-in Code:
https://github.com/purushottamnawale/cad-customization-of-ev-chassis/tree/main/Add-in
I have uploaded a GIF where a selected part is supposed to change the dimensions with respect to slider.