<?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: Error when divide properties in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553666#M30525</link>
    <description>&lt;P&gt;What are "Sheet Metal Width", etc? Are those user parameters or custom iProperties?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 14:20:51 GMT</pubDate>
    <dc:creator>tyler.warner</dc:creator>
    <dc:date>2022-11-15T14:20:51Z</dc:date>
    <item>
      <title>Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553371#M30522</link>
      <description>&lt;P&gt;Hi, i try to divide the total area of flat sheet to convert mm3 to m3&lt;/P&gt;&lt;P&gt;How i can solve?&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;/P&gt;&lt;LI-CODE lang="general"&gt;If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kPartDocumentObject And _
	ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties").Item("Document SubType Name").Value &amp;lt;&amp;gt; "Sheet Metal" Then
	MsgBox("This rule only works for Sheet Metal Part documents. Exiting.", vbOKOnly, " ")
	Exit Sub
End If

Dim oDTProps As PropertySet = ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties")

Dim oSMW As String = oDTProps.Item("Sheet Metal Width").Value
Dim oSML As String = oDTProps.Item("Sheet Metal Length").Value
oSMA = oDTProps.Item("Sheet Metal Area").Value / 1000
Dim Mass As String
'If iProperties.Material = "801171 AISI 304 sp.1 2B"
'	Mass = (oSMA 
MsgBox("Sheet Metal Width = " &amp;amp; oSMW &amp;amp; vbCrLf &amp;amp; _
"Sheet Metal Length = " &amp;amp; oSML &amp;amp; vbCrLf &amp;amp; _
"Sheet Metal Area = " &amp;amp; oSMA, vbOKOnly, "SHEET METAL SIZE")&lt;/LI-CODE&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="Neuzzo_0-1668514563959.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1139864i6792461D05C03711/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Neuzzo_0-1668514563959.png" alt="Neuzzo_0-1668514563959.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 12:16:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553371#M30522</guid>
      <dc:creator>Neuzzo</dc:creator>
      <dc:date>2022-11-15T12:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553618#M30523</link>
      <description>&lt;P&gt;Use the Double type instead of String type for your parameters since the values are decimals.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim oSMW As Double = oDTProps.Item("Sheet Metal Width").Value
Dim oSML As Double = oDTProps.Item("Sheet Metal Length").Value
Dim oSMA As Double = oDTProps.Item("Sheet Metal Area").Value / 1000&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;There are also cleaner ways of converting units by using the built in UnitsOfMeasure.ConvertUnits function. You can find many examples in the &lt;A href="https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=UnitsOfMeasure" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;&amp;nbsp;or within the &lt;A href="https://forums.autodesk.com/t5/forums/searchpage/tab/message?filter=location&amp;amp;q=unitsofmeasure.convertunits&amp;amp;noSynonym=false&amp;amp;location=forum-board:120&amp;amp;collapse_discussion=true" target="_blank" rel="noopener"&gt;forums&lt;/A&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 14:05:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553618#M30523</guid>
      <dc:creator>tyler.warner</dc:creator>
      <dc:date>2022-11-15T14:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553644#M30524</link>
      <description>&lt;P&gt;Same error...&lt;/P&gt;&lt;LI-CODE lang="general"&gt;If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kPartDocumentObject And _
	ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties").Item("Document SubType Name").Value &amp;lt;&amp;gt; "Sheet Metal" Then
	MsgBox("This rule only works for Sheet Metal Part documents. Exiting.", vbOKOnly, " ")
	Exit Sub
End If

Dim oDTProps As PropertySet = ThisApplication.ActiveDocument.PropertySets.Item("Design Tracking Properties")

Dim oSMW As Double = oDTProps.Item("Sheet Metal Width").Value
Dim oSML As Double = oDTProps.Item("Sheet Metal Length").Value
Dim oSMA As Double = oDTProps.Item("Sheet Metal Area").Value / 1000
Dim Mass As String
'If iProperties.Material = "801171 AISI 304 sp.1 2B"
'	Mass = (oSMA 
MsgBox("Sheet Metal Width = " &amp;amp; oSMW &amp;amp; vbCrLf &amp;amp; _
"Sheet Metal Length = " &amp;amp; oSML &amp;amp; vbCrLf &amp;amp; _
"Sheet Metal Area = " &amp;amp; oSMA, vbOKOnly, "SHEET METAL SIZE")&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Neuzzo_0-1668521650517.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1139926iA1EC15DC764EFF54/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Neuzzo_0-1668521650517.png" alt="Neuzzo_0-1668521650517.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 14:14:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553644#M30524</guid>
      <dc:creator>Neuzzo</dc:creator>
      <dc:date>2022-11-15T14:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553666#M30525</link>
      <description>&lt;P&gt;What are "Sheet Metal Width", etc? Are those user parameters or custom iProperties?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 14:20:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553666#M30525</guid>
      <dc:creator>tyler.warner</dc:creator>
      <dc:date>2022-11-15T14:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553712#M30526</link>
      <description>Really don't know &lt;span class="lia-unicode-emoji" title=":neutral_face:"&gt;😐&lt;/span&gt;</description>
      <pubDate>Tue, 15 Nov 2022 14:40:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553712#M30526</guid>
      <dc:creator>Neuzzo</dc:creator>
      <dc:date>2022-11-15T14:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553724#M30527</link>
      <description>&lt;P&gt;Can you provide a sample part file?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 14:43:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553724#M30527</guid>
      <dc:creator>tyler.warner</dc:creator>
      <dc:date>2022-11-15T14:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553780#M30528</link>
      <description>&lt;P&gt;Yes. Here the sheet metal&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 15:03:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553780#M30528</guid>
      <dc:creator>Neuzzo</dc:creator>
      <dc:date>2022-11-15T15:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553906#M30529</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main

	Dim oDocument As Document = ThisApplication.ActiveDocument
	If oDocument.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kPartDocumentObject Then
		MsgBox("The open file is not a part file. The command has been cancelled.")
		Exit Sub
	End If

	Dim oPartDocument As PartDocument = oDocument
	If oPartDocument.SubType &amp;lt;&amp;gt; "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
		MsgBox("This is not a sheet metal part. The command has been cancelled.")
		Exit Sub
	End If
	
	Dim oComponentDefinition As SheetMetalComponentDefinition = oPartDocument.ComponentDefinition
	Dim oFlatPattern As FlatPattern = oComponentDefinition.FlatPattern
	Dim oUOM As UnitsOfMeasure = oPartDocument.UnitsOfMeasure
	
	Dim oSMW As Double = oUOM.ConvertUnits(oFlatPattern.Width, UnitsTypeEnum.kDatabaseLengthUnits, UnitsTypeEnum.kMillimeterLengthUnits) 'Database unit is cm
	MsgBox("Width (mm): " &amp;amp; oSMW)
	
	Dim oSML As Double = oUOM.ConvertUnits(oFlatPattern.Length, UnitsTypeEnum.kDatabaseLengthUnits, UnitsTypeEnum.kMillimeterLengthUnits) 'Database unit is cm
	MsgBox("Length (mm): " &amp;amp; oSML)
	
	Dim oSMA As Double = oSMW * oSML
	MsgBox("Area (mm): " &amp;amp; oSMA)
	
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 15:54:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553906#M30529</guid>
      <dc:creator>tyler.warner</dc:creator>
      <dc:date>2022-11-15T15:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553970#M30530</link>
      <description>&lt;P&gt;Hi guys.&amp;nbsp; Those were standard iProperties that are present in all Inventor documents, but obviously only used in sheet metal parts.&amp;nbsp; There are actually two different series of similar standard iProperties for similar purposes, and both are in the same PropertySet.&amp;nbsp; Item(44) is "Flat Pattern Width" with PropID = 63.&amp;nbsp; Item(45) is "Flat Pattern Length", with PropId = 64.&amp;nbsp; Item(46) is "Flat Pattern Area", with PropId = 65.&amp;nbsp; And you already know about the 3 starting with "Sheet Metal ...", but all of those are ReadOnly, and should all return Double data type, but all iProperty.Value is defined as Object, so it is always best to set the value of a variable of the expected data type, before attempting to do things like math with an expected Double, because the Value is not yet recognized as a Double until it is assigned to a Double type variable.&amp;nbsp; I believe one of these sets is supposed to return document units, while the other returns database units.&amp;nbsp; The iLogic shortcut snippets (SheetMetal.FlatExtentsWidth) actually access these iProperties behind the scenes.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 16:11:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11553970#M30530</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2022-11-15T16:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Error when divide properties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11555505#M30531</link>
      <description>Work like a charm. Thank you</description>
      <pubDate>Wed, 16 Nov 2022 07:00:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/error-when-divide-properties/m-p/11555505#M30531</guid>
      <dc:creator>Neuzzo</dc:creator>
      <dc:date>2022-11-16T07:00:15Z</dc:date>
    </item>
  </channel>
</rss>

