How to add a path and use it for a Normal Stress Result using Mechanical scripting?
Pernelle Marone-Hitz
Member, Moderator, Employee Posts: 871
✭✭✭✭
in Structures
How to add a path and use it for a Normal Stress Result using Mechanical scripting?
Tagged:
0
Answers
-
def InsertPath(UsePathName,node1 , node2 ): firstnode = ExtAPI.DataModel.MeshDataByName("Global").NodeById(node1) secondnode = ExtAPI.DataModel.MeshDataByName("Global").NodeById(node2) Model = ExtAPI.DataModel.Project.Model csall = Model.CoordinateSystems globalcs = csall.Children[0] cons=Model.ConstructionGeometry p=cons.AddPath() p.Name = UsePathName p.StartCoordinateSystem = globalcs p.StartXCoordinate = Quantity(str(firstnode.X)+" [m]") p.StartYCoordinate = Quantity(str(firstnode.Y)+" [m]") p.StartZCoordinate = Quantity(str(firstnode.Z)+" [m]") p.EndCoordinateSystem = globalcs p.EndXCoordinate = Quantity(str(secondnode.X)+" [m]") p.EndYCoordinate = Quantity(str(secondnode.Y)+" [m]") p.EndZCoordinate = Quantity(str(secondnode.Z)+" [m]") allpaths = ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.Path) mypath = [i for i in allpaths if i.Name == UsePathName][0] result = Model.Analyses[0].Solution.AddLinearizedNormalStress() result.NormalOrientation=NormalOrientationType.XAxis sel = ExtAPI.SelectionManager.CurrentSelection pathLoc = Ansys.Mechanical.Selection.PathLocation(mypath, sel) result.Location = pathLoc result.Name=UsePathName #================================================================ #Usage : Path's ( and result's) name , first node, second node numbers InsertPath('newpath2',195 , 84 )
0