Custom iProperty reading on component occurrence causing Inventor Crash?

Custom iProperty reading on component occurrence causing Inventor Crash?

amitabhVA4SD
Advocate Advocate
524 Views
6 Replies
Message 1 of 7

Custom iProperty reading on component occurrence causing Inventor Crash?

amitabhVA4SD
Advocate
Advocate

Hello,

 

I am facing an Inventor API error while trying to read a custom iProperty from a component occurrence. Has someone experienced a similar issue before on Inventor 2020.3.4?

This is happening both when the Inventor session is shown and hidden.

 

amitabhVA4SD_1-1634786749962.png

 

amitabhVA4SD_2-1634786821866.png

 

Inventor API Team and Experts please help

@MjDeck @JelteDeJong @johnsonshiue 

@johnsonshiue 

 

Thanks,

Amitabh Mukherjee

 

 

 

 

0 Likes
525 Views
6 Replies
Replies (6)
Message 2 of 7

Michael.Navara
Advisor
Advisor

This doesn't look like a general issue. Because this part of Inventor API is well tested and used by many users.

Can you provide some minimal dataset where the error occurs?

Try to check what kind of occurrence you have as input. Because this can be some strange type. For example virtual component, weld bead in weldment assembly, iPart/iAssembly instance etc. 

 

BTW please put code sample as text instead of print screen.

0 Likes
Message 3 of 7

amitabhVA4SD
Advocate
Advocate

@Michael.Navara  - Exploring the issue with reading iProperties in the case of the tool assembly,
We have found that if the LOD representation is CLEAN, irrespective of inventor session visible or invisible mode, the exception is being reported out for a few occurrences in the assembly. We are trying to list out the specific occurrences where the error is popping out. There are no unresolved parts when the LOD is clean and no out-of-date parts as well.
In the case of LOD representation  Master, there is no exception in Inventor

 

amitabhVA4SD_0-1634860586479.png

 

Thanks,
Amitabh Mukherjee

 

 

 

0 Likes
Message 4 of 7

Michael.Navara
Advisor
Advisor

That's it. Because in LOD some documents are not loaded in memory. In this case you are not able to read anything from this documents.

0 Likes
Message 5 of 7

amitabhVA4SD
Advocate
Advocate

@Michael.Navara- We are opening the Assembly in "Load Full" mode. Why would some documents be not loaded in CLEAN LOD but loaded in MASTER LOD? Is there a particular API that we can use to check if the AssemblyDocument or PartDocument is loaded?

 

 

0 Likes
Message 6 of 7

JelteDeJong
Mentor
Mentor

If something is not loaded because LOD then usually that means that the occurrence is suppressed in the LOD. You can easily check this.

if (compOccurrence.Suppressed)
{
    throw new Exception($"{compOccurrence._DisplayName} is suppressed!");
}
Document doc = (Document)compOccurrence.Definition.Document;
PropertySet customPropSet = doc.PropertySets["nventor User Defined Properties"];
            
try
{
    Property iProperty = customPropSet["V_01_PART_TYPE"];
    string value = iProperty.Value.ToString();
    if (string.IsNullOrEmpty(value) return false;
    if (!value.Equals("SINGLE_DETAIL", StringComparison.InvariantCultureIgnoreCase) return false;
    return true;
    }
catch (Exception)
{
    return false;
}

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 7 of 7

amitabhVA4SD
Advocate
Advocate

@JelteDeJong- Really appreciate the updated code.

 

We did some more digging and found that in the Clean LOD representation, there are missing references which is causing the exception

What I was surprised to see is that we are able to open the iProperty dialog on the Parent node manually but not using code. There must be some use-case that is not properly handled in the Inventor APIs.

 

amitabhVA4SD_1-1635095772631.png

 

Thanks,

Amitabh Mukherjee

 

 

0 Likes