<?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 Re: Determine thickness in Ilogic in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13430918#M663</link>
    <description>&lt;P&gt;Hi! You can try using this code.&lt;BR /&gt;You just need to select the edge that represents the thickness, and the code will do the rest.&lt;BR /&gt;It checks if a sheet metal rule matching that thickness exists and applies it if found.&lt;BR /&gt;Then, it verifies that the parameter you're looking for exists and enables the export option.&lt;BR /&gt;Finally, it unfolds the model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
' Prompt user to select an edge
Dim oSelectedEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select the thickness edge. Press ESC to cancel.")
If oSelectedEdge Is Nothing Then Exit Sub

' Get edge length
Dim minParam, maxParam, oOutputLength As Double
Dim oCurveEval As CurveEvaluator = oSelectedEdge.Evaluator
oCurveEval.GetParamExtents(minParam, maxParam)
oCurveEval.GetLengthAtParam(minParam, maxParam, oOutputLength)
Dim oThickness As Double = Math.Round(oOutputLength * 10, 1) ' Convert to mm

' Build sheet metal rule name based on thickness
Dim oStyleName As String = "Sp_" + CStr(oThickness) + "_mm" ' This depends on your defined sheet metal rules

' Convert to sheet metal if it isn’t already
If Not oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
End If

' Assign the matching sheet metal rule
Dim oSheetMetalCompDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition
Try
	Dim oStyle As SheetMetalStyle = oSheetMetalCompDef.SheetMetalStyles(oStyleName)
	oStyle.Activate()
Catch
	MessageBox.Show("Failed to apply a sheet metal rule." &amp;amp; vbNewLine &amp;amp; "Detected thickness: " &amp;amp; CStr(oThickness), "WARNING", MessageBoxButtons.OK)
	Exit Sub
End Try

' check flag to export
Dim ParamName As String = "Thickness" ' This also depends on the parameter you're lookin for
Try
	Dim ThicknessParam As Parameter = oPartDoc.ComponentDefinition.Parameters(ParamName) 
	ThicknessParam.ExposedAsProperty = True
Catch
	MessageBox.Show("Failed to find the parameter: " &amp;amp; CStr(ParamName), "WARNING", MessageBoxButtons.OK)
	Exit Sub
End Try

' Unfold
oSheetMetalCompDef.Unfold&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Apr 2025 12:34:18 GMT</pubDate>
    <dc:creator>a.brusamolino</dc:creator>
    <dc:date>2025-04-17T12:34:18Z</dc:date>
    <item>
      <title>Determine thickness in Ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13430462#M662</link>
      <description>&lt;P&gt;Hello forum members,&lt;/P&gt;&lt;P&gt;I'm trying to determine the thickness of imported (step-file) parts in Ilogic but my knowledge is unsufficient.&lt;/P&gt;&lt;P&gt;After determining the thickness the corresponding "Sheet Metal Rule" an "Unfold Rule" must be selected.&lt;/P&gt;&lt;P&gt;In the parameters the "Export Parameter" box must be checked.&lt;/P&gt;&lt;P&gt;Your help would be much appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 17 Apr 2025 07:26:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13430462#M662</guid>
      <dc:creator>mjplaatwerk</dc:creator>
      <dc:date>2025-04-17T07:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Determine thickness in Ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13430918#M663</link>
      <description>&lt;P&gt;Hi! You can try using this code.&lt;BR /&gt;You just need to select the edge that represents the thickness, and the code will do the rest.&lt;BR /&gt;It checks if a sheet metal rule matching that thickness exists and applies it if found.&lt;BR /&gt;Then, it verifies that the parameter you're looking for exists and enables the export option.&lt;BR /&gt;Finally, it unfolds the model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
' Prompt user to select an edge
Dim oSelectedEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select the thickness edge. Press ESC to cancel.")
If oSelectedEdge Is Nothing Then Exit Sub

' Get edge length
Dim minParam, maxParam, oOutputLength As Double
Dim oCurveEval As CurveEvaluator = oSelectedEdge.Evaluator
oCurveEval.GetParamExtents(minParam, maxParam)
oCurveEval.GetLengthAtParam(minParam, maxParam, oOutputLength)
Dim oThickness As Double = Math.Round(oOutputLength * 10, 1) ' Convert to mm

' Build sheet metal rule name based on thickness
Dim oStyleName As String = "Sp_" + CStr(oThickness) + "_mm" ' This depends on your defined sheet metal rules

' Convert to sheet metal if it isn’t already
If Not oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
End If

' Assign the matching sheet metal rule
Dim oSheetMetalCompDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition
Try
	Dim oStyle As SheetMetalStyle = oSheetMetalCompDef.SheetMetalStyles(oStyleName)
	oStyle.Activate()
Catch
	MessageBox.Show("Failed to apply a sheet metal rule." &amp;amp; vbNewLine &amp;amp; "Detected thickness: " &amp;amp; CStr(oThickness), "WARNING", MessageBoxButtons.OK)
	Exit Sub
End Try

' check flag to export
Dim ParamName As String = "Thickness" ' This also depends on the parameter you're lookin for
Try
	Dim ThicknessParam As Parameter = oPartDoc.ComponentDefinition.Parameters(ParamName) 
	ThicknessParam.ExposedAsProperty = True
Catch
	MessageBox.Show("Failed to find the parameter: " &amp;amp; CStr(ParamName), "WARNING", MessageBoxButtons.OK)
	Exit Sub
End Try

' Unfold
oSheetMetalCompDef.Unfold&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Apr 2025 12:34:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13430918#M663</guid>
      <dc:creator>a.brusamolino</dc:creator>
      <dc:date>2025-04-17T12:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Determine thickness in Ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13431229#M664</link>
      <description>Thanks for your help&lt;BR /&gt;&lt;BR /&gt;I'm not sure when I will be able to test this because I'm terribly busy but&lt;BR /&gt;I'll let you know the result&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Apr 2025 15:04:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13431229#M664</guid>
      <dc:creator>mjplaatwerk</dc:creator>
      <dc:date>2025-04-17T15:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Determine thickness in Ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13431515#M665</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5796989"&gt;@mjplaatwerk&lt;/a&gt;&amp;nbsp;.&amp;nbsp;To make my rule work, you don't need anything except to run it.&amp;nbsp;It calculates the distance between the largest face and its opposite.&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Public Sub Main()
	oInvApp = ThisApplication
	Dim oPDoc As PartDocument = TryCast(oInvApp.ActiveDocument, PartDocument)
	If oPDoc Is Nothing Then Exit Sub
	If oPDoc.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" Then
		oPDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
	End If
	Dim oCompDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
	If oCompDef.SurfaceBodies.Count = 0 Then Exit Sub
	Dim dThickness As Double = GetThickFromMaxFace(oCompDef.SurfaceBodies(1))
	oCompDef.UseSheetMetalStyleThickness = False
	oCompDef.Thickness.Value = dThickness
	If Not oCompDef.HasFlatPattern Then : oCompDef.Unfold
	Else : oCompDef.FlatPattern.Edit : End If
End Sub

Property oInvApp As Inventor.Application

Private Function GetThickFromMaxFace(ByVal oBody As SurfaceBody) As Double
	Dim oMaxFace As Face = GetMaxFace(oBody.Faces)
	If oMaxFace Is Nothing Then Return Nothing
	Dim origin As Inventor.Point = oMaxFace.PointOnFace
	Dim pt(2) As Double
	pt(0) = origin.X : pt(1) = origin.Y : pt(2) = origin.Z
	Dim n(2) As Double
	Call oMaxFace.Evaluator.GetNormalAtPoint(pt, n)
	Dim normal As Inventor.UnitVector = oInvApp.TransientGeometry.CreateUnitVector(-n(0), -n(1), -n(2))
	Dim objects As ObjectsEnumerator
	Dim pts As ObjectsEnumerator
	Call oBody.FindUsingRay(origin, normal, 0.001, objects, pts, True)	
	If objects.Count = 1 Then Return Nothing
	Return oInvApp.MeasureTools.GetMinimumDistance(origin, objects.Item(2))
End Function

Private Function GetMaxFace(ByVal oFaces As Faces) As Face
	Dim dArea(oFaces.Count) As Double
	For i As Integer = 1 To oFaces.Count
		dArea(i-1) = oFaces(i).Evaluator.Area
	Next i
	For i As Integer = 1 To oFaces.Count
		If oFaces(i).Evaluator.Area = dArea.Max Then Return oFaces(i)
	Next i
	Return Nothing
End Function&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Apr 2025 18:04:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13431515#M665</guid>
      <dc:creator>Andrii_Humeniuk</dc:creator>
      <dc:date>2025-04-17T18:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Determine thickness in Ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13432458#M666</link>
      <description>&lt;P&gt;Hi Andrii,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code works super. Thanks a lot.&lt;/P&gt;&lt;P&gt;it helps me (as a beginner) to learn and understand Ilogic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you be so kind to make some extra code&amp;nbsp;&lt;/P&gt;&lt;P&gt;After determining the thickness the corresponding "Sheet Metal Rule" an "Unfold Rule" must be selected. (see the attached files)&lt;/P&gt;&lt;P&gt;The name for the "Sheet Metal Rule" will be "Staal-" followed by the thickness&lt;/P&gt;&lt;P&gt;The name for the "Unfold Rule" will be "Staal-" followed by the thickess and "_Kfactor"&lt;/P&gt;&lt;P&gt;After doing this the "Use Thickness from Rule" box must be checked.&lt;/P&gt;&lt;P&gt;And finaly in the parameters the "Export Parameter" box must be checked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 11:11:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13432458#M666</guid>
      <dc:creator>mjplaatwerk</dc:creator>
      <dc:date>2025-04-18T11:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Determine thickness in Ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13432478#M667</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5796989"&gt;@mjplaatwerk&lt;/a&gt;&amp;nbsp;.&amp;nbsp;I'm glad to hear that everything is working well. Try the new code that selects the &lt;STRONG&gt;Sheet Metal Rule&lt;/STRONG&gt; and &lt;STRONG&gt;Unfold Rule&lt;/STRONG&gt; according to the metal thickness in case there are any in the list.&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Public Sub Main()
	oInvApp = ThisApplication
	Dim oPDoc As PartDocument = TryCast(oInvApp.ActiveDocument, PartDocument)
	If oPDoc Is Nothing Then Exit Sub
	If oPDoc.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" Then
		oPDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
	End If
	Dim oCompDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
	Dim dThickness As Double
	With oCompDef.SurfaceBodies
		If .Count = 0 Then Exit Sub
		If Not .Item(1).IsSolid Then Exit Sub
		dThickness = GetThickFromMaxFace(.Item(1))
	End With
	Dim sSMRule As String = sMetalRule &amp;amp; (dThickness * 10)
	Dim sURule As String = sSMRule &amp;amp; sKfactor
	With oCompDef
		Try
			If Not .UseSheetMetalStyleThickness Then .UseSheetMetalStyleThickness = True
			.SheetMetalStyles(sSMRule).Activate()
			.UnfoldMethod = oCompDef.UnfoldMethods(sURule)
		Catch
			If .UseSheetMetalStyleThickness Then .UseSheetMetalStyleThickness = False
			If Not .Thickness.Value = dThickness Then .Thickness.Value = dThickness
		End Try
		If Not .HasFlatPattern Then : .Unfold()
		Else : .FlatPattern.Edit() : End If
'		Else : .FlatPattern.Delete() : .Unfold() : End If
	End With
End Sub

Property oInvApp As Inventor.Application
Property sMetalRule As String = "Staal-"
Property sKfactor As String = "_Kfactor"

Private Function GetThickFromMaxFace(ByVal oBody As SurfaceBody) As Double	
	With oBody.Faces.Cast(Of Face).OrderBy(Function(f) f.Evaluator.Area).Last()
		Dim pt(2), n(2) As Double
		Call.Evaluator.GetNormalAtPoint(pt, n)
		Dim normal As Inventor.UnitVector = oInvApp.TransientGeometry.CreateUnitVector(-n(0), -n(1), -n(2))
		Dim objects, pts As ObjectsEnumerator
		Call oBody.FindUsingRay(.PointOnFace, normal, 0.001, objects, pts, True)
		If objects.Count = 1 Then Return Nothing
		Return oInvApp.MeasureTools.GetMinimumDistance(.PointOnFace, objects(2))
	End With
End Function&lt;/LI-CODE&gt;
&lt;P&gt;Line 33 is the prefix for the Sheet Metal Rule.&lt;BR /&gt;Line 34 is the suffix for the Unfold Rule.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Apr 2025 13:41:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13432478#M667</guid>
      <dc:creator>Andrii_Humeniuk</dc:creator>
      <dc:date>2025-04-18T13:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Determine thickness in Ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13433536#M668</link>
      <description>&lt;P&gt;Hello Andrii,&lt;/P&gt;&lt;P&gt;It works flawless. Thank you very much&lt;/P&gt;&lt;P&gt;I have one last request&lt;/P&gt;&lt;P&gt;How do I check the box in the Export parameters? (see the attached file)&lt;/P&gt;</description>
      <pubDate>Sat, 19 Apr 2025 06:52:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13433536#M668</guid>
      <dc:creator>mjplaatwerk</dc:creator>
      <dc:date>2025-04-19T06:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Determine thickness in Ilogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13433553#M669</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5796989"&gt;@mjplaatwerk&lt;/a&gt;&amp;nbsp;.&amp;nbsp;Line 26 makes the thickness parameter exportable.&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Public Sub Main()
	oInvApp = ThisApplication
	Dim oPDoc As PartDocument = TryCast(oInvApp.ActiveDocument, PartDocument)
	If oPDoc Is Nothing Then Exit Sub
	If oPDoc.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" Then
		oPDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
	End If
	Dim oCompDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
	Dim dThickness As Double
	With oCompDef.SurfaceBodies
		If .Count = 0 Then Exit Sub
		If Not .Item(1).IsSolid Then Exit Sub
		dThickness = GetThickFromMaxFace(.Item(1))
	End With
	Dim sSMRule As String = sMetalRule &amp;amp; (dThickness * 10)
	Dim sURule As String = sSMRule &amp;amp; sKfactor
	Dim oThick As Inventor.Parameter = oCompDef.Thickness
	Try
		If Not oCompDef.UseSheetMetalStyleThickness Then oCompDef.UseSheetMetalStyleThickness = True
		oCompDef.SheetMetalStyles(sSMRule).Activate()
		oCompDef.UnfoldMethod = oCompDef.UnfoldMethods(sURule)
	Catch
		If oCompDef.UseSheetMetalStyleThickness Then oCompDef.UseSheetMetalStyleThickness = False
		If Not oThick.Value = dThickness Then oThick.Value = dThickness
	End Try
	oThick.ExposedAsProperty = True
	If Not oCompDef.HasFlatPattern Then : oCompDef.Unfold()
	Else : oCompDef.FlatPattern.Edit() : End If
'	Else : oCompDef.FlatPattern.Delete() : oCompDef.Unfold() : End If
End Sub

Property oInvApp As Inventor.Application
Property sMetalRule As String = "Staal-"
Property sKfactor As String = "_Kfactor"

Private Function GetThickFromMaxFace(ByVal oBody As SurfaceBody) As Double	
	With oBody.Faces.Cast(Of Face).OrderBy(Function(f) f.Evaluator.Area).Last()
		Dim pt(2), n(2) As Double
		Call.Evaluator.GetNormalAtPoint(pt, n)
		Dim normal As Inventor.UnitVector = oInvApp.TransientGeometry.CreateUnitVector(-n(0), -n(1), -n(2))
		Dim objects, pts As ObjectsEnumerator
		Call oBody.FindUsingRay(.PointOnFace, normal, 0.001, objects, pts, True)
		If objects.Count = 1 Then Return Nothing
		Return oInvApp.MeasureTools.GetMinimumDistance(.PointOnFace, objects(2))
	End With
End Function&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Apr 2025 07:19:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/determine-thickness-in-ilogic/m-p/13433553#M669</guid>
      <dc:creator>Andrii_Humeniuk</dc:creator>
      <dc:date>2025-04-19T07:19:40Z</dc:date>
    </item>
  </channel>
</rss>

