In Mechanical scripting, how can I run APDL using the same license as Mechanical?

Landon Mitchell Kanner
Landon Mitchell Kanner Member, Employee Posts: 290
100 Comments 25 Answers 25 Likes Photogenic
✭✭✭✭

In Mechanical scripting, I am using the RunAnsys() to do some custom post-processing in MAPDL. However RunAnsys() is looking for a license that I do not have.

Best Answer

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 290
    100 Comments 25 Answers 25 Likes Photogenic
    ✭✭✭✭
    Answer ✓

    First define a dictionary to convert license name to increment name:

    ProductArgDict = {'ANSYS Mechanical Pro':'mech_1'}
    ProductArgDict.Add('ANSYS Mechanical Premium','mech_2')
    ProductArgDict.Add('ANSYS Mechanical Enterprise','ansys')
    ProductArgDict.Add('ANSYS Mechanical Enterprise PrepPost','preppost')
    ProductArgDict.Add('ANSYS Mechanical Enterprise Solver','meba')
    

    Get the current license name:

    commandText = "var x=WB.ProductName\n"
    commandText += "returnFromScript(x)"
    ProductName = ExtAPI.Application.ScriptByName("jscript").ExecuteCommand(commandText).Replace('Ansys','ANSYS')
    
    

    Finally, pass the license name to RunANSYS() command:

    postLicenseMAPDL = ProductArgDict[ProductName]
    commandlinestring = " -j " + fileId + " -b nolist -p " + postLicenseMAPDL + " -i " + datFile + " -o " + outFile
    ansys.RunANSYS(ExtAPI,commandlinestring,runDir=dirName,exelocation=None,minimized=True,hidden=True,unlockLicense=True)
    

Answers

  • Magnus Gustafsson
    Magnus Gustafsson Member Posts: 1
    Photogenic First Comment
    **

    Due to the name change in the products from "ANSYS" to "Ansys" this script included a "Replace" to cope with both the old and new product names.
    The "commandlinestring" contains a variable "fileId" for the job name, this should not be "file".
    The "datFile" is the input file name usually created in the working directory specified by "dirName" and should not be "ds.dat".
    The "outFile" is the output file name, this should not be "solve.out".