ComponentOccurrence of a missing (skipped?) component?

ComponentOccurrence of a missing (skipped?) component?

oransen
Collaborator Collaborator
556 Views
3 Replies
Message 1 of 4

ComponentOccurrence of a missing (skipped?) component?

oransen
Collaborator
Collaborator

If I loop over the component occurrences in an assembly, but some of these occurrences are missing and have been skipped by the user, what does...

        CComPtr<ComponentOccurrence> pCompOcc;
        hRes = pOccs->get_Item(lOccCount, &pCompOcc);
        // pCompOcc appears to be unavailable, but hRes has returned OK

...give me? If I check pCompOcc == nullptr I get an exception. Is there some member of ComponentOccurrence which tells me it is skipped?

 

0 Likes
Accepted solutions (1)
557 Views
3 Replies
Replies (3)
Message 2 of 4

j.haggenjos
Advocate
Advocate
Accepted solution

I think what you are looking for is this:

 

Occurrence.ReferencedDocumentDescriptor.ReferenceMissing

 

This will return true if the component is unresolved or if the occurrence is suppressed. So a better option could be:

 

Not Occurrence.Suppressed AndAlso Occurrence.ReferencedDocumentDescriptor.ReferenceMissing

 

Message 3 of 4

oransen
Collaborator
Collaborator

Thanks for that, I'll try it in C++ COM and let you know.

0 Likes
Message 4 of 4

oransen
Collaborator
Collaborator

@j.haggenjos, many thanks for that it works, and here it is in C++ COM:

 

CComPtr<ComponentOccurrence> pCompOcc;
hRes = pOccs->get_Item(lOccCount, &pCompOcc);
if (FAILED(hRes)) {
    gLogger.Printf(ekErrMsg, L"Could not get a component");
    return false;
}

if (VARIANT_TRUE == pCompOcc->ReferencedDocumentDescriptor->ReferenceMissing) {
    // Maybe a missing and skipped component...
    continue ;
}

 

 

 

0 Likes