API: Get the coordinates of the 3D line points a 3D sketch

Creator
Creator

I create a 3D sketch in an assembly document. In this sketch i draw simple line.

Now i would like have a access to the coordinates of the start- and endpoint of this line.

Is this possible, with the API?

2 REPLIES

Re: API: Get the coordinates of the 3D line points a 3D sketch

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi Obi8,

yes this possible.

 

Find the sketch in the AssemblyDocument Sketches3D list.

In the Sketch3D you find all the Line3D elements in the Lines3D list.

From the Line3D use the GetKeypointPosition() method with igSketch3DStartPoint or igSketch3DEndPoint as KeypointType paramter and it will return an array of Double with the x,y,z coordinates of the points.

 

regards

JB
VS2015, SE ST10

Re: API: Get the coordinates of the 3D line points a 3D sketch

Creator
Creator

Hello JB and thanks for your reply,

 

i have write this code:

 

Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objAssembly As SolidEdgeAssembly.AssemblyDocument = Nothing
Dim objSketches3d As SolidEdgePart.Sketches3D = Nothing
Dim objSketch3d As SolidEdgePart.Sketch3D = Nothing
Dim objLines3d As SolidEdgePart.Lines3D = Nothing
Dim objLine3d As SolidEdgePart.Line3D = Nothing
Dim i As Integer = 0
Dim coordinates(3) As Array

 

Try
  

objApplication = Marshal.GetActiveObject("SolidEdge.Application")

objAssembly = objApplication.ActiveDocument

objSketches3d = objAssembly.Sketches3D
objSketch3d = objSketches3d.Item(1)

objLines3d = objSketch3d.Lines3D
Console.WriteLine(objLines3d.Count)
objLine3d = objLines3d.Item(1)

objLine3d.GetKeypointPosition(SolidEdgePart.Sketch3DKeypointType.igSketch3DStartPoint, coordinates)


Console.WriteLine("Works!")
Console.ReadKey()


Catch ex As Exception
    Console.WriteLine(ex.Message)
    Console.ReadKey()
End Try

 

 

Now i would display the coordinates in the console. But it dont work. :-(

I get an error message in the console.

Type conflict. <exception of HRESULT: 0x80020005 <DISP_E_TYPEMISMATCH>>

 

Edit: Now it works! The type of coordinates was wrong. It must be Double.