3D Design

3D Design

Topics related to Ansys Discovery and Ansys SpaceClaim.

Inconsistent Script

    • Lumbdi
      Subscriber

      I'm generating a geometry using a script in spaceclaim. It used to work in other projects, but since I  swapped from 24R2 to 25R1 it's inconsistent and only works sometimes.
      It makes a 2D plane

      sectionPlane = Plane.PlaneXY
      result = ViewHelper.SetSketchPlane(sectionPlane, None)

      and adds lines

      result = SketchLine.Create(start, end)

      I then want to make named selections, but these lines get sometimes added to FFF/Sketching Plane1 / Sketch1 and sometimes to FFF / Surface (which is how it used to work).
      If i delete the sketchContainer1, i get an alternating once it works and then it doesn't behaviour 

      selection = SketchContainer1
      Delete.Execute(selection)

      How do i make this consistent?

    • NickFL
      Subscriber

      Based upon what you have said, my first instinct is to say that your sketch is not completely closed, or you have some inconsistent constraints. Do you have some geometry already created when this part of your script is executed?

       

      When you finish drawing your sketch and go to 3D Solid Mode, SpaceClaim will automatically try and fill. But if it does not do the fill automatically, you can force it to yourself. Use the commands:

      sel = Selection.Create(GetRootPart.DatumPlanes[-1].Curves[:])

      sel2 = Selection.Empty()

      options = FillOptions()

      result = Fill.Execute(sel,sel2,options)

      The part you may want to look at here is the fill options. The default GapDistance is 0.0001 [m]. Depending on your situation this may not be sufficiently large. You could increase it to something more appropriate for this sketch.

      Another thing, it is good to create a plane and then work off this plane instead of working in 3D Sketch containers. An example code would look like:

      # Bezugsebene erstellen

      selection = Selection.Create(GetRootPart().CoordinateSystems[0].Axes[0])

      result = DatumPlaneCreator.Create(selection, False, None)

      selection = Selection.Create(result.CreatedPlanes)

      result = ViewHelper.SetSketchPlane(selection)

       

      # Set 3 Points and create lines

      point1 = Point2D.Create(MM(9), MM(8))

      point2 = Point2D.Create(MM(13), MM(17))

      point3 = Point2D.Create(MM(25), MM(15))

      result = SketchLine.Create(point1, point2)

      result = SketchLine.Create(point2, point3)

      result = SketchLine.Create(point3,point1)

       

      # Grab all the lines and fill

      sel = Selection.Create(GetRootPart().DatumPlanes[-1].Curves[:])

      sel2 = Selection.Empty()

      options = FillOptions()

      result = Fill.Execute(sel,sel2,options)

      • Lumbdi
        Subscriber

        I have a loop in the beginning that deletes old geometries:
        while GetRootPart().Components.Count > 0:
            GetRootPart().Components[0].Delete()
        while GetRootPart().Bodies.Count > 0:
            GetRootPart().Bodies[0].Delete()
        while GetRootPart().Curves.Count > 0:
            GetRootPart().Curves[0].Delete()

        Is there a better way to clear current geometries?
        This also doesn't work anymore, since this lines are not in GetRootPart().Components. But even if I delete everything in FFF*, this occures.
        If I include your

        selection = Selection.Create(GetRootPart().CoordinateSystems[0].Axes[0])
        result = DatumPlaneCreator.Create(selection, False, None)
        selection = Selection.Create(result.CreatedPlanes)
        result = ViewHelper.SetSketchPlane(selection)

        at the start and:

        # Grab all the lines and fill

        sel = Selection.Create(GetRootPart().DatumPlanes[-1].Curves[:])
        sel2 = Selection.Empty()
        options = FillOptions()
        result = Fill.Execute(sel,sel2,options)

        at the end, the first run goes through, but the second one throws an error:

        result = Fill.Execute(sel,sel2,options)
        The Fill command must include a Face or Edge selection

        Which to me sounds like the same issue and GetRootPart() doesn't contain the drawn lines.

        Thank you very much your help!

    • Lumbdi
      Subscriber

      -> Reply

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