Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to run the flat pattern rules from assembly??

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
1240 Views, 7 Replies

How to run the flat pattern rules from assembly??

hi guys, I need help to rule the runs from the assembly. My assembly file has 3 sheet metal parts and what I need is use ilogic rules to export them as .dxf files at the same time. It does work when I write the code for each single part, however, the rules not works when I assembly them together. I keep getting the error message

 

"Error in rule: Rule3, in document: access dr_same

Unable to cast COM object of type 'Inventor._DocumentClass' 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))."

 

Something to clear, Rule3 is the rule I wrote in ilogic to export .dxf FILE. everytime the parameter changes, the rule allows me to automatically save the surface as dxf file to a certain location. the rule works perfect in the ipt file. 

 

however, when i assemble 3 sheet metal parts together in an assembly file, this rule not works anymore and give me the above error message. 

 

anybody can help me to solve this problem? very appreciate your help.

 

 

7 REPLIES 7
Message 2 of 8
jletcher
in reply to: Anonymous

Welcome to the forums.

 

What you may have to do is write it so it opens the part and then do what you ask as long as you put false at the end on the saveas DXF it should run in the background and all you will see is hour glass till it is done.

 

AKA silent run....

Message 3 of 8
cwhetten
in reply to: Anonymous

Hi and welcome to the forum!

 

Without seeing your rule, it might be hard to give you the best help.  Can you post your iLogic code?  Better yet, can you post one of your IPT files (one with the rule in question, of course)?

 

Cameron Whetten
Inventor 2012

Message 4 of 8
Anonymous
in reply to: cwhetten

thanks for your reply, the attached is the working ipt file. it works perfectly by its own, however, when i asseble it to an assembly file and try to run the Rule3 in it by ilogic, it not works anymore. please help me~ thank you

Message 5 of 8
Anonymous
in reply to: Anonymous

Do you have any code that would tell the rule which of the multiple parts it is to run this rule on? It works in the part because it is a single part. I expect if you want it to cover multiple parts you must tell it to start with each part, run the rule, then switch to the next part. The same process you would use to get the length from one part, go to the next part, get it, etc, then put them in a BOM. it needs to know which part you want to execute the rule on.

 

Just a possibility.

Message 6 of 8
Anonymous
in reply to: Anonymous

yes, I created a new rule in my assembly file and write the following code. but it always give me the same error.

 

iLogicVb.RunRule("access dr_same:1", "Rule3")


Error in rule: Rule3, in document: access dr_same

Unable to cast COM object of type 'Inventor._DocumentClass' 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)).

 

 

please help~ thanks and appreciate

 
Message 7 of 8
cwhetten
in reply to: Anonymous

The error is caused by line 57 of Rule3.  What you have is this:

 

oDoc = ThisApplication.ActiveDocument

 

The problem with this line is that when the code is run from an assembly, the part file with Rule3 in it is not the active document--the assembly is the active document.  So the remainder of the code tries to execute on the assembly document, which obviously doesn't have a flat pattern and causes the error.

 

There are several ways to address the problem, but the simplest is to change the line to read this:

 

oDoc = ThisDoc.Document

 

This little bit of iLogic code gets the document that the rule is in, so you don't have to worry about which document is the active one.  It just always gets the document with the currently-running Rule3.

 

That should take care of the error and allow the rest of the code to run.  After I made this change, I was able to generate the DXF file from the assembly.

 

There is a related issue on line 39, though it has a minor effect.  This line also has a call to ThisApplication.ActiveDocument, so running the rule from an assembly will always make it show the message box that says "Please open a part document".  A minor issue, but could be addressed in a similar way as above.

 

Cameron Whetten
Inventor 2012

Please click "Accept as Solution" if this response answers your question.

Message 8 of 8
Anonymous
in reply to: cwhetten

thank you for your help~ it works for me, and very appreciate your helps~ thank youSmiley Tongue

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

Post to forums  

Autodesk Design & Make Report