General Mechanical

General Mechanical

ANSYS Scripting: Defining Global Coordinate System through Python Script

    • jainsam
      Subscriber
      Hi, I am trying to write a Python script in an ANSYS Transient structural Problem to define a joint. I have written the code to create a joint and define all elements of it except the origin. In the joint, the reference coordinate system has origin by default to be defined by geometry selection. I am not able to find the command to change it to global coordinates. What is the Python script command to change it to Global coordinates?nPlease note that I need only Python script command that can be directly run in editor to change it to global coordinates.nMy current code to create a joint is:njoint1=DataModel.Project.Model.Connections.AddJoint()njoint1.ConnectionType=JointScopingType.BodyToGroundnnamed_selection1=DataModel.GetObjectsByName(XYZ)njoint1.PromoteToNamedSelection()njoint1.MobileLocation=named_selection[0]njoint1.Type=JointType.Generalnjoint1.TranslationX=FixedOrFree.Freenjoint1.TranslationY=FixedOrFree.Freenjoint1.TranslationZ=FixedOrFree.Freenjoint1.ReferenceCoordinateSystem.PrimaryAxisDefineBy=CoordinateSystemAlignmentType.GlobalZnjoint1.ReferenceCoordinateSystem.SecondaryAxisDefineBy=CoordinateSystemAlignmentType.GlobalYn
    • Aniket
      Ansys Employee
      Hi,I believe there is a typo in the code for named_selection1 object in your code.nanyway if you enable recording you can get the code which you are stuck on as follows:njoint1.ReferenceCoordinateSystem.OriginDefineBy=CoordinateSystemAlignmentType.Fixednjoint1.ReferenceCoordinateSystem.OriginX = Quantity(1, m)n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning Forumn
    • jainsam
      Subscriber
      Hi Aniket, nThank you for your response. I had already tried the code suggested by you but it is giving the following error:nCoordinateSystem' object has no attribute 'OriginDefineBynNeither the editor is showing the command on the recording. Could you please help me with how to get this attribute in my editor?n
    • Aniket
      Ansys Employee
      which version are you using? I have checked this in 2021R1 and seems to working.n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning Forumn
    • jainsam
      Subscriber
      I am using ANSYS 2020 R1 version. Maybe there is some option to see all attributes in my version too. Alternatively, can this be implemented using the APDL Command block? If so, please help me with how to implement using the APDL command block.nn
    • Aniket
      Ansys Employee
      Is there any chance that you can upgrade to 2021R1? you can use dir() and help() methods to check all attributes and arguments for an object in python.n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning Forumn
Viewing 5 reply threads
  • You must be logged in to reply to this topic.