get_ReferencingDocuments API is not working as expected for Multiple Model State

get_ReferencingDocuments API is not working as expected for Multiple Model State

Harshil.JAINS8RVT
Contributor Contributor
368 Views
1 Reply
Message 1 of 2

get_ReferencingDocuments API is not working as expected for Multiple Model State

Harshil.JAINS8RVT
Contributor
Contributor
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
0 Likes
369 Views
1 Reply
Reply (1)
Message 2 of 2

YuhanZhang
Autodesk
Autodesk

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.

0 Likes