AnsweredAssumed Answered

How can I fix points in 3D Sketches?

Question asked by Steven Boege on Mar 27, 2020
Latest reply on Mar 27, 2020 by Josh Brady

I'm trying to extend the macro _FullyDefineSketch to work with 3D Sketches.  I managed to make a version that gets points in a 3D Sketch and lists their coordinates.  But I can't figure out how to fix them.  The macro fixes the 2D Sketch points in the attached .sldprt file, but not the 3D Sketch points.  Some files have many 3D Sketches, so manually editing sketches is impractical.

 

If FeatType = "3DProfileFeature" Then
   Set swSketch = Feature.GetSpecificFeature2
   longSketchStatus = swSketch.GetConstrainedStatus()
   If longSketchStatus = 2 Then
      Part.ClearSelection2 True   
      boolstatus = Part.Extension.SelectByID2(FeatName, "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
      Part.EditSketch
      Part.ClearSelection2 True
      boolstatus = Part.Extension.SelectByID2("Point1@Origin", "EXTSKETCHPOINT", 0, 0, 0, True, 6, Nothing, 0)
      longstatus = Part.SketchManager.FullyDefineSketch(1, 1, 1023, 1, 1, Nothing, -1, Nothing, 1, -1)

      'Execerpted from https://help.solidworks.com/2018/english/api/sldworksapi/Get_Sketch_Points_Example_VB.htm
      sketchPointArray = swSketch.GetSketchPoints2
      For ii = 0 To UBound(sketchPointArray)      
          Set swSketchPoint = sketchPointArray(i)
          ' Get the x & y coordinates      
          Part.SketchAddConstraints "sgFIXED"
         xValue = sketchPointArray(ii).X
          yValue = sketchPointArray(ii).Y
          Debug.Print "Sketch point coordinates: "
          Debug.Print " x: " & xValue
          Debug.Print " y: " & yValue
          Debug.Print " "
      Next ii
       Part.ClearSelection2 True
       Part.SketchManager.InsertSketch True
      Part.ClearSelection2 True
   End If
End If

Outcomes