Ansys workbench commands (APDL) step number

Options
fab88
fab88 Member Posts: 4
Name Dropper First Comment
edited April 18 in Structures

Hello,
How one set the same commands (APDL) for several steps?
Here is the image for more clarification.

Thank you.

Answers

  • Chris Harrold
    Chris Harrold Member, Administrator, Employee Posts: 117
    First Answer First Comment First Anniversary Ansys Employee
    admin
    Options

    @AKD-Scripting-Team - someone must have some thoughts here?

  • Chris Harrold
    Chris Harrold Member, Administrator, Employee Posts: 117
    First Answer First Comment First Anniversary Ansys Employee
    admin
    Options

    @fab88 - Also the reason you have probably not gotten any replies here is that you posted your question in the announcements area which is for news and updates about the forum. None of the developers will look there for questions so it is easy for them to be overlooked.

    Sorry this sat so long, but I have moved it to the correct forum.

  • Abel Ramos
    Abel Ramos Member, Employee Posts: 30
    5 Likes First Answer First Comment First Anniversary
    Options

    Hello, you might need to create several command snippets with the same input.

    You can do it with something like this:

    analysis = ExtAPI.DataModel.Project.Model.Analyses[0]
    
    stepNumbers = [1,2,5]
    
    for stepNumber in stepNumbers:
        cs = analysis.AddCommandSnippet()
        cs.AppendText("!My APDL code here \n")
        cs.StepSelectionMode=SequenceSelectionType.ByNumber
        cs.StepNumber = stepNumber
    

    Best Regards

  • M
    M Member, Employee Posts: 230
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member
    edited April 18
    Options

    @fab88 You can't do this directly. Step Number will only take a single value input.
    APDL solution:
    What you will need to do is set the Step Selection Mode to All and then in the APDL commands put in a loop and boolean/logic to only run the commands based on your requirements/step.

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 115
    First Answer First Anniversary Name Dropper Solution Developer Community of Practice Member
    Options

    Hi @fab88 ,

    I would suggest using "Python Code" object (RMB on Analysis --> Insert --> Python Code) with default "Target Callback" which is "Get Solve Commands"

    Here you can add APDL commands the same way you do for Command objects, but the only difference is you enclose each command in the way as shown below.

    solver_input_file.WriteLine("!Your command")

    The advantage with this method is, this python code object has easy access to current step number.

    Example code

    stepNumbers = [1,3]
    if solver_data.CurrentStep in stepNumbers:
        solver_input_file.WriteLine("/com,Step number is " + str(solver_data.CurrentStep))