iFeature, change affected SurfaceBody
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I am trying to change, with VBA code, the affected bodies of an iFeature :
Sub ChangeiFeatureAffectedBody()
Dim oDef As PartComponentDefinition
Set oDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oBody As SurfaceBody, oBodies As ObjectCollection
Set oBodies = ThisApplication.TransientObjects.CreateObjectCollection
Call oBodies.Add(oDef.SurfaceBodies(2)) '<-- change with 1 or 2
Dim oiFeature As iFeature
Set oiFeature = oDef.Features("TROU_SERTISSAGE:1")
Call oiFeature.SetAffectedBodies(oBodies)
Call ThisApplication.ActiveDocument.Update
End Sub
Even if this piece of code is correctly executed (no exception), the affected bodies of the iFeature does not change. Do you have any idea of what's going wrong ?
In attachment, you will find a part made of 2 solid bodies. It contains as well an iFeature and the VBA code. The iFeature should create a hole. As it is configured in the part, no hole is created because the selection (solid selected does not match with the point and the plane selected), but this is on purpose. So, changing the affected surface body with the VBA code should make the hole "appear" (as then the selected body does match the point and the plane). But this is not working.
After running the VBA code, if I look with a spy the iFeature object, I can see that the "SurfaceBodies" property of the object does not change. It stills contains the same solid body as before the code is run.
Any help would be much appreciated.
Thank you,
Colin