AnalyzeInterference Inventor API error?

AnalyzeInterference Inventor API error?

amitabhVA4SD
Advocate Advocate
1,426 Views
14 Replies
Message 1 of 15

AnalyzeInterference Inventor API error?

amitabhVA4SD
Advocate
Advocate

Hello,

 

I am getting an API error from AnalyzeInterference API on Inventor 2020.3.4. The error stack trace is not very detailed. Can someone explain to me the cause of the issue? I am putting all the component occurrences in one set and calling the AnalyzeInterference API

Is there any way to get additional error details from an Inventor API?
Inventor API Team @MjDeck , @YuhanZhang . Can you please help?

 

Doing a manual Interference Analysis with the same set of Component Occurrence is not giving any error.

image.png

 

Thanks,

Amitabh Mukherjee

 
 

 

0 Likes
1,427 Views
14 Replies
Replies (14)
Message 2 of 15

MjDeck
Autodesk
Autodesk

@amitabhVA4SD , can you post an assembly that shows the error?
How do you go about adding the component occurrences to the set? Is it something like this?
(From @Curtis_Waguespack  on https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-and-analyze-interference/td-p/34...)

 

	Dim oAsmDoc As AssemblyDocument
	oAsmDoc = ThisApplication.ActiveDocument

	Dim oAsmCompDef As AssemblyComponentDefinition
	oAsmCompDef = oAsmDoc.ComponentDefinition

	' Add each occurrence in the assembly to the object collection.
	Dim oCheckSet As ObjectCollection
	oCheckSet = ThisApplication.TransientObjects.CreateObjectCollection
	Dim oOcc As ComponentOccurrence
	For Each oOcc In oAsmCompDef.Occurrences
		oCheckSet.Add(oOcc)
	Next

	Dim oResults As InterferenceResults
	oResults = oAsmCompDef.AnalyzeInterference(oCheckSet)

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 3 of 15

amitabhVA4SD
Advocate
Advocate

@MjDeck- Yes, below I have shared the code that is being used. Does the API have any limitations with the type of inputs?

 

public void AnalyzeInterference()
        {
            try
            {
                ObjectCollection objectCollection = VctApplication.InventorSession.inventorApp.TransientObjects.CreateObjectCollection();

                foreach (ComponentOccurrence oOcc in GetVisibleItems)
                    objectCollection.Add(oOcc);

                var InterferenceResult = VctApplication.InventorSession.ActiveAssemblyDoc.ComponentDefinition.AnalyzeInterference(objectCollection);

                foreach (InterferenceResult interferenceResult in InterferenceResult)
                {
                    OccuranceDetail oOCD1 = new OccuranceDetail(interferenceResult.OccurrenceOne);
                    OccuranceDetail oOCD2 = new OccuranceDetail(interferenceResult.OccurrenceTwo);

                    if (Checknode(oOCD1) && Checknode(oOCD2))
                    {
                        ComponentDetail componentDetails1 = new ComponentDetail(oOCD1, oOCD2);
                        componentDetails1.Interference = "Y";
                        componentDetails1.FirstSubComponent.Add(oOCD1.Path);
                        componentDetails1.SecondSubComponent.Add(oOCD2.Path);
                        ComponentDetails.Add(componentDetails1);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Issue with interference for Component/Tool : " + AssemblyName + System.Environment.NewLine + System.Environment.NewLine + ex.StackTrace);
            }

        }

 

 

A sample of the assembly is shown below

amitabhVA4SD_0-1631923389971.png

Thanks,

Amitabh Mukherjee

0 Likes
Message 4 of 15

MjDeck
Autodesk
Autodesk

@amitabhVA4SD, can you share the code for GetVisibleItems?
What type of components do you have in the sample assembly?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 15

MjDeck
Autodesk
Autodesk

@amitabhVA4SD , you can get a bit more information from the error message by using 

 

ex.ToString()

 

instead of

 

ex.StackTrace

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 15

amitabhVA4SD
Advocate
Advocate

@MjDeck - We are collecting the hidden and suppressed items and then add the remaining Component occurrences to the Visible items. 

I need some more clarity on the type of components - It has Component, Welded Assemblies, Content Center Parts, and  Sheet Metal Parts. Does the API have any limitation on the type of parts it can handle?

 

amitabhVA4SD_0-1632173223487.png  

amitabhVA4SD_1-1632173258497.png

 

Thanks,

Amitabh Mukherjee

0 Likes
Message 7 of 15

MjDeck
Autodesk
Autodesk

@amitabhVA4SD , the API can handle  weldments, Content Center parts, and sheet metal parts.


One thing I found : it will throw an error if you call it with only one component in the collection. To verify, please add this line right before the call to AnalyzeInterference:

 

MessageBox.Show(String.Format("Component count = {0}", objectCollection.Count), "Test")

 


Please also try with the latest update for 2020. That is 2020.4.3.

 

Have you tried with different assemblies?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 8 of 15

amitabhVA4SD
Advocate
Advocate

@MjDeck- Our customer is on 2020.3.4. We do not have the liberty to upgrade.

The number of components is definitely more than 1 but it is good to know that there is a limitation to the API.

The component occurrences can be in different folders at our end. Will that pose a challenge?

0 Likes
Message 9 of 15

MjDeck
Autodesk
Autodesk

@amitabhVA4SD , part or assembly files in different folders should not be a problem, as long as there are no unresolved references. Do you get any warnings about unresolved files when you open the assembly?

Can you share one of the assemblies that shows the problem privately with Autodesk?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 10 of 15

amitabhVA4SD
Advocate
Advocate

@MjDeck- No there are no unresolved files in the assembly. No Question mark is shown on the top assembly prior to or after running the program. I will check with my team if we can zip the small assembly and share it with the Autodesk Team privately for analysis.

What is the best way to check the cause of unresolved references in the Assembly using Inventor API and also list out the parts which are unresolved?

We have noticed that when we do Isolate and Undo-Isolate using the command manager since there is no direct way to perform this using API, sometimes the assembly becomes unresolved. Any clue? 

0 Likes
Message 11 of 15

MjDeck
Autodesk
Autodesk

@amitabhVA4SD  , the Isolate command shows unresolved components in this assembly?
To get a list using the UI:
- Activate the Master Level of Detail in the top-level assembly.

- Save, close and reopen the assembly. Make sure you open the Master Level of Detail.

- That should give you a message for each unresolved file.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 12 of 15

amitabhVA4SD
Advocate
Advocate

@MjDeck- Thank you for sharing the steps. I need some additional clarity

 

To get a list using the UI:
- Activate the Master Level of Detail in the top-level assembly

- Save, close, and reopen the assembly. Make sure you open the Master Level of Detail - Do we need to open each part individually from the freshly opened assembly at the Master Level of Detail?

- That should give you a message for each unresolved file - Where will the message appear, can you please show me an example?

 

Is there some sort of Part Cleanup in Inventor that can help resolve unresolved parts (other than when the part reference is missing due to missing files or changed files location)?

What are the different reasons for which a part in the assembly can be unresolved?

Will a Document. Rebuild helps in such cases or does it just rebuild the Geometry?

0 Likes
Message 13 of 15

MjDeck
Autodesk
Autodesk

The Resolve Link dialog will appear. See this page:
https://knowledge.autodesk.com/support/inventor/troubleshooting/caas/sfdcarticles/sfdcarticles/Resol...

 

You do not need to open each part or subassembly individually.
I don't think there's a part cleanup tool available. If the parts are missing, it's a problem. Inventor is not going to try to produce new replacement parts automatically.
Document.Rebuild will not help.
I think the only reason for the message is that the file is not found.

Please let us know if you ever get the Resolve Link dialog when working with your assembly.

 


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 14 of 15

amitabhVA4SD
Advocate
Advocate

@MjDeck 

Can the Update Required icon be resolved with a Save or Document Update, Update2, Rebuild, Rebuild2, or all of them in a sequence?

Which is recommended and what is the difference? Any particular sequence that needs to be performed as a best practice?

Does it have an impact on AnalyzeInterference API?

 

Update.png

Thanks,

Amitabh Mukherjee

0 Likes
Message 15 of 15

MjDeck
Autodesk
Autodesk

An "Update Required" status can have an impact on the AnalyzeInterference API. It shouldn't cause it to throw an error, but it might affect the results. An assembly update can cause components to move. That could clear existing interferences and/or create new ones. So it's a good idea to make sure the assembly is up to date before running AnalyzeInterference.
As far as I know, Save will not update the document.
The Document.Update API should be sufficient to update an assembly.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes