<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to get specific texture image (.png or .jpeg) file path used on a face. in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-specific-texture-image-png-or-jpeg-file-path-used-on/m-p/13049899#M172327</link>
    <description>&lt;LI-CODE lang="general"&gt;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; 
								}
							}
						}
					}
				}
			}
			
        }

    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I am working on a Inventor part file to GLTF file convertor.&lt;/P&gt;&lt;P&gt;At line number 33, I want to get the exact path of file texture file which is used on a face using Inventor API.&lt;BR /&gt;Can anyone help me to get this location with the help of API?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aniket_pachore_0-1727441937766.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1415186i395B0FA8B6AEAE40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aniket_pachore_0-1727441937766.png" alt="aniket_pachore_0-1727441937766.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2024 13:00:44 GMT</pubDate>
    <dc:creator>aniket_pachore</dc:creator>
    <dc:date>2024-09-27T13:00:44Z</dc:date>
    <item>
      <title>How to get specific texture image (.png or .jpeg) file path used on a face.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-specific-texture-image-png-or-jpeg-file-path-used-on/m-p/13049899#M172327</link>
      <description>&lt;LI-CODE lang="general"&gt;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; 
								}
							}
						}
					}
				}
			}
			
        }

    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I am working on a Inventor part file to GLTF file convertor.&lt;/P&gt;&lt;P&gt;At line number 33, I want to get the exact path of file texture file which is used on a face using Inventor API.&lt;BR /&gt;Can anyone help me to get this location with the help of API?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aniket_pachore_0-1727441937766.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1415186i395B0FA8B6AEAE40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="aniket_pachore_0-1727441937766.png" alt="aniket_pachore_0-1727441937766.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 13:00:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-specific-texture-image-png-or-jpeg-file-path-used-on/m-p/13049899#M172327</guid>
      <dc:creator>aniket_pachore</dc:creator>
      <dc:date>2024-09-27T13:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get specific texture image (.png or .jpeg) file path used on a face.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-specific-texture-image-png-or-jpeg-file-path-used-on/m-p/13053174#M172346</link>
      <description>&lt;P&gt;I used the following iLogic rule to print all (or at least most) AssetValue for a face appearance.&amp;nbsp; (Disclaimer: I only tested it on one face. Reslut may be different on your faces.)&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Sub main()

    Dim doc As PartDocument = ThisDoc.Document
    Dim body As SurfaceBody = doc.ComponentDefinition.SurfaceBodies.Item(1)

    Dim face = body.Faces.Item(1)
    Dim appearance = face.Appearance


    LogAssetValues(appearance.Cast(Of AssetValue))

End Sub

Private Sub LogAssetValues(assetValues As IEnumerable(Of AssetValue), Optional preText As String = "")

    For Each assetValue As AssetValue In assetValues



        Select Case AssetValue.ValueType
            Case AssetValueTypeEnum.kAssetValueTypeString
                PrintAssetValueDefault(preText, AssetValue)

            Case AssetValueTypeEnum.kAssetValueTypeBoolean
                PrintAssetValueDefault(preText, AssetValue)

            Case AssetValueTypeEnum.kAssetValueTypeInteger
                PrintAssetValueDefault(preText, AssetValue)

            Case AssetValueTypeEnum.kAssetValueTypeFloat
                PrintAssetValueDefault(preText, AssetValue)
                'logger.Info(preText + assetValue.DisplayName + ": " + assetValue.Value.ToString())

            Case AssetValueTypeEnum.kAssetValueTypeFilename
                Dim a As FilenameAssetValue = AssetValue
                If (a.HasMultipleValues) Then
                    logger.Info(preText + a.DisplayName + " (" + a.Name + ") has values: ")
                    For Each val As String In a.Values
                        logger.Info(preText + " - " + Val)
                    Next
                Else
                    logger.Info(preText + a.DisplayName + " (" + a.Name + ") has value: " + a.Value)
                End If


            Case AssetValueTypeEnum.kAssetValueTypeColor
                Dim a As ColorAssetValue = AssetValue

                If (a.HasMultipleValues) Then
                    logger.Info(preText + a.DisplayName + " (" + a.Name + ") has values: -----------------------------------------------")
                    For Each color As Color In a.Values
                        Dim colorString = String.Format("Red:{0}, Green:{1}, Blue:{2}, Opacity:{3}",
                                                Color.Red, Color.Green, Color.Blue, Color.Opacity)

                        If (a.HasConnectedTexture) Then
                            logger.Info(preText + "  - " + a.DisplayName + ": " + colorString + "   (Has connected texture:)")
                            Dim textureAsset As AssetTexture = a.ConnectedTexture
                            LogAssetValues(textureAsset.Cast(Of AssetValue), "      " + preText)
                        Else
                            logger.Info(preText + a.DisplayName + " (" + a.Name + "): " + colorString + "   (NONE connected texture)")
                        End If
                    Next
                Else
                    Dim color = a.Value
                    Dim colorString = String.Format("Red:{0}, Green:{1}, Blue:{2}, Opacity:{3}",
                                                color.Red, color.Green, color.Blue, color.Opacity)

                    If (a.HasConnectedTexture) Then
                        logger.Info(preText + a.DisplayName + " (" + a.Name + "): " + colorString + "   Has connected texture:")
                        Dim textureAsset As AssetTexture = a.ConnectedTexture
                        LogAssetValues(textureAsset.Cast(Of AssetValue), "      " + preText)
                    Else
                        logger.Info(preText + a.DisplayName + " (" + a.Name + "): " + colorString + "   (NONE connected texture)")
                    End If
                End If

            Case AssetValueTypeEnum.kAssetValueTypeChoice
                Dim a As ChoiceAssetValue = AssetValue

                Dim names As String() = {}
                Dim choises As String() = {}

                a.GetChoices(names, choises)
                Dim allChoises = String.Join("//", choises)

                logger.Info(preText + a.DisplayName + " (" + a.Name + ") has value: " + a.Value + "(" + allChoises + ")")

            Case Else

                logger.Info("----------&amp;gt; " + AssetValue.DisplayName + ": " + CType(AssetValue.Type, ObjectTypeEnum).ToString())
        End Select

    Next

End Sub

Private Sub PrintAssetValueDefault(preText As String, assetValue As AssetValue)
    Dim template = preText + "{0} ({1}): {2}"

    logger.Info(String.Format(template, assetValue.DisplayName, assetValue.Name, assetValue.Value.ToString()))
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;With this I came to the conclusion that you can get the filename using this line of code:&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;appearance.Item("generic_diffuse").ConnectedTexture.Item("unifiedbitmap_Bitmap").Value&lt;/LI-CODE&gt;
&lt;P&gt;As a warning, I found that the file path can be a relative path. and there can be multiple paths. Have a look at what I found for my "Bump" texture:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JelteDeJong_2-1727632364666.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1415750iDFA3D3BE60242771/image-size/large?v=v2&amp;amp;px=999" role="button" title="JelteDeJong_2-1727632364666.png" alt="JelteDeJong_2-1727632364666.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JelteDeJong_3-1727632374477.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1415751i86E2D63F2E161F44/image-size/large?v=v2&amp;amp;px=999" role="button" title="JelteDeJong_3-1727632374477.png" alt="JelteDeJong_3-1727632374477.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Sep 2024 17:53:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-get-specific-texture-image-png-or-jpeg-file-path-used-on/m-p/13053174#M172346</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2024-09-29T17:53:35Z</dc:date>
    </item>
  </channel>
</rss>

