Boundary patch with guide rails using VBA (API)

Boundary patch with guide rails using VBA (API)

Anonymous
Not applicable
2,062 Views
9 Replies
Message 1 of 10

Boundary patch with guide rails using VBA (API)

Anonymous
Not applicable

Hello everybody.

 

I have this Surface:

I don't have any problem with the code until this point, but I can not find any example or guide to make a Boundary patch with guide rails. What I want is to get this Surface:

 

 

 

Could anyone help me with this code using boundary patch operation WITH GUIDE RAILS?
I need examples, just to have an idea about how to programm that operation.
Thanks!
 
PD:
 
Here you are a Little of my code:
 

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

        
        Dim oProfileLine As SketchLine
        Dim oPath As Path

        For Each oProfileLine In sketchXY.SketchLines
            oPath = partDef.Features.CreatePath(oProfileLine)
            Call oBoundaryPatchDef.BoundaryPatchLoops.Add(oPath)
        Next

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

      

0 Likes
Accepted solutions (1)
2,063 Views
9 Replies
Replies (9)
Message 2 of 10

Xun.Zhang
Alumni
Alumni

Hi @YuhanZhang, Could you help shed some lights here?

Thanks!


Xun
Message 3 of 10

YuhanZhang
Autodesk
Autodesk

Seems I could not see your pictures(not sure if others can see them or not), can you create a Word document to demonstrate the problem?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 4 of 10

Anonymous
Not applicable

OK, I will check

0 Likes
Message 5 of 10

Anonymous
Not applicable

I had the same problem with Mozilla FireFox browser. I just had to wait some time and then I could watch the pictures. If problem persists, please tell me.

 

Here I attach the pictures in the order specified in the post.

fig 1.png

fig 2.png

fig 3.png

kelly.young has embedded your images for clarity.

0 Likes
Message 6 of 10

Anonymous
Not applicable

Thanks for your help, by the way 🙂

0 Likes
Message 7 of 10

YuhanZhang
Autodesk
Autodesk
Accepted solution

If the second sketch has a sketch arc and control point spline, then you can try below VBA sample:

 

Sub CreateBPWithGuiderail()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSk1 As PlanarSketch, oSk2 As PlanarSketch
    Set oSk1 = oDoc.ComponentDefinition.Sketches(1)
    Set oSk2 = oDoc.ComponentDefinition.Sketches(2)
    
    Dim oProfile1 As Profile
    Set oProfile1 = oSk1.Profiles.AddForSurface
    
    Dim oBPDef1 As BoundaryPatchDefinition
    Dim oBP1 As BoundaryPatchFeature
    
    Set oBPDef1 = oDoc.ComponentDefinition.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition
    oBPDef1.BoundaryPatchLoops.Add oProfile1
    Set oBP1 = oDoc.ComponentDefinition.Features.BoundaryPatchFeatures.Add(oBPDef1)
    
    Dim oBPDef2 As BoundaryPatchDefinition
    Dim oBP2 As BoundaryPatchFeature
    Dim oGuideRails As ObjectCollection
    
    Set oBPDef2 = oDoc.ComponentDefinition.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition
    oBPDef2.BoundaryPatchLoops.Add oBP1.Faces(1).EdgeLoops(1)
    Set oGuideRails = ThisApplication.TransientObjects.CreateObjectCollection
    Set oPath = oDoc.ComponentDefinition.Features.CreatePath(oSk2.SketchControlPointSplines(1))
    
    oGuideRails.Add oSk2.SketchArcs(1)
    oGuideRails.Add oSk2.SketchControlPointSplines(1)
    oBPDef2.GuideRails = oGuideRails
    
    Set oBP2 = oDoc.ComponentDefinition.Features.BoundaryPatchFeatures.Add(oBPDef2)
    
End Sub

Please let me if it works for you.

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 8 of 10

Anonymous
Not applicable

It worked perfect!

Thanks a lot!
You have helped me a lot!

0 Likes
Message 9 of 10

Anonymous
Not applicable

Hello @YuhanZhang may I ask you for help with this?

 

fwrf.JPG

 

I want to create boundary patches where these triangles are, to make a B-rep solid out of this 3D sketch via VBA. I don't know what path to give to the boundary patch definition model, for it to create the patches. 

 

I tried this, which didn't work:

 

Dim oLine3d As SketchLine3D
Dim oPath As Path
For Each oLine3d In oSketch3d.SketchLines3D
oPath = oDef.Features.CreatePath(oLine3d)
Call oBoundaryPatchDef.BoundaryPatchLoops.Add(oPath)
Next

 

 

Cheers,

Omar

 

0 Likes
Message 10 of 10

YuhanZhang
Autodesk
Autodesk

Can you provide your data so I can try with it? Don't share confidential data here.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes