BoundaryPatch from Sketch3D with more Loops

BoundaryPatch from Sketch3D with more Loops

florian_wenzel
Advocate Advocate
500 Views
6 Replies
Message 1 of 7

BoundaryPatch from Sketch3D with more Loops

florian_wenzel
Advocate
Advocate

Hi,

 

Inventor 2022

VB.NET Visual Studio

 

i try to make a Face with BoundaryPatch Feature.

I want to use a Sketch3D with few Loops, it works with GUI.

My Question is how to get each loop (Path or Profile)  to reach the Goal?

florian_wenzel_0-1674750824105.png

florian_wenzel_1-1674750841271.png

florian_wenzel_2-1674750850656.png

 

How to Get info How many Loops in a Sketch3D i have ?

 

 

This is my Code: in Progres

 

    Public Sub CommandFunctionfweButton_34()

        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 oBRep As TransientBRep = g_inventorApplication.TransientBRep

        Dim oSketch3D As Sketch3D = oCompDef.Sketches3D.Item(1)

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

        For i = 1 To oSketch3D.SketchEntities3D.Count


        Next

        Dim oBoudaryPatchLoopOutside As BoundaryPatchLoop = oBoudaryPatchDef.BoundaryPatchLoops.Add()
        Dim oBoudaryPatchLoopInside As BoundaryPatchLoop = oBoudaryPatchDef.BoundaryPatchLoops.Add()


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


    End Sub

 

 

Thanks for Any Suggestion

0 Likes
Accepted solutions (2)
501 Views
6 Replies
Replies (6)
Message 2 of 7

florian_wenzel
Advocate
Advocate

Hi,

 

How to get the Profiles3D?

    Public Sub CommandFunctionfweButton_20()

        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 oBRep As TransientBRep = g_inventorApplication.TransientBRep

        Dim oSketch3D As Sketch3D = oCompDef.Sketches3D.Item(1)

        Dim oProfiles As List(Of Profile3D) = New List(Of Profile3D)()
        oProfiles.Add(oSketch3D.Profiles3D.AddClosed)


        Dim oProfile As Profile3D = oProfiles.Item(0)

        Dim oBoudaryPatchDef As BoundaryPatchDefinition = oCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition
        Dim oBoudaryPatchLoopOutside As BoundaryPatchLoop = oBoudaryPatchDef.BoundaryPatchLoops.Add(oProfile)

        oBoudaryPatchDef.BoundaryPatchLoops.Item(1).SetBoundaryCondition(oProfile, BoundaryPatchConditionEnum.kTangentBoundaryPatchCondition)
        Dim oBoundaryPatch As BoundaryPatchFeature = oCompDef.Features.BoundaryPatchFeatures.Add(oBoudaryPatchDef)


    End Sub

 

I dont understand the Method "oBoudaryPatchDef"

Inventor 2022 Help | BoundaryPatchDefinition Object | Autodesk

 

 

0 Likes
Message 3 of 7

florian_wenzel
Advocate
Advocate

Hi Autodesk Inventor Developers,

@adam.nagy 

@CGBenner 

@MjDeck 

@AlexKorzun 

 

 

How to get information, how many loops is in 3D Sketch.

How to do this with API?

Is this, what im asking in my First Post in This Topic possible with API?

0 Likes
Message 4 of 7

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

I always suggest people that they investigate object hierarchy in VBA: 
https://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html 

 

In case of Sketch3D the Profile3D you create for it will include ProfilePath3Ds

adamnagy_0-1675167252299.png

 



Adam Nagy
Autodesk Platform Services
Message 5 of 7

florian_wenzel
Advocate
Advocate

Hi @adam.nagy 

 

sorry, i need stil help.

I was bussy with other things.

Where is the Problem?

 

ok, the Profiles are ok, and it works with Each Profile separately, but How to get the Surface with Holes?

Do i still need something ?

 

In this Case, the First Profile is the Outside one.

 

 

 

 

    Public Sub CommandFunctionfweButton_()

        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 oBRep As TransientBRep = g_inventorApplication.TransientBRep

        Dim oSketch3D As Sketch3D = oCompDef.Sketches3D.Item(1)
        Dim oProfiles As Profile3D = oSketch3D.Profiles3D.AddClosed()
        Dim oObjCollProfile As ObjectCollection = oTO.CreateObjectCollection
        Dim oBoudaryPatchDef As BoundaryPatchDefinition = oCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition

        MsgBox("Profiles = " & oProfiles.Count)



        For i = 1 To oProfiles.Count

            oObjCollProfile.Clear()
            Dim oProfilePath As ProfilePath3D = oProfiles.Item(i)
            MsgBox("ProfilesPath = " & oProfilePath.Count)
            For j = 1 To oProfilePath.Count
                Dim oProfileEntity As ProfileEntity3D = oProfilePath.Item(j)
                Dim oCurve As SketchEntity3D = oProfileEntity.SketchEntity
                oObjCollProfile.Add(oCurve)
            Next

            Call oBoudaryPatchDef.BoundaryPatchLoops.Add(oObjCollProfile)

        Next

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





    End Sub

 

 

 

 

0 Likes
Message 6 of 7

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

It's much easier to test things in VBA - that's what I do as well. There you can examine objects as you step through the code. As shown in the picture you can see that the BoundaryPatchDefinition ends up with just a single SketchCircle3D in each BoundaryPatchLoop

 

adamnagy_0-1675334094496.png

This suggests that BoundaryPatchLoops.Add() does not copy the collection you pass in, but simply adds a reference to it. And so, you should create a new collection object for each loop:

Public Sub CommandFunctionfweButton_()
    Dim g_inventorApplication As Application
    Set g_inventorApplication = ThisApplication

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

    Dim oSketch3D As Sketch3D
    Set oSketch3D = oCompDef.Sketches3D.Item(1)
    Dim oProfile As Profile3D
    Set oProfile = oSketch3D.Profiles3D.AddClosed()
    
    Dim oBoudaryPatchDef As BoundaryPatchDefinition
    Set oBoudaryPatchDef = oCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition

    Dim oProfilePath As ProfilePath3D
    For Each oProfilePath In oProfile
        Dim oObjCollProfile As ObjectCollection
        Set oObjCollProfile = oTO.CreateObjectCollection

        Dim oProfileEntity As ProfileEntity3D
        For Each oProfileEntity In oProfilePath
            Dim oCurve As SketchEntity3D
            Set oCurve = oProfileEntity.SketchEntity
            Call oObjCollProfile.Add(oCurve)
        Next

        Call oBoudaryPatchDef.BoundaryPatchLoops.Add(oObjCollProfile)
    Next

    Dim oBoundaryPatch As BoundaryPatchFeature
    Set oBoundaryPatch = oCompDef.Features.BoundaryPatchFeatures.Add(oBoudaryPatchDef)
End Sub

This worked:

adamnagy_1-1675334442520.png 



Adam Nagy
Autodesk Platform Services
Message 7 of 7

florian_wenzel
Advocate
Advocate

Hi @adam.nagy ,

 

Thanks very Much, the Boundary Feature Works.

 

ok, got it!

no further investigation