Bulge feature addin by Brian Ekins. How to do it? (vb.net)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello)
I've been learning Inventor API for a while now and have made some progress, but sometimes there are tasks where you don't even know where to start.
I watched Brian Ekins' workshop and was very impressed with his "Bulge feature". It's there on 1:19:15:
https://www.autodesk.com/autodesk-university/class/iLogic-and-Inventor-API-2016#video
I was very impressed with this demonstration and wanted to make the same feature, like, reverse engineer it.
I understand how to do it in GUI: patch with tangent option and then replace face command. But to do it with code, I can't imagine. I especially liked the interactivity: controlling the tangency coefficient with the mouse.
I try write some code (as an external rule for beginning). I managed how to create a patch feature. But there is a problem with the replace face feature: in Inventor 2023 there is no API option to create this operation:
ReplaceFaceFeatures.CreateDefinition
and
ReplaceFaceFeatures.Add(oReplaceFaceDef)
This functionality appeared only in Inventor 2024..... Brian's video is old, so the problem still has a solution, it's just that my approach is probably wrong. And I still have no idea how he was able to control the degree of tangency with the mouse in real time.
My code is below. Please help 😃 There is no commercial gain here, just my research interest.
Dim oDoс As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oDoс.ComponentDefinition
' pick a face
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select planar Face")
' Collect up the edges to create boundary patch.
Dim oEdgeColl As EdgeCollection = ThisApplication.TransientObjects.CreateEdgeCollection
Dim oEdge As Edge
For Each oEdge In oFace.Edges
oEdgeColl.Add(oEdge)
Next
' Create a boundary patch definition based on edges of the selected face.
Dim oBoundaryPatchDef As BoundaryPatchDefinition = oCompDef.Features.BoundaryPatchFeatures.CreateBoundaryPatchDefinition
oBoundaryPatchDef.BoundaryPatchLoops.Add(oEdgeColl)
'Set the conditions on each edge to be tangent.
For Each oEdge In oEdgeColl
oBoundaryPatchDef.BoundaryPatchLoops.Item(1).SetBoundaryCondition(oEdge, kTangentBoundaryPatchCondition)
oBoundaryPatchDef.BoundaryPatchLoops.Item(1).SetBoundaryTangentWeight(oEdge, 0.9)
Next
' Create the boundary patch feature based on the definition.
Dim oBoundaryPatch As BoundaryPatchFeature = oCompDef.Features.BoundaryPatchFeatures.Add(oBoundaryPatchDef)
' Create existing faces collection obj
Dim oExistFaceColl As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection
oExistFaceColl.Add(oFace)
' Create new faces collection obj
Dim oNewFaceColl As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection
oNewFaceColl.Add(oCompDef.Features.BoundaryPatchFeatures.Item(1).Faces.Item(1))
' create replace face feature
Dim oReplaceFaceDef As ReplaceFaceFeature = oCompDef.Features.ReplaceFaceFeatures.CreateDefinition(oExistFaceColl, oNewFaceColl)
Dim oReplaceFace As BoundaryPatchFeature = oCompDef.Features.ReplaceFaceFeatures.Add(oReplaceFaceDef)