IntersectWithCurve Get Accses to Created Point2d from Object Enumaerator

IntersectWithCurve Get Accses to Created Point2d from Object Enumaerator

florian_wenzel
Advocate Advocate
349 Views
2 Replies
Message 1 of 3

IntersectWithCurve Get Accses to Created Point2d from Object Enumaerator

florian_wenzel
Advocate
Advocate

Hi,

 

Inventor 2022

API Visual Studio VB.NET

 

i Try to make a IntersectWithCurve (Sketchline and SketchArc, for example) and Create a Point2d.

How can i get the Point2d?

 

Imports System.Runtime.InteropServices
Imports Inventor
Imports Microsoft.Win32

Module CommandFunctionButton_09
    Public Sub CommandFunctionfweButton_09()

        Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
        Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
        Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
        Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry


        Dim oWorkSketch01 As PlanarSketch
        oWorkSketch01 = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3), False)

        Dim oWorkPoint01 As Point2d
        oWorkPoint01 = oTG.CreatePoint2d(0, 0)

        Dim oWorkPoint02 As Point2d
        oWorkPoint02 = oTG.CreatePoint2d(0, 10)

        Dim oWorkPoint03 As Point2d
        oWorkPoint03 = oTG.CreatePoint2d(-5, 5)

        Dim oWorkPoint04 As Point2d
        oWorkPoint04 = oTG.CreatePoint2d(5, 5)

        Dim oWorkPoint05 As Point2d
        oWorkPoint05 = oTG.CreatePoint2d(0, 8)

        Dim oWorkPoint06 As Point2d
        oWorkPoint06 = oTG.CreatePoint2d(0, 6)

        Dim oSketchLine01 As SketchLine
        oSketchLine01 = oWorkSketch01.SketchLines.AddByTwoPoints(oWorkPoint01, oWorkPoint02)

        Dim oSketchArc01 As SketchArc
        oSketchArc01 = oWorkSketch01.SketchArcs.AddByThreePoints(oWorkPoint03, oWorkPoint05, oWorkPoint04)

        Dim oLineSegment01 As LineSegment2d
        oLineSegment01 = oSketchLine01.Geometry

        oLineSegment01.IntersectWithCurve(oSketchArc01,)


        Dim oPointObj As ObjectCollection
        oPointObj = oTO.CreateObjectCollection

        Call oPointObj.Add()

        Dim oPointsCross01 As Point2d

        Dim oSketchLine02 As SketchLine
        oSketchLine02 = oWorkSketch01.SketchLines.AddByTwoPoints(oWorkPoint03, oPointsCross01)



    End Sub
End Module

 

Thanks for any Suggestion

 

 

 

0 Likes
Accepted solutions (1)
350 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor
Accepted solution

In this post is described how to look to the Inventor API object tree.

Here is described how the LineSegment.IntersectWithCurve method works.

You need to set the method result to new variable and then you can iterate this collection or pick some objet from it.

 

Dim oLineSegment01 As LineSegment2d
oLineSegment01 = oSketchLine01.Geometry

Dim pointsCollection As ObjectsEnumerator = oLineSegment01.IntersectWithCurve(oSketchArc01.Geometry)

'Iterate all points
For Each point As Point2d In pointsCollection
	'Do something with point
Next

'Get first point
Dim firstPoint As Point2d = pointsCollection(1)

 

 

Message 3 of 3

florian_wenzel
Advocate
Advocate

Hi,

 

Thanks very much!

0 Likes