Inventor Customization

Inventor Customization

Reply
Active Contributor
MikeGillam5072
Posts: 38
Registered: ‎12-22-2009
Message 1 of 2 (190 Views)

adding a sub-component as a participant in an assembly feature in iLogic/API

190 Views, 1 Replies
04-27-2011 10:54 AM

Is there a trick to making a sub-component participate in a feature (ExtrudeFeature, SweepFeature, etc.)?

 

I've tried using the SweepFeature.AddParticipant(ComponentOccurrence) and ExtrudeFeature(ComponentOccurrence) functions, and both work fine when the ComponentOcurrence is a direct component of the assembly.

 

However, if I explode down another level, and pass in a ComponentOccurrence for a sub-component, I get an INVALID_ARG error.

 

I can do this manually in the Inventor model browser.

 

I worked around the problem by collapsing the assembly structure, but now my customer is pressing me "to do it right".

 

If necessary, I'll reconstruct a the code snippet that was failing.

 

Any help is appreciated.  thanks

Employee
yuhanzhang
Posts: 480
Registered: ‎01-06-2009
Message 2 of 2 (180 Views)

Re: adding a sub-component as a participant in an assembly feature in iLogic/API

04-27-2011 11:55 PM in reply to: MikeGillam5072

Below sample will show how to implement it:

 

Sub AddParticipantSample()
    ' New an assembly, place a sub-assembly which has two occurrences
    ' create an extrude feature on the first occurrence of the sub-assembly
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oExtrude As ExtrudeFeature
    Set oExtrude = oDoc.ComponentDefinition.Features.ExtrudeFeatures(1)
    
    Dim oOcc As ComponentOccurrence
    Set oOcc = oDoc.ComponentDefinition.Occurrences(1)
    
    Dim oSubOccProxy As ComponentOccurrenceProxy
    oOcc.CreateGeometryProxy oOcc.SubOccurrences(2), oSubOccProxy
    
    oExtrude.AddParticipant oSubOccProxy
End Sub

 You may want to see a topic in API document titled "Introduction to proxies", it will explain the concept of proxy. Hope this helps.



Rocky Zhang
Inventor API
Manufacturing Solutions
Autodesk, Inc.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.