Selecting midPoint of Edges API VB.NET

Selecting midPoint of Edges API VB.NET

florian_wenzel
Advocate Advocate
612 Views
8 Replies
Message 1 of 9

Selecting midPoint of Edges API VB.NET

florian_wenzel
Advocate
Advocate

Hi,

 

Inventor 2022

API Visual Studio

 

i try to create a WorkPlane AddByPlaneAndPoint.

The Tricky thing is, that i want to select the MidPoint From Edges.

I have't find this.

florianwenzelEJNZZ_2-1651491900025.png

 

 

This is my simple Code to Create  WorkPlane AddByPlaneAndPoint.

With this Code is possible only to Select a End or Start Point.

Code:

 

 

 

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

Module CommandFunctionButton_07
    Public Sub CommandFunctionfweButton_07()

        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 oWorkPointCenter As Vertex
        oWorkPointCenter = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kAllPointEntities, "Pick a Points1")


        Dim oFaceTang As Face = CType(g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a Face1"), Face)

        Dim oWorkPlaneCenter As WorkPlane
        oWorkPlaneCenter = oCompDef.WorkPlanes.AddByPlaneAndPoint(oFaceTang, oWorkPointCenter, False)

    End Sub
End Module

 

 

 

I have't find this in Object and Enums.

What is the Command for This?

 

Thanks for any Sugestion.

 

0 Likes
Accepted solutions (1)
613 Views
8 Replies
Replies (8)
Message 2 of 9

dalton98
Collaborator
Collaborator

This Worked

oWorkPointCenter = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Pick an Edge")

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

oDoc.ComponentDefinition.WorkPoints.AddByMidPoint(oWorkPointCenter)
Message 3 of 9

florian_wenzel
Advocate
Advocate

Hi,

 

still dont work 

Wrong Parameter

 

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

Module CommandFunctionButton_07
    Public Sub CommandFunctionfweButton_07()

        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 oWorkPointCenter As Edge
        oWorkPointCenter = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Pick a Edge")

        oPartDoc.ComponentDefinition.WorkPoints.AddByMidPoint(oWorkPointCenter)
        oPartDoc.Update()


        Dim oFacePlane As Face = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a Face1")

        Dim oWorkPlaneCenter As WorkPlane
        oWorkPlaneCenter = oCompDef.WorkPlanes.AddByPlaneAndPoint(oFacePlane, oWorkPointCenter, False)

    End Sub
End Module

florianwenzelEJNZZ_0-1651497436660.png

 

florianwenzelEJNZZ_1-1651497486108.png

 

0 Likes
Message 4 of 9

dalton98
Collaborator
Collaborator
Dim oPoint as WorkPoint
oPoint
= oPartDoc.ComponentDefinition.WorkPoints.AddByMidPoint(oWorkPointCenter)

oWorkPlaneCenter = oPartDoc.ComponentDefinition.WorkPlanes.AddByPlaneAndPoint(oFace, oPoint)

You need to create the midpoint as a variable.

0 Likes
Message 5 of 9

florian_wenzel
Advocate
Advocate

Still not Working:

 

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

Module CommandFunctionButton_07
    Public Sub CommandFunctionfweButton_07()

        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 oWorkPointCenter As Edge
        oWorkPointCenter = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Pick a Edge")

        Dim oPoint As Inventor.Point
        oPoint = oPartDoc.ComponentDefinition.WorkPoints.AddByMidPoint(oWorkPointCenter, False)



        oPartDoc.ComponentDefinition.WorkPoints.AddByMidPoint(oWorkPointCenter)
        oPartDoc.Update()


        Dim oFacePlane As Face = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a Face1")

        Dim oWorkPlaneCenter As WorkPlane
        oWorkPlaneCenter = oCompDef.WorkPlanes.AddByPlaneAndPoint(oFacePlane, oPoint, False)

    End Sub
End Module

 

Error:

Object cannot converted in Inventor.Point

florianwenzelEJNZZ_0-1651503059093.png

florianwenzelEJNZZ_1-1651503095522.png

 

The Point is, but than Crash.

 

 

0 Likes
Message 6 of 9

dalton98
Collaborator
Collaborator

MB its dimension the point as a 'WorkPoint' not  'Inventor.Point'

0 Likes
Message 7 of 9

florian_wenzel
Advocate
Advocate

hmm, what you mean with MB?

I dont understood, sorry 🙂

 

I dont know, why i  must select the Edge to get the midPoint.

Manually you are able to select directly the Point.

I think, it should be also able do this with API with Automatization.

 

But, i very glad that you try to help me.

Thanks

 

0 Likes
Message 8 of 9

dalton98
Collaborator
Collaborator
Accepted solution

Ok I rewrote it how you had it. was saying my bad for answering sloppily.

Module CommandFunctionButton_07
    Public Sub CommandFunctionfweButton_07()

        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 oEdge As Edge
        oEdge = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Pick an Edge1")
		
		Dim oWorkPointCenter As WorkPoint
		oWorkPointCenter = oCompDef.WorkPoints.AddByMidPoint(oEdge, True)

        Dim oFaceTang As Face = CType(g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a Face1"))

        Dim oWorkPlaneCenter As WorkPlane
        oWorkPlaneCenter = oCompDef.WorkPlanes.AddByPlaneAndPoint(oFaceTang, oWorkPointCenter, False)

    End Sub
End Module

 

Message 9 of 9

florian_wenzel
Advocate
Advocate

Thanks!

its Working

florianwenzelEJNZZ_0-1651505006245.png

 

0 Likes