Adding a sub assembly component to a main assembly extrude participants

Adding a sub assembly component to a main assembly extrude participants

Anonymous
Not applicable
518 Views
2 Replies
Message 1 of 3

Adding a sub assembly component to a main assembly extrude participants

Anonymous
Not applicable

I've used code similar to this and never had a problem with it. I've added some additional code to get to a sub assemblies components and I can't seem to get it to work. I'm not sure why I get the error I do. My first msgbox returns the correct count and my second returns the correct name, so I know it's getting the component, but I don't know why it can't add it as a participant.

 


Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition

Dim
BATCUT As ExtrudeFeature = oDef.Features.ExtrudeFeatures.Item("BATCUT") Dim EWL As ComponentOccurrence = oDef.Occurrences.ItemByName("FR END WALL LEFT WIZARD") Dim LPAT As OccurrencePattern = EWL.Definition.OccurrencePatterns.Item("BATTENS") 'MsgBox(LPAT.OccurrencePatternElements.Count) For Each LELM As OccurrencePatternElement In LPAT.OccurrencePatternElements For Each LOCC As ComponentOccurrence In LELM.Occurrences 'MsgBox(LOCC.Name) BATCUT.AddParticipant(LOCC) Next Next

 

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Inventor.ExtrudeFeature.AddParticipant(ComponentOccurrence Occurrence)
   at ThisRule.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

0 Likes
Accepted solutions (1)
519 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

you are working with a occurence in the sub assembly there for you need to make a occurence proxy. try this:

Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition

Dim BATCUT As ExtrudeFeature = oDef.Features.ExtrudeFeatures.Item("BATCUT")
Dim EWL As ComponentOccurrence = oDef.Occurrences.ItemByName("FR END WALL LEFT WIZARD")

Dim LPAT As OccurrencePattern = EWL.Definition.OccurrencePatterns.Item("BATTENS")

For Each LELM As OccurrencePatternElement In LPAT.OccurrencePatternElements
    For Each LOCC As ComponentOccurrence In LELM.Occurrences

        Dim proxyOcc As ComponentOccurrenceProxy
        EWL.CreateGeometryProxy(LOCC, proxyOcc)

        BATCUT.AddParticipant(proxyOcc)
    Next
Next

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

Message 3 of 3

Anonymous
Not applicable

Works perfectly, Thanks!

0 Likes