03-04-2020
07:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-04-2020
07:09 AM
Here is the code i have. I have commented out the error that I get when I go to run it. The intent is to run some iLogic to delete suppressed parts and assembly after running a form where the user would choose which options to include. Those options not used, would be suppressed, and then ultimately deleted.
Sub Main() Dim doc As AssemblyDocument doc = ThisApplication.ActiveDocument Dim acd As AssemblyComponentDefinition acd = doc.ComponentDefinition Call DeleteSuppressedComponent(acd.Occurrences) End Sub Sub DeleteSuppressedComponent(occs As ComponentOccurrences) Dim occ As ComponentOccurrence For Each occ In occs If occ.Suppressed Then occ.Delete Else Call DeleteSuppressedComponent(occ.SubOccurrences) End If Next End Sub '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.ComponentOccurrence.Delete() 'at ThisRule.DeleteSuppressedComponent(ComponentOccurrences occs) 'at ThisRule.Main() 'at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem) 'at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Solved! Go to Solution.
03-04-2020
08:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-04-2020
08:20 AM
I was able to get this error by running your code on an assembly where an occurrence within a component pattern was suppressed. Could that be the issue for you?
If so, you could solve the issue by making sure the suppressed occurrence is not part of a pattern, and if it is, leave it alone. This tweak will do that:
If occ.Suppressed Then If Not occ.IsPatternElement Then occ.Delete End If Else Call DeleteSuppressedComponent(occ.SubOccurrences) End If