Discovery Import

Discovery Import

Get BoundiingBox

    • Guillaume ANFOSSI
      Subscriber

      Hi,

      Do you know how to find by scripting the bounding box of a body, along a specific direction that is not aligned with the origin ?

    • Subashni Ravichandran
      Ansys Employee

      Hello GUICAD

      I'm not very clear with your query.
      Do you wish to use scripting to align the bounding box of the component in a specific direction?

    • Guillaume ANFOSSI
      Subscriber

      Hello  Subashni

      Yes exactly.

    • Subashni Ravichandran
      Ansys Employee

      Hello GUICAD

      I found the below script and it may help you get the projected points using a bounding box.

      body=GetRootPart().Bodies[0]
      boundingBox=body.Shape.GetBoundingBox(Matrix.Identity)
      center=boundingBox.Center
      view=ViewHelper.GetCurrentProjection()
      viewZDir=Direction.Create(view.Item[2,0],view.Item[2,1],view.Item[2,2])
      newFrame=Frame.Create(center,viewZDir)
      centerPlane=Plane.Create(newFrame)

      for p in boundingBox.Corners:
          pProj=centerPlane.ProjectPoint(p)
          SketchPoint.Create(pProj.Point)

      # Create Box
      result = BlockBody.Create(Point.Create(MM(-10), MM(-10), MM(0)), Point.Create(MM(10), MM(10), MM(20)), ExtrudeType.ForceAdd, Info1)
      # EndBlock

       

      Please let me know if this helps. As I'm not very well versed with scripting I may need to consult the experts on this and get back to you.

    • Guillaume ANFOSSI
      Subscriber

      Hello Subashni

      Thanks for this information, but it's not exactly what I'm looking for.
      The goal is to get the maximum dimensions of a part that is not necessarily oriented correctly with respect to the world origin. (the creation of the box is not desired, just get the maximum dimensions)

      With "boundingBox=body.Shape.GetBoundingBox(Matrix.Identity)" i get the bounding box oriented with respect to the world origin while I would like to orient this box with respect to a local origin (with as direction Z, the direction of the edge of maximum length

      🛈 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

      Ok I understand now. 

      Let me check with my team if this can be done. 

    • Subashni Ravichandran
      Ansys Employee

      Hello GUICAD

      I discussed with my team and I gather that the Bounding box per definition is aligned to the coordinate axis. So I believe that cannot be changed.

      An alternative workaround would be to use the 'Create workpiece' option.

       

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