Discovery Import

Discovery Import

compare origin alignment in scripting

    • Guillaume ANFOSSI
      Subscriber

      Hello,

      I am looking to automate the part numbering according to their position in an assembly. My idea is to compare the alignement between local and global origin (X and Y). Could you help me to find the code in scripting ?

      If you have another idea you're welcome 

      Thanks,

      ūüõą This post originally contained file attachments which have been removed in compliance with the updated Ansys Learning Forum Terms & Conditions
    • Subashni Ravichandran
      Ansys Employee

      Hello GUICAD

      I will need to consult with my team on this as I'm not an expert on scripting. I will get back to you as soon as I hear from them.

    • Subashni Ravichandran
      Ansys Employee

      Hello GUICAD

      Sorry for the delay in response. As it was the holiday season I found it difficult to get hold of some help.

      You can use commands such as "GetCoordinateSystems()" to access the coordinates of the local coordinate system (wrt global origin) of a component. 

      You can then create a loop to rename the components as per their coordinates as required.

      Below is a sample script written by my colleague to print the coordinates. You can use it for your reference.

      part =GetRootPart()
      comps = part.GetAllComponents()[0]
      print comps.GetName()
      org = comps.GetCoordinateSystems()[0]
      print org.Frame.Origin
      x_coord = org.Frame.Origin[0]
      y_coord = org.Frame.Origin[1]
      z_coord = org.Frame.Origin[2]
      print x_coord
      print y_coord
      print z_coord

    • Guillaume ANFOSSI
      Subscriber

      Thanks

Viewing 3 reply threads
  • You must be logged in to reply to this topic.