Python code to access CAD Parameter value in DOE/DP

SK
SK Member Posts: 9
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: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

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

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 297
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    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: 85
    Second Anniversary 10 Comments 5 Answers Solution Developer Community of Practice Member
    ✭✭✭✭

    @SK resolved?