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
Thanks for Any Suggestion
Solved! Go to Solution.
Solved by Lucas.dolinarVFXZU. Go to 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
🙂
can you tell me what you're doing with that patch?
is it for some calculations?
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
no, i meant:
why do you need those patches?
does some machine need that? or some other reason?
actualy, to make Holes in other Surface, with ThicknesFeature Symetric, and then Bool Diference Cut etc...
its a Fragment of a Biger Code
Can't find what you're looking for? Ask the community or share your knowledge.