0

Ansys gurus,

My project is a static structural analysis using ANSYS workbench mechanical. I have created the parametrized geometry (via Design modeler) and material property in workbench, and used ACT scripting to configure the model. However, I don't find too much information on how to access the parameters via ACT scripting.

I have confirmed that the geometric parameters are successfully created in the workbench, e.g.

ID Paramater Name Value Unit
P1 diameter 50 um

The documentation LINK suggests that I can obtain parameter ID using Analysis.GetParameter(), however, the following code didn't work for me and resulted in the error as below.

Code:

STATIC_STRUCTURAL = ExtAPI.DataModel.AnalysisByName("Static Structural")

HEIGHT = STATIC_STRUCTURAL.GetParameter('height')

Error: Property not found.

Do you have any suggestions on the cause of such error, is it because the Parameters were not imported from workbench "project schematic" to "Model", or the code I tried to retrieve the parameters was incorrect. In either cases, could you advise the correct method to access the parameters? Thank you!

hawkoli1987

  • I don't think you can access a geometric parameter from within mechanical. Do you really need it from within mechanical? What are you trying to achieve? Do you want to access a non-geometric parameter defined from within mechanical? – meshWorker Aug 05 '22 at 05:44
  • hi meshWorker, thanks for your questions! In my project, I need to model a transient process of detaching an elastic body from a rigid surface. The area of attachment is a surface named selection and I need to decrement it via a geometric parameter. At each stage of detachment, I need to run the simulation and find out the current state of strain energy in the elastic body, and comparing it with a constant value to determine if the detachment will continue. I was hoping the parameter can be access in mechanical scripting such that this iterative process can be automated. – hawkoli1987 Aug 06 '22 at 05:11
  • Perhaps I missed something, but have you tried parametrizing Ansys without ACT: https://www.youtube.com/watch?v=EQFMuUtpRlo – meshWorker Aug 29 '22 at 05:30
  • Another one with parametrization via DesignModeller: https://www.youtube.com/watch?v=4MAelcMfHis – meshWorker Aug 30 '22 at 05:13

1 Answers1

0

If you want to access a parameter from the "project schematic" page you can create a list. If you than want to do something with this inside of mechanical, you have to send the commands to your model:

# Access the geometric parameters
allParameters = Parameters.GetAllParameters()
for parameter in allParameters:
    print parameter.DisplayText
    if parameter.DisplayText == 'height':
        heigthParameter = parameter

# Loop over all systems in the project
for system in GetAllSystems():
    # Get Model Container
    model = system.GetContainer(ComponentName="Model")
    # edit model component in batch mode
    system.Refresh()
    model.Edit(Interactive=True)
    # code to be sent to ansys mechanical
    cmd ='''
here goes your ACT script as string. You have to make sure, that there are no leading spaces or tabs.
    '''
    # send code and exit mechanical
    model.SendCommand(Language='Python',Command=cmd)
    model.Exit()
print "Finished script execution."
meshWorker
  • 183
  • 2
  • 13
  • Thank you meshWorker! I tried the following in mechanical scripting, however, it threw the error ' Name 'Parameters' is not defined. Did I miss anything? – hawkoli1987 Aug 06 '22 at 02:47
  • What is prohibiting you from controlling the parameters from the project schematic? I don't think you can access a geometric parameter from within mechanical. After all it is not a CAD system. – meshWorker Aug 30 '22 at 05:45