<?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 Material-Hatch Mapping in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12562524#M163787</link>
    <description>&lt;P&gt;With Hatch Patterns getting API access, has anyone found a way to access this Material/Hatch Pattern Map from the Styles Editor?&amp;nbsp; I'm working on something, and I want to be able to check the User defined HatchMap, but I'm not sure how to access it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="temp_pic.JPG" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1326497i7929DCBB14C6FE69/image-size/medium?v=v2&amp;amp;px=400" role="button" title="temp_pic.JPG" alt="temp_pic.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2024 16:14:15 GMT</pubDate>
    <dc:creator>J-Camper</dc:creator>
    <dc:date>2024-02-15T16:14:15Z</dc:date>
    <item>
      <title>Material-Hatch Mapping</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12562524#M163787</link>
      <description>&lt;P&gt;With Hatch Patterns getting API access, has anyone found a way to access this Material/Hatch Pattern Map from the Styles Editor?&amp;nbsp; I'm working on something, and I want to be able to check the User defined HatchMap, but I'm not sure how to access it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="temp_pic.JPG" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1326497i7929DCBB14C6FE69/image-size/medium?v=v2&amp;amp;px=400" role="button" title="temp_pic.JPG" alt="temp_pic.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 16:14:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12562524#M163787</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2024-02-15T16:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Material-Hatch Mapping</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12562846#M163793</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4898893"&gt;@J-Camper&lt;/a&gt;.&amp;nbsp; I do not think those will be found in the 'usual' place (DrawingStylesManager.ActiveStandardStyle...).&amp;nbsp; I believe those are dictated from the following location:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=DrawingDocument_DrawingHatchPatternsManager" target="_blank" rel="noopener"&gt;DrawingDocument.DrawingHatchPatternsManager&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-DrawingHatchPatternsManager" target="_blank" rel="noopener"&gt;DrawingHatchPatternsManager&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...and its properties/methods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&amp;nbsp; After closer review, the resource I pointed to does provide a way to access or create a list of hatch patterns, but it does not really seem to provide a way to pair a material with a hatch pattern, so maybe what you are looking for is just not available to the Inventor API yet.&lt;/P&gt;
&lt;P&gt;When you go to manually select a hatch pattern from the drop-down list, and choose "Other...", it opens a dialog titled "Select Hatch Pattern", and that dialog has the Load &amp;amp; Export buttons, similar to the DrawingHatchPatternsManager methods available at that link.&amp;nbsp; May have to ask someone from Autodesk if that is available to access by code.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 19:08:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12562846#M163793</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-02-15T19:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Material-Hatch Mapping</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12562917#M163794</link>
      <description>&lt;P&gt;I tried those first, but no luck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now I'm manually parsing through design data xml files.&amp;nbsp; I found a section in the "standard.xml" file starting with "&amp;lt;HatchMaterialMap&amp;gt;" and ending with "&amp;lt;/HatchMaterialMap&amp;gt;" That looks like the data I'm interested in.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I might have to try this as the route for now&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 20:02:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12562917#M163794</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2024-02-15T20:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Material-Hatch Mapping</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12563338#M163799</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to put this together:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Private Function BuildHatchMap(StyleName As String) As NameValueMap
	Dim OutputMap As NameValueMap = g_inventorApplication.TransientObjects.CreateNameValueMap()

	Dim DesignDateFolder As String = g_inventorApplication.DesignProjectManager.ActiveDesignProject.DesignDataPath
	Dim StandardXMLFullFileName As String = DesignDateFolder &amp;amp; "standard.xml"
	Dim GenericStyleHeading As String = "Style"
	Dim HatchMapHeading As String = "HatchMaterialMap"
	Dim MaterialAttribute As String = "Material"
	Dim PatternHeading As String = "PatternLine"

	Dim StandardXMLdoc As XDocument = XDocument.Load(StandardXMLFullFileName)


	Dim styleElement As XElement

	For Each s As XElement In StandardXMLdoc.Descendants(GenericStyleHeading)

		If s.Value.Contains(StyleName) Then styleElement = s : Exit For

	Next

	If styleElement.Value Is String.Empty Then Return Nothing

	Dim HatchMapXElement As XElement = styleElement.Descendants(HatchMapHeading)(0)

	If HatchMapXElement.Value Is String.Empty Then Return Nothing

	'Now We need to parse this for Materials

	For Each s As XElement In HatchMapXElement.Elements()

		Dim MaterialName As String = s.Attribute(MaterialAttribute).Value

		Dim PatternLine0 As String = s.Descendants(PatternHeading)(0).Value.Split(",")(0)

		PatternLine0 = Right(PatternLine0, PatternLine0.Length - 1)

		OutputMap.Add(MaterialName, PatternLine0)

	Next

	Return OutputMap
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It builds a namevaluemap for the StyleStandard name provided.&amp;nbsp; I was feeding from Main:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;dDoc.StylesManager.ActiveStandardStyle.Name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm wondering if anyone has a more elegant solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 22:53:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12563338#M163799</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2024-02-15T22:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Material-Hatch Mapping</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12563373#M163800</link>
      <description>&lt;P&gt;Here is an iLogic friendly version for testing:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;AddReference "System.Xml"
AddReference "System.Xml.Linq"

Imports System.Xml
Imports System.Xml.Linq

Sub Main
	
	Dim dDoc As DrawingDocument = TryCast(ThisApplication.ActiveDocument, DrawingDocument)
	If IsNothing(dDoc) Then Logger.Debug("Not Run In Drawing Document") : Exit Sub
	
	Dim HatchMap As NameValueMap = BuildHatchMap(dDoc.StylesManager.ActiveStandardStyle.Name)
	If HatchMap Is Nothing Then Exit Sub
		
	MessageBox.Show(HatchMap.Count, "Materials Mapped to Hatches")
	
End Sub

Private Function BuildHatchMap(StyleName As String) As NameValueMap
	Dim OutputMap As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()

	Dim DesignDateFolder As String = ThisApplication.DesignProjectManager.ActiveDesignProject.DesignDataPath
	Dim StandardXMLFullFileName As String = DesignDateFolder &amp;amp; "standard.xml"
	Dim GenericStyleHeading As String = "Style"
	Dim HatchMapHeading As String = "HatchMaterialMap"
	Dim MaterialAttribute As String = "Material"
	Dim PatternHeading As String = "PatternLine"

	Dim StandardXMLdoc As XDocument = XDocument.Load(StandardXMLFullFileName)


	Dim styleElement As XElement

	For Each s As XElement In StandardXMLdoc.Descendants(GenericStyleHeading)

		If s.Value.Contains(StyleName) Then styleElement = s : Exit For

	Next

	If styleElement.Value Is String.Empty Then Return Nothing

	Dim HatchMapXElement As XElement = styleElement.Descendants(HatchMapHeading)(0)

	If HatchMapXElement.Value Is String.Empty Then Return Nothing

	'Now We need to parse this for Materials

	For Each s As XElement In HatchMapXElement.Elements()

		Dim MaterialName As String = s.Attribute(MaterialAttribute).Value

		Dim PatternLine0 As String = s.Descendants(PatternHeading)(0).Value.Split(",")(0)

		PatternLine0 = Right(PatternLine0, PatternLine0.Length - 1)

		OutputMap.Add(MaterialName, PatternLine0)

	Next

	Return OutputMap
End Function&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 15 Feb 2024 23:29:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/material-hatch-mapping/m-p/12563373#M163800</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2024-02-15T23:29:37Z</dc:date>
    </item>
  </channel>
</rss>

