Message 1 of 2
How to get specific texture image (.png or .jpeg) file path used on a face.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
foreach (Face face in surfaceBody.Faces)
{
Asset faceAppearance = face.Appearance;
if (faceAppearance != null)
{
AssetTypeEnum assetType = faceAppearance.AssetType;
if (assetType == AssetTypeEnum.kAssetTypeAppearance)
{
GLTFMaterial gltfMaterial = new GLTFMaterial();
GLTFPBR pbr = new GLTFPBR();
float opacity = 1;
string matId = null;
if (faceAppearance.HasTexture)
{
foreach (AssetValue assetValue in faceAppearance)
{
string textureImgName = faceAppearance.DisplayName;
AssetValueTypeEnum assetValueEnum = assetValue.ValueType;
if (assetValueEnum == AssetValueTypeEnum.kAssetValueTypeColor)
{
ColorAssetValue colorValue = (ColorAssetValue)assetValue;
AssetTexture assetTextureValue = colorValue.ConnectedTexture as AssetTexture;
if (assetTextureValue != null)
{
AssetTextureTypeEnum assetTextureTypeEnum = assetTextureValue.TextureType;
How to get a full path e.g(C:\Program Files\Common Files\Autodesk Shared\Materials\Textures\3\Mats\Finishes.Flooring.Carpet.DarkGray.Colour.png)
string textureFilePath =
if (!string.IsNullOrEmpty(textureFilePath))
{
string folderName = "Textures";
string folderPath = CreateFolderAtRoot(folderName);
string destinationTexturePath = CopyTextureToFolder(textureFilePath, folderPath);
string textureFileName = System.IO.Path.GetFileName(destinationTexturePath);
string texPath = folderName + "/" + textureFileName;
gltfMaterial.alphaMode = opacity != 1 ? BLEND : OPAQUE;
gltfMaterial.alphaCutoff = null;
gltfMaterial.name = faceAppearance.DisplayName;
// Handle bitmap textures
if (assetTextureTypeEnum == AssetTextureTypeEnum.kTextureTypeBitmap)
{
matId = string.Concat(InvAddIn.Core.Constants.faceId, assetTextureValue.Type);
setPBRMaterialsPropertiesContainsTexture(faceAppearance, texPath, opacity, ref images, ref textures, ref pbr, ref gltfMaterial);
break;
}
}
}
}
}
}
}
}
}
As I am working on a Inventor part file to GLTF file convertor.
At line number 33, I want to get the exact path of file texture file which is used on a face using Inventor API.
Can anyone help me to get this location with the help of API?