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: 

AssemblyComponentDefinition throws member not found

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
mrattray
1080 Views, 7 Replies

AssemblyComponentDefinition throws member not found

I have two assembly files which throw a "member not found" error when running the following line of code in iLogic:

 

oAsmCompDef = ThisDoc.Document.ComponentDefinition

 

I've tried with declaring oAsmCompDef as either ComponentDefinition or AssemblyComponentDefinition and without declaring it. All variations fail.

 

I tried one of these assemblies on a co-workers machine with no difference.

 

Other assembly files run fine.

 

I'm using Inventor 2015.

 

Any ideas would be appreciated.

Mike (not Matt) Rattray

7 REPLIES 7
Message 2 of 8
xiaodong_liang
in reply to: mrattray

Hi,

 

I gave a simple test on  my Inventor 2015. It works well. The attachment is the video. 

 

Does this problem occur with specific document?

 

Message 3 of 8
mrattray
in reply to: xiaodong_liang

Sorry, I should've attached the file to begin with.

Please, open the attached file. It's an empty assembly with just one rule (for reproduction purposes). Skip any missing references, they're not needed to show the issue. Try running Rule1. It only contains the above code which should throw a member not found error.

Mike (not Matt) Rattray

Message 4 of 8
xiaodong_liang
in reply to: mrattray

Hi Mike,

 

sorry, my video was not uploaded successfully last time.

 

I used your assembly to test again. The rule can still work without error. The video is available at: 

https://autodesk.box.com/s/t4d4z1o0bvnn5u555zbl

 

Could you take a look?

Message 5 of 8
mrattray
in reply to: xiaodong_liang

Well, this is frustrating.
When I posted that file I did the same steps you did in order to reproduce the problem multiple times and each time threw the error. Now, after the holiday, I tried again in order to record a video for you and I can no longer reproduce the problem either with this file nor the original file.
I'm confident that this will come up again as it seems to be an issue that comes and goes. When it does I'll be sure to get a video of it.
In the mean time, do you have any theories as to what could cause something like this? If you did get an error what would be the first thing you looked at?
Mike (not Matt) Rattray

Message 6 of 8
mrattray
in reply to: xiaodong_liang

I knew it would crop up again. This time it's in a part file. Here's a video I captured here.

I'll attach the part file to this post.

Mike (not Matt) Rattray

Message 7 of 8
xiaodong_liang
in reply to: mrattray

Hi Mike,

 

I got the comments from our engineer team. Could you check if it helps?

 

This problem is caused by interaction with other addins. It depends on the history of a particular Document object in a session. It’s hard to reproduce. But there is a workaround: declare a document object of a specific type.

 

Instead of the statement:

oAsmCompDef = ThisDoc.Document.ComponentDefinition

 

In an assembly, use these statements:
Dim assemDoc As AssemblyDocument = ThisDoc.Document

oAsmCompDef = assemDoc.ComponentDefinition

 

In a part, use these:

Dim partDoc As PartDocument = ThisDoc.Document

oPartCompDef = partDoc.ComponentDefinition

 

 

Message 8 of 8
mrattray
in reply to: xiaodong_liang

This seems to work. Thank you, very much!
Mike (not Matt) Rattray

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

Post to forums  

Autodesk Design & Make Report