Here is the sample. It creates new material asset and set Poisson ratio value,
then it creates a new appearance asset and change its properties - color and reflectivity.
Inventor.PartDocument doc = (PartDocument)oApp.ActiveDocument;
// Only document appearances can be edited, so that's what's created.
// This assumes a part or assembly document is active.
Assets docAssets = doc.Assets;
//-------------------------------------------------------
// Create a new material asset
MaterialAsset m = (MaterialAsset)docAssets.Add(
AssetTypeEnum.kAssetTypeMaterial,
"Metal",
"MySuperAlloy",
"My Super Alloy AAA");
// access some existing material asset
MaterialAsset m = (MaterialAsset)doc.Assets["My Super Alloy AAA"];
// get the current Poisson ratio value
AssetValue v = m.PhysicalPropertiesAsset["structural_Poisson_ratio"];
Console.WriteLine("Initial value: {0:G}", ((FloatAssetValue)v).Value);
//change the Poisson ratio value
FloatAssetValue x = (FloatAssetValue)m
.PhysicalPropertiesAsset["structural_Poisson_ratio"];
x.Value = 0.13;
Console.WriteLine("New value: {0:G}", ((FloatAssetValue)v).Value);
//-------------------------------------------------------
// Create a new appearance asset.
Asset appearance = docAssets.Add(
AssetTypeEnum.kAssetTypeAppearance,
"Generic", "AAAAA", "AAAAA");
// new color
TransientObjects oTransObjects = oApp.TransientObjects;
ColorAssetValue color = (ColorAssetValue)appearance["generic_diffuse"];
color.Value = oTransObjects.CreateColor(255, 15, 15);
// set reflectivity
x = (FloatAssetValue)appearance["generic_reflectivity_at_0deg"];
x.Value = 0.7;
x = (FloatAssetValue)appearance["generic_reflectivity_at_90deg"];
x.Value = 0.7;
//-------------------------------------------------------
Inventor API Help contains the code sample “Write out all materials to a file” that writes out information about all of the materials in all libraries. This can help to find out physical property names available for a material.
Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network