Python code to access CAD Parameter value in DOE/DP

Options
SK
SK Member Posts: 6
Name Dropper First Comment

Hello,
I'm using below script to get CAD parameter information inside mechanical by running it in mechanical scripting window. But when I create a Python code for the same script it says null value for L,H and R.

Can you please help me in this, or can you please suggest a way to access DP parameter values in python code so that my script will run over all DP points. Thanks.

Scirpt :

import wbjn

parameters_cmd ='''

parameter, parameterName, parameterValueType, parameterValue, parameterValueUnit = ([] for i in range(5))

for param in Parameters.GetAllParameters():
parameter.append(param.Name)
parameterValue.append(param.Value.Value)
parameterName.append(param.DisplayText)
parameterValueUnit.append(param.Value.Unit)
parameters = [parameter,parameterValue,parameterName,parameterValueUnit]
returnValue(parameters)
'''

parameter= wbjn.ExecuteCommand(ExtAPI,parameters_cmd)

These are geometric parameters

L=parameter[1][0]
H=parameter[1][1]
R=parameter[1][2]

print(L,H,R)

Comments

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 804
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Options

    @AKD-Scripting-Team Could someone have a look? Many thanks

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 208
    First Answer First Comment 5 Likes First Anniversary
    Options

    I have not worked with Python code objects much, so just guessing here, but probably you need to add the location of the wbjn module to your system path. Something like:

    import sys
    pyDir = r"C:\Program Files\ANSYS Inc\v241\Addins\ACT\libraries\Mechanical"
    sys.path.append(pyDir)
    
  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 67
    First Anniversary Solution Developer Community of Practice Member Ansys Employee 5 Likes
    Options

    @SK resolved?