Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I logic rule giving error in Welded Assemblies.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
floccipier
472 Views, 5 Replies

I logic rule giving error in Welded Assemblies.

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

Labels (1)
5 REPLIES 5
Message 2 of 6
floccipier
in reply to: floccipier

Any ideas why It is throwing this error and how I can avoid this, Thanks.
Message 3 of 6

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


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 4 of 6
R.Mabery
in reply to: floccipier

You can look at the Definition.Type to determine if it's an kAssemblyComponentDefinitionObject or an kWeldmentComponentDefinitionObject. 

 


Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
Message 5 of 6

that kind of fixed it but now I am just bit worried that I have so many exceptions and error handling in my code (including this one I added with your recommendation) is that its gonna miss something else. I have marked this as solution but is there a way to to add something in there which recognises leaf node as weld bead and skips it, thank you.
Message 6 of 6

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!!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report