Can I access the arguments in a command snippet through ACT scripting?

Pernelle Marone-Hitz
Pernelle Marone-Hitz Member, Moderator, Employee Posts: 741
First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
edited June 2023 in Structures

Is it possible to access the details view, and especially read/edit the “ARG1”, “ARG2”, etc. values of a command snippet in Mechanical?

Tagged:

Answers

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

    Yes, this is possible:

    analysis = ExtAPI.DataModel.Project.Model.Analyses[0] # reference analysis
    snippet = analysis.GetChildren(DataModelObjectCategory.CommandSnippet,True)[0] # get first command snippet object in the analysis
    print(snippet.InputArgument1) # print the value of “ARG1”
    snippet.InputArgument1="342" # change the value of “ARG1”
    
  • M
    M Member, Employee Posts: 199
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    Answer ✓

    OutputParameter_1 = snippet.OutputParameters[0].Value