iFeature, change affected SurfaceBody

iFeature, change affected SurfaceBody

cdellea
Enthusiast Enthusiast
617 Views
4 Replies
Message 1 of 5

iFeature, change affected SurfaceBody

cdellea
Enthusiast
Enthusiast

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

0 Likes
618 Views
4 Replies
Replies (4)
Message 2 of 5

andy
Explorer
Explorer

Hi,

 

Did you find a solution for this? I'm struggling with the same issue

 

Thanks,

 

Andy

0 Likes
Message 3 of 5

cdellea
Enthusiast
Enthusiast

Hi Andy,

 

Unfortunately, I havent found any way of making this working. I submitted a support request to ADN (Autodesk developer network) and they admitted this is a "bug" in the API.

 

For your information, change request as been recorded by Autodesk :

 

The Change Request for this is: ID:INVGEN - 58260 - "18360765 - Setting affected bodies to iFeature through Inventor API".

 

Cheers,

 

Colin

Message 4 of 5

JelteDeJong
Mentor
Mentor

There might be a workaround by hiding all bodies except the one that is affected. Have a look at this thread.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 5

cdellea
Enthusiast
Enthusiast

Hello,

 

Thank you very much for your answer.

 

Unfortunately, this project was abandoned due to the limitation / bug. So I wont be able to test and validate your proposition (even if it seems working).

0 Likes