Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Why get I this error?

jedL95UP
Observer

Why get I this error?

jedL95UP
Observer
Observer

Hi,

 

I get this error when trying the script.

 

The doc I read from is attached.

 

Failed:

Traceback (most recent call last):

File "C:/Users/*****/Dropbox/*****/Fusion/Script/Import CSV/ImportCSVIntoFXparameter/ImportCSVIntoFXparameter.py", line 44, in run

sheetDimXReal = unitsMgr.evaluateExpression(str(sheetDimX),'mm')

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users/*****/AppData/Local/Autodesk/webdeploy/production/80334f1f1d9684bdf5e16fc8205e53367e0cee32/Api/Python/packages\adsk\fusion.py", line 72069, in evaluateExpression

return _fusion.FusionUnitsManager_evaluateExpression(self, *args)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

RuntimeError: 6 : The expression parameter is not a valid expression

 

#Script start here.

from asyncio import constants
import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context😞
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        design = adsk.fusion.Design.cast(app.activeProduct)
        doc = app.activeDocument
        # # Read the csv file.
        file = open('C://temp//test.txt')
        for line in file:
            # Get the values from the csv file.
            pieces = line.split(',')
           
            # sheetDimX = [4]
            xstock = [4]
            sheetDimY = [5]
            xLength = pieces[7]
            yLength = pieces[8]
            xMatrix = pieces[9]
            yMatrix = pieces[10]

        sheetDimXName = 'SheetDimInX'
        sheetDimX = xstock
        sheetDimYName = 'SheetDimInY'
        sheetDimY = 445
        # xLength = 6.7
        xLengthName = 'LengthInX'
        # yLength = 22.7
        yLengthName = 'LengthInY'
        xMatrixName = 'MatrixInX'
        yMatrixName = 'MatrixInY'
        thickness = 2
        thicknessName = 'Thickness'
        cornerRadius = 1.5
        cornerRadiusName = 'Radius'
        unitsMgr = design.unitsManager
        # draftAngleReal = unitsMgr.evaluateExpression(str(draftAngle),'deg')
        sheetDimXReal = unitsMgr.evaluateExpression(str(sheetDimX),'mm')
        sheetDimYReal = unitsMgr.evaluateExpression(str(sheetDimY),'mm')
        xMatrixReal = unitsMgr.evaluateExpression(str(xMatrix),'mm')
        yMatrixReal = unitsMgr.evaluateExpression(str(yMatrix),'mm')
        xLengthReal = unitsMgr.evaluateExpression(str(xLength),'mm')
        yLengthReal = unitsMgr.evaluateExpression(str(yLength),'mm')
        thicknessReal = unitsMgr.evaluateExpression(str(thickness),'mm')

        # realDraft = adsk.core.ValueInput.createByReal(draftAngleReal)
        realSheetDimX = adsk.core.ValueInput.createByReal(sheetDimXReal)
        realSheetDimY = adsk.core.ValueInput.createByReal(sheetDimYReal)
        realXMatrix = adsk.core.ValueInput.createByReal(xMatrixReal)
        realYMatrix = adsk.core.ValueInput.createByReal(yMatrixReal)
        realXLength = adsk.core.ValueInput.createByReal(xLengthReal)
        realYLength = adsk.core.ValueInput.createByReal(yLengthReal)
        realThickness = adsk.core.ValueInput.createByReal(thicknessReal)

        # design.userParameters.add(draftName,realDraft,'deg','')
        design.userParameters.add(sheetDimXName,realSheetDimX,'mm','')
        design.userParameters.add(sheetDimYName,realSheetDimY,'mm','')
        design.userParameters.add(xMatrixName,realXMatrix,'mm','')
        design.userParameters.add(yMatrixName,realYMatrix,'mm','')
        design.userParameters.add(xLengthName,realXLength,'mm','')
        design.userParameters.add(yLengthName,realYLength,'mm','')
        design.userParameters.add(thicknessName,realThickness,'mm','')
0 Likes
Reply
Accepted solutions (1)
239 Views
1 Reply
Reply (1)

kandennti
Mentor
Mentor
Accepted solution

Hi @jedL95UP -San.

 

I don't understand, but the error can be avoided by modifying the following.

・・・
            # sheetDimX = [4]
            # xstock = [4]
            xstock = pieces[4]
            # sheetDimY = [5]
            sheetDimY = pieces[5]
            xLength = pieces[7]
            yLength = pieces[8]
            xMatrix = pieces[9]
            yMatrix = pieces[10]
・・・
1 Like