In WB Mechanical scripting, how can I change the transformation angles of an external data file?

Member, Employee, GitHub-issue-creator Posts: 353
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭

Here is my project page schematic:

I want to change the Rigid Transformation angles:

From the Mechanical model where it is use:

Answers

  • Member, Employee, GitHub-issue-creator Posts: 353
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    1. import System
    2. from System.Threading import *
    3.  
    4. def RunWBJN(cmds):
    5. def Internal_RunWBJN():
    6. import wbjn
    7. wbjn.ExecuteCommand(ExtAPI,cmds)
    8. thread = System.Threading.Thread(System.Threading.ThreadStart(Internal_RunWBJN))
    9. thread.Start()
    10.  
    11. def SetImportedLoadRotations(ImportedLoadGroup,XY,YZ,ZX):
    12. coord = ImportedLoadGroup.Source.Split(':')[0]
    13. WBcmds = '''
    14. coord = "$coord"
    15. import clr
    16. clr.AddReference("Ans.UI")
    17. import Ansys.UI
    18.  
    19. view1 = Ansys.UI.UIManager.Instance.GetActiveWorkspace().GetView(Ansys.ProjectSchematic.View.ProjectSchematicView.ViewName)
    20. coord_map = dict(view1.CoordinateMap)
    21. coord_map2 = {Ansys.UI.IDManager.GetAlphabeticLabelFromCoordinate(coord_map[key]):key for key in coord_map}
    22. setup1 = coord_map2[coord]
    23. externalLoadData1 = setup1.GetExternalLoadData()
    24. externalLoadFileData1 = externalLoadData1.GetExternalLoadFileData(Name="ExternalLoadFileData")
    25. externalLoadFileDataProperty1 = externalLoadFileData1.GetDataProperty()
    26. externalLoadFileDataProperty1.ThetaXYUnit = '$XY.Unit'
    27. externalLoadFileDataProperty1.ThetaYZUnit = '$YZ.Unit'
    28. externalLoadFileDataProperty1.ThetaZXUnit = '$ZX.Unit'
    29. externalLoadFileDataProperty1.ThetaXY = $XY.Value
    30. externalLoadFileDataProperty1.ThetaYZ = $YZ.Value
    31. externalLoadFileDataProperty1.ThetaZX = $ZX.Value
    32. '''.replace('$coord',coord).replace('$XY.Unit',XY.Unit).replace('$YZ.Unit',YZ.Unit).replace('$ZX.Unit',ZX.Unit).replace('$XY.Value',str(XY.Value)).replace('$YZ.Value',str(YZ.Value)).replace('$ZX.Value',str(ZX.Value))#,YZ.Unit,ZX.Unit,XY.Value,YZ.Value,ZX.Value)
    33. print WBcmds
    34. RunWBJN(WBcmds)
    35.  
    36.  
    37. impload = ExtAPI.DataModel.GetObjectsByType(Ansys.ACT.Automation.Mechanical.ImportedLoads.ImportedLoadGroup)[0]
    38. XY = Quantity(30,'degree')
    39. YZ = Quantity(0.2,'radian')
    40. ZX = Quantity(0.3,'radian')
    41. SetImportedLoadRotations(impload,XY,YZ,ZX)

Welcome!

It looks like you're new here. Sign in or register to get started.