Inventor API Boundary patch for Each Inside Edgeloop

Inventor API Boundary patch for Each Inside Edgeloop

florian_wenzel
Advocate Advocate
543 Views
8 Replies
Message 1 of 9

Inventor API Boundary patch for Each Inside Edgeloop

florian_wenzel
Advocate
Advocate

Hi,

Inventor 2022

API VB.NET Visual Studio

 

I try to make a BoundaryPatch for Each inside Edgeloop from a Face.

I make only 1 Surrafce. How to do this for each Inside Edgeloop ?

 

Where is the problem?

This is my Code:

 

 

    Public Sub CommandFunctionfweButton_13()

        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 oFaceTopBody As Face = CType(g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a FaceTopBody"), Face)
        Dim oEdge As Edge
        Dim oEdgeColl As EdgeCollection = oTO.CreateEdgeCollection


        If oFaceTopBody IsNot Nothing Then

            For Each oEdgeloop As EdgeLoop In oFaceTopBody.EdgeLoops
                If Not oEdgeloop.IsOuterEdgeLoop Then
                    For Each oEdge In oEdgeloop.Edges
                        oEdgeColl.Add(oEdge)
                    Next

                    Dim oBoundaryPatchDef As BoundaryPatchDefinition
                    oBoundaryPatchDef = oCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition

                    Call oBoundaryPatchDef.BoundaryPatchLoops.Add(oEdgeColl)

                    For i = 1 To oEdgeColl.Count
                        For Each oEdge In oEdgeColl
                            Call oBoundaryPatchDef.BoundaryPatchLoops.Item(i).SetBoundaryCondition(oEdge, BoundaryPatchConditionEnum.kFreeBoundaryPatchCondition)
                        Next
                        Dim oBoundaryPatch As BoundaryPatchFeature
                        oBoundaryPatch = oCompDef.Features.BoundaryPatchFeatures.Add(oBoundaryPatchDef)
                    Next

                End If
            Next
        End If
    End Sub

 

 

 

 

Second Code:

 

 

    Public Sub CommandFunctionfweButton_14()

        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 oFaceTopBody As Face = CType(g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a FaceTopBody"), Face)
        Dim oEdge As Edge
        Dim oEdgeColl As EdgeCollection = oTO.CreateEdgeCollection


        If oFaceTopBody Is Nothing Then Return

        For Each oEdgeloop As EdgeLoop In oFaceTopBody.EdgeLoops
            If oEdgeloop.IsOuterEdgeLoop Then Continue For

            For Each oEdge In oEdgeloop.Edges

                oEdgeColl.Add(oEdge)
            Next

            Dim oBoundaryPatchDef As BoundaryPatchDefinition
            oBoundaryPatchDef = oCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition

            Call oBoundaryPatchDef.BoundaryPatchLoops.Add(oEdgeColl)

            For Each oEdge In oEdgeColl
                Call oBoundaryPatchDef.BoundaryPatchLoops.Item(1).SetBoundaryCondition(oEdge, BoundaryPatchConditionEnum.kFreeBoundaryPatchCondition)
            Next

            Dim oBoundaryPatch As BoundaryPatchFeature
            oBoundaryPatch = oCompDef.Features.BoundaryPatchFeatures.Add(oBoundaryPatchDef)


        Next


    End Sub

 

 

 

Only 1 Surface

florian_wenzel_0-1662033994528.png

 

 

 

Thanks for Any Suggestion

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

Lucas.dolinarVFXZU
Collaborator
Collaborator
Accepted solution

from a quick glance, looks like you are not clearing your edge collection...

try either deleting it after the patch, or limit it's scope to the For-Loop

Message 3 of 9

florian_wenzel
Advocate
Advocate

Hi Lucas.dolinarVFXZU.

 

Thanks for Solution.

it Works 🙂

florian_wenzel_0-1662039232541.png

 

 

 

Message 4 of 9

Lucas.dolinarVFXZU
Collaborator
Collaborator

🙂

can you tell me what you're doing with that patch?
is it for some calculations?

Message 5 of 9

florian_wenzel
Advocate
Advocate

Hi,

 

exactly what you said before.

oEdgeColl.Clear

 

 

Code:

Imports System.Runtime.InteropServices
Imports Inventor
Imports Microsoft.Win32
Imports System.Collections.Generic
Imports System.Linq
Imports System.IO

Module CommandFunctionButton_14


    Public Sub CommandFunctionfweButton_14()

        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 oFaceTopBody As Face = CType(g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a FaceTopBody"), Face)
        Dim oEdge As Edge
        Dim oEdgeColl As EdgeCollection = oTO.CreateEdgeCollection
        Dim oBoundaryPatch As BoundaryPatchFeature


        If oFaceTopBody Is Nothing Then Return

        For Each oEdgeloop As EdgeLoop In oFaceTopBody.EdgeLoops
            If oEdgeloop.IsOuterEdgeLoop Then Continue For

            For Each oEdge In oEdgeloop.Edges

                oEdgeColl.Add(oEdge)
            Next

            Dim oBoundaryPatchDef As BoundaryPatchDefinition
            oBoundaryPatchDef = oCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition

            Call oBoundaryPatchDef.BoundaryPatchLoops.Add(oEdgeColl)

            For Each oEdge In oEdgeColl
                Call oBoundaryPatchDef.BoundaryPatchLoops.Item(1).SetBoundaryCondition(oEdge, BoundaryPatchConditionEnum.kFreeBoundaryPatchCondition)
            Next


            oBoundaryPatch = oCompDef.Features.BoundaryPatchFeatures.Add(oBoundaryPatchDef)

            oEdgeColl.Clear()

        Next
0 Likes
Message 6 of 9

Lucas.dolinarVFXZU
Collaborator
Collaborator

no, i meant:
why do you need those patches?

does some machine need that? or some other reason?

Message 7 of 9

florian_wenzel
Advocate
Advocate

actualy, to make Holes in other Surface, with ThicknesFeature Symetric,  and then Bool Diference Cut etc...

its a Fragment of a Biger Code

0 Likes
Message 8 of 9

Lucas.dolinarVFXZU
Collaborator
Collaborator

Ah, i see.
professional automation 🙂

 


thx for answering

0 Likes
Message 9 of 9

florian_wenzel
Advocate
Advocate
Hi,
i try my best 🙂
step by step, it's gonna be better someday.

0 Likes