Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
J-Camper
in reply to: J-Camper

Here is an iLogic friendly version for testing:

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 & "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