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: 

get_ReferencingDocuments API is not working as expected for Multiple Model State

1 REPLY 1
Reply
Message 1 of 2
Harshil.JAINS8RVT
175 Views, 1 Reply

get_ReferencingDocuments API is not working as expected for Multiple Model State

Hello All,
 
I have been working on Inventor 2023 and trying to access the Referencing Document of a Part using get_ReferencingDocuments API.
 
I have created below Structure in CAD
Drawing1.idw               Drawing2.idw
          |_Part1.ipt                      |_Part1.ipt
 
Now all the above documents are opened in Inventor and keep Part1.ipt active in CAD Session.
I have written below code which is working fine in case of Single Model State but not working for multiple model state.
a) In case of Single Model State get_ReferencingDocuments is returning list of opened drawing file.
b) But in case of Multiple Model State get_ReferencingDocuments is returning list of part files instead of drawing file.
Could you please suggest me how to access ReferencingDocuments of Part in case of Multiple Model State in Part or It is a bug from Inventor side.
 
Code Smaple :-
DocumentsEnumeratorPtr ReferencingDocs;
if (SUCCEEDED(hr) && !!pDocument)
hr = pDocument->get_ReferencingDocuments(&ReferencingDocs); //Getting incorrect list in case multiple Model State in Part
 
long lReferencingDocsCount;
if (SUCCEEDED(hr) && !!ReferencingDocs)
hr = ReferencingDocs->get_Count(&lReferencingDocsCount);
 
if (SUCCEEDED(hr) && ReferencingDocs)
{
for (int i = 1; i <= lReferencingDocsCount; i++)
{
DocumentPtr DocPtr = ReferencingDocs->GetItem(i);
 
BSTR bstrFullFileName;
if (SUCCEEDED(hr) && DocPtr)
hr = DocPtr->get_FullFileName(&bstrFullFileName);
}
}
 
 
Thanks
1 REPLY 1
Message 2 of 2

The situation should be that you are querying the referencing documents for a model state factory document instead of model state member document. When you have an assembly document, and it has several model states, and place one model state to drawing document, it has below reference structure:

Assembly1.iam 
           |____Assembly1.iam<Model State1>
                                                |____Assembly1.idw

     

The Assembly1.iam is a model state factory document, check ComponentDefinition.IsModelStateFactory, the Assembly1.iam<Model State1> is a model state member document, check PartComponentDefinition.IsModelStateMember). So the model state factory document will reference to the model state member document, and then the model state member document references to the drawing document.  So in your code you should firstly check your document is a model state factory or member document.

 

Thanks,

Rocky



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

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

Post to forums  

Autodesk Design & Make Report