IExportContext Material missing Appearance Asset data

IExportContext Material missing Appearance Asset data

josepht21
Enthusiast Enthusiast
395 Views
4 Replies
Message 1 of 5

IExportContext Material missing Appearance Asset data

josepht21
Enthusiast
Enthusiast

Hi everyone!

I am currently trying to retrieve the material properties from the AppearanceAsset using the IExportContext but I have encountered some issues. For some reason some assets do not have any property (asset.Size == 0), therefore when trying to search for any property like "BaseSchema" I get null. 

The code snippet goes like this 

public void OnMaterial(MaterialNode node)
{

var currentMaterialId = node.MaterialId;
Asset currentAsset = node.HasOverriddenAppearance ? node.GetAppearanceOverride() : node.GetAppearance();
var baseSchemaProperty = currentAsset.FindByName("BaseSchema");
}

What is weird it that the material does have the right appearance asset set, is there a solution for this or am I missing something? 

Thanks in advance! 

@jeremy_tammik 

0 Likes
396 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni

Yes, that sounds weird indeed. I asked the development team for you.

    

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 5

josepht21
Enthusiast
Enthusiast

Thanks! Will wait for the answer on it.

0 Likes
Message 4 of 5

jeremy_tammik
Alumni
Alumni

Please try this path to get the "BaseSchema":

   

  • material Id -> material element -> AppearanceAssetId -> AppearanceAssetElement -> GetRenderingAsset -> FindByName("BaseSchema").

     

This path can explain why the material does have the right appearance asset set. For the OnMaterial method, it is more context based(more dynamic as it's exporting).

  

For further testing, can you please send us a sample file and Macro script so that we can check what is happening? Thank you!

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 5

josepht21
Enthusiast
Enthusiast

Awesome! I will try that way. Thanks!

0 Likes