3D Design

3D Design

Topics related to Ansys Discovery and Ansys SpaceClaim.

Error with Spaceclaim scripting

TAGGED: 

    • evan_gu
      Subscriber

      Error with Spacescripting when record mesh generate and rerun the code.

      it is fine using debug mode and error using run mode.

       

      code:

      # Create/Edit Mesh
      options = CreateMeshOptions()
      options.SolidElementShape = ElementShapeType.Hexahedral
      options.SurfaceElementShape = ElementShapeType.QuadDominant
      options.BlockingType = BlockingDecompositionType.BoundingBox
      bodySelection = BodySelection.Create(GetRootPart().Bodies[0])
      sweepFaceSelection = Selection.Empty()
      result = CreateMesh.Execute(bodySelection, sweepFaceSelection, options)
      # EndBlock

       

      Error messeage:
      System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
         at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
         at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
         at SpaceClaim.UserInterface.ScriptHelper.ExecuteAllOnMainThread[T](GetValue`1 task)
         at SpaceClaim.Api.V21.Scripting.Commands.CreateMesh.Execute(ISelection bodies, ISelection sourceFaces, CreateMeshOptions options, ICommandInfo info)
         at Microsoft.Scripting.Interpreter.FuncCallInstruction`5.Run(InterpretedFrame frame)
         at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
         at Microsoft.Scripting.Interpreter.LightLambda.Run6[T0,T1,T2,T3,T4,T5,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
         at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
         at Microsoft.Scripting.Interpreter.DynamicInstruction`6.Run(InterpretedFrame frame)
         at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)

    • evan_gu
      Subscriber

      Dose anyone have the same problem?

    • evan_gu
      Subscriber

      ALL CODE:

      # Python Script, API Version = V19

      ClearAll()

      # Set New Sketch
      result = SketchHelper.StartConstraintSketching()
      # EndBlock

      # Sketch Rectangle
      plane = Plane.PlaneZX
      result = ViewHelper.SetSketchPlane(plane)
      point1 = Point2D.Create(MM(4),MM(-3))
      point2 = Point2D.Create(MM(-8),MM(-3))
      point3 = Point2D.Create(MM(-8),MM(4))
      result = SketchRectangle.Create(point1, point2, point3)
      # EndBlock

      # Solidify Sketch
      mode = InteractionMode.Solid
      result = ViewHelper.SetViewMode(mode, None)
      # EndBlock

      # Extrude 1 Face
      selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[0])
      options = ExtrudeFaceOptions()
      options.ExtrudeType = ExtrudeType.Add
      result = ExtrudeFaces.Execute(selection, MM(6.26), options)
      # EndBlock

      # Set Sketch Plane
      sectionPlane = Plane.PlaneXY
      result = ViewHelper.SetSketchPlane(sectionPlane, None)
      # EndBlock

      # Move section plane
      axis = HandleAxis.Z
      distance = MM(9.06)
      result = ViewHelper.TransformSectionPlaneAlongAxis(axis, distance)
      # EndBlock

      # Set New Sketch
      result = SketchHelper.StartConstraintSketching()
      # EndBlock

      # Sketch Rectangle
      point1 = Point2D.Create(MM(1),MM(3))
      point2 = Point2D.Create(MM(7),MM(3))
      point3 = Point2D.Create(MM(7),MM(-2))
      result = SketchRectangle.Create(point1, point2, point3)
      # EndBlock

      # Solidify Sketch
      mode = InteractionMode.Solid
      result = ViewHelper.SetViewMode(mode, None)
      # EndBlock

      # Extrude 1 Face
      selection = FaceSelection.Create(GetRootPart().Bodies[1].Faces[0])
      options = ExtrudeFaceOptions()
      options.ExtrudeType = ExtrudeType.ForceCut
      result = ExtrudeFaces.Execute(selection, MM(-1*Parameters.H), options)
      #

      # Create/Edit Mesh
      options = CreateMeshOptions()
      options.SolidElementShape = ElementShapeType.Hexahedral
      options.SurfaceElementShape = ElementShapeType.QuadDominant
      options.BlockingType = BlockingDecompositionType.BoundingBox
      bodySelection = BodySelection.Create(GetRootPart().Bodies[0])
      sweepFaceSelection = Selection.Empty()
      result = CreateMesh.Execute(bodySelection, sweepFaceSelection, options)
      # EndBlock

    • Charudatta Bandgar
      Subscriber

      Hello LD Gu

      Let me check.

    • Charudatta Bandgar
      Subscriber

      Hello  LD Gu

      Are you using SpaceClaim meshing?

      Regards.

      • evan_gu
        Subscriber

        this is  the error pageCharudatta Bandgar 

    • evan_gu
      Subscriber

      yes

      • Charudatta Bandgar
        Subscriber

        Hello LD Gu 

        SpaceClaim meshing module is not included in the Discovery package. I think it is part of the SpaceClaim that comes with workbench, and not Discovery SpaceClaim. 

        Regarding your question on Ansys SpaceClaim meshing or workbench, please post it on ANSYS Customer Portal or Ansys Learning Forum based on the type of license that you have, so that experts in the domain would be able to help you better. This ANSYS Discovery Community Forum is intended for seeking help on ANSYS Discovery products, and experts on the respective product will be able to help you better there.

        Thank you for your understanding!

    • evan_gu
      Subscriber

      thinks!

Viewing 6 reply threads
  • The topic ‘Error with Spaceclaim scripting’ is closed to new replies.