Cancel
Showing results for 
Search instead for 
Did you mean: 

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

Pioneer
Pioneer

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?

ST09 MP12 - DBSolid Edge R16 2.4 - Windows 10 x64
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
SE ST10

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

Pioneer
Pioneer

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.

ST09 MP12 - DBSolid Edge R16 2.4 - Windows 10 x64