Ansys workbench commands (APDL) step number

fab88
fab88 Member Posts: 4
First Comment Name Dropper
**
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: 183
    5 Answers 100 Comments Photogenic Name Dropper
    admin

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

  • Chris Harrold
    Chris Harrold Member, Administrator, Employee Posts: 183
    5 Answers 100 Comments Photogenic Name Dropper
    admin

    @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: 42
    First Answer 5 Likes 10 Comments Photogenic
    ✭✭✭✭

    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: 235
    100 Comments Photogenic 5 Likes Name Dropper
    ✭✭✭✭
    edited April 18

    @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: 175
    100 Comments Photogenic Ansys Employee 5 Likes
    ✭✭✭✭

    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))