API Select Points from 3D Modell

API Select Points from 3D Modell

florian_wenzel
Advocate Advocate
428 Views
3 Replies
Message 1 of 4

API Select Points from 3D Modell

florian_wenzel
Advocate
Advocate

Hi,

'Inventor 2022 & Visual Studio

 

i try to create a WorkPlane with 3 Points.

AddByThreePoints

 

The 3 Points, i want to pick up from 3D Modell.

The Final Result should look like This:

florianwenzelEJNZZ_0-1649007586351.png

 

 

So i  want to select 3 Points:

Edge EndPoint or EdgeMidPoint etc...

florianwenzelEJNZZ_1-1649007729956.png

 

But it dosent work.

This is my Code:

 

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


Module CommandFunctionButton_01
Public Sub CommandFunctionfweButton_01()

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 oWorkPoint1 As Object
oWorkPoint1 = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPointFilter, "Pick a Points1")

Dim oWorkPoint2 As Object
oWorkPoint2 = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPointFilter, "Pick a Points2")

Dim oWorkPoint3 As Object
oWorkPoint3 = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPointFilter, "Pick a Points3")


Dim oWorkPlaneA1 As WorkPlane
oWorkPlaneA1 = oCompDef.WorkPlanes.AddByThreePoints(oWorkPoint1, oWorkPoint2, oWorkPoint3, True)

 


End Sub
End Module

florianwenzelEJNZZ_0-1649009440159.png

 

 

In Enums / SelectionFilterEnum Enumerator which Methods should i use?

I want simple select Point on: Edge EndPoint or EdgeMidPoint etc...

 

i'm not able to Pick up any Points:

florianwenzelEJNZZ_0-1649008299243.png

 

 

How can i do this.

 

Thanks for any Suggestion.

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

A.Acheson
Mentor
Mentor

It looks like the boolean construction plane is at fault here. Changing it to false allows the plane to be shown visibly. Boolean of true creates a construction plane that is not shown in the browser or graphically. See API help description here. 

 

Dim oWorkPlaneA1 As WorkPlane
oWorkPlaneA1 = oCompDef.WorkPlanes.AddByThreePoints(oWorkPoint1, oWorkPoint2, oWorkPoint3, False)

AAcheson_0-1649010961902.png

You can check the type with the Construction property. 

Dim oWorkPlaneA1 As WorkPlane
oWorkPlaneA1 = oCompDef.WorkPlanes.AddByThreePoints(oWorkPoint1, oWorkPoint2, oWorkPoint3, true)

MessageBox.Show(oWorkPlaneA1.Construction, "Title")

 

Using sketch points also works so you can skip the WorkPoint creation.

oPoint1 = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kSketchPointFilter, "Pick a Points1")

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 4

JelteDeJong
Mentor
Mentor
Accepted solution

Getting the midpoint is very difficult (if possible at all for your purpose). Have a look at this post.  But if you can live with 3 vertexes/points then you can do it like this.

 

Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition

Dim oWorkPoint1 As Vertex = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kAllPointEntities, "Pick a Points1")
Dim oWorkPoint2 As Vertex = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kAllPointEntities, "Pick a Points2")
Dim oWorkPoint3 As Vertex = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kAllPointEntities, "Pick a Points3")

Dim oWorkPlaneA1 As WorkPlane = oCompDef.WorkPlanes.AddByThreePoints(oWorkPoint1, oWorkPoint2, oWorkPoint3, False)

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 4 of 4

florian_wenzel
Advocate
Advocate

Hi,

Thanks 🙂

Yeah, it should be a Vertex, and False as you mentioned before.

 

You Right, its very Tricky to select a MidPoint, but i will try it.

 

The EndPoint works Fine!

 

florianwenzelEJNZZ_0-1649015617645.png

florianwenzelEJNZZ_1-1649015706524.png

 

0 Likes