Hi,
A rule which works flawlessly on all of my assemblies and adds iproperty of the maximum length to each part of assembly except it throws following error when assembly is a welded assembly. To make sure if weld is causing error or not I ran it on a regular assembly and it ran just fine, but gave the same error (below) once the assembly was changed to weldment.
Error in rule: MaxLength, in document: WeldmentAssembly.iam
Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
thanks and regards,
flo
Solved! Go to Solution.
Solved by Sergio.D.Suárez. Go to Solution.
Good morning, if I remember correctly, that is because in a welded assembly the weld geometry is recognized as occurrence. To avoid that error you can easily place the Try catch end try instruction when working with assemblies and pass over each assembly occurrence, below I will give you an example that may be useful for you.
Dim AssyDoc As AssemblyDocument, AssyCD As AssemblyComponentDefinition AssyDoc = ThisDoc.Document AssyCD = AssyDoc.ComponentDefinition For Each oCC As ComponentOccurrence In AssyCD.Occurrences Try ' Put your code on occurrences here Catch End Try Next
You could also put "on error resume next" at the beginning just in place of "try", and remove the "catch - end try"
This instruction will run and skip the errors, I have placed the two forms because these forms cannot both coexist in the same subroutine.
I hope some of this helps. regards
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
You can look at the Definition.Type to determine if it's an kAssemblyComponentDefinitionObject or an kWeldmentComponentDefinitionObject.
Good morning, could you try the following, maybe this can work as well.
Dim AssyDoc As AssemblyDocument, AssyCD As AssemblyComponentDefinition AssyDoc = ThisDoc.Document AssyCD = AssyDoc.ComponentDefinition For Each oCC As ComponentOccurrence In AssyCD.Occurrences If oCC.Definition.Type <> 100670208 Then ' Occurrence <> WeldsComponentDefinition Object. ' Put your code on occurrences here End If Next
I usually use the try catch end try instruction a lot, to perform operations faster when creating the code, but it sure can be improved. I hope this helps you. Greetings!!
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
Can't find what you're looking for? Ask the community or share your knowledge.