<?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: Need to get correct length of the part in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021115#M88553</link>
    <description>How is the materialdescription defined?</description>
    <pubDate>Wed, 23 May 2018 14:53:18 GMT</pubDate>
    <dc:creator>bradeneuropeArthur</dc:creator>
    <dc:date>2018-05-23T14:53:18Z</dc:date>
    <item>
      <title>Need to get correct length of the part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021001#M88552</link>
      <description>&lt;P&gt;I am looking for a way to change my cut length code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes the Max length is already in the material description&amp;nbsp;&lt;/P&gt;&lt;P&gt;example: a 2.00" x 3.00" Rectangular tube is cut at 1.25": The Max Length comes out as 3.00" when it should be 1.25"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to check if the &lt;STRONG&gt;Measure&lt;/STRONG&gt;.&lt;STRONG&gt;ExtentsLength,&amp;nbsp;Measure.ExtentsWidth,&amp;nbsp;Measure.ExtentsHeight&lt;/STRONG&gt;&lt;STRONG&gt;.....&amp;nbsp;&lt;/STRONG&gt;is already in the material description then use the one that is not in the description.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The material description is stored in&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;iProperties.Value("Project", "Stock Number")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I am using, any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;oDoc = ThisDoc.Document

Dim MyArrayList As New ArrayList

'get measurements
My_x = Measure.ExtentsLength
My_y = Measure.ExtentsWidth
My_z = Measure.ExtentsHeight

'Make longest value the Length, rounded to 4 places
MaxLength = Round(MaxOfMany(My_x, My_y, My_z), 4)

Dim propertyName1 As String = "CALCLength"

 'define custom prpoerty collection
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")

 Try
'set property value
oProp = oCustomPropertySet.Item(propertyName1)
Catch
' Assume error means not found so create it
oCustomPropertySet.Add("", propertyName1)
End Try

 'set custom property value
iProperties.Value("Custom", "CALCLength") = MaxLength&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 May 2018 14:15:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021001#M88552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-23T14:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get correct length of the part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021115#M88553</link>
      <description>How is the materialdescription defined?</description>
      <pubDate>Wed, 23 May 2018 14:53:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021115#M88553</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2018-05-23T14:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get correct length of the part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021126#M88554</link>
      <description>&lt;P&gt;Manually typed in. Working&amp;nbsp;on changing that in the future&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 14:55:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021126#M88554</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-23T14:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get correct length of the part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021132#M88555</link>
      <description>I don't understand this then:&lt;BR /&gt;&lt;BR /&gt;"I need to check if the Measure.ExtentsLength, Measure.ExtentsWidth, Measure.ExtentsHeight..... is already in the material description then use the one that is not in the description. "</description>
      <pubDate>Wed, 23 May 2018 14:57:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021132#M88555</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2018-05-23T14:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get correct length of the part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021139#M88556</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;a 2.00" x 3.00" Rectangular tube is cut at 1.25": &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The Max Length comes out as 3.00" when it should be 1.25"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;because&amp;nbsp;the code uses the max of all extents&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 14:59:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021139#M88556</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-23T14:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get correct length of the part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021151#M88557</link>
      <description>&lt;P&gt;Here is an actual example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;11 GA x 3.00 x 3.00 HRS TUBING&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if I cut it at 2.00"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run the ilogic&amp;nbsp;code. the CALCLENGTH&amp;nbsp;will be 3.00" when it needs to be 2.00"&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 15:03:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021151#M88557</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-23T15:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get correct length of the part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021335#M88558</link>
      <description>&lt;P&gt;I think this can be done with some string operations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Get the Material name as a string with:&lt;/P&gt;&lt;P&gt;SyntaxEditor Code Snippet&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;My_Material&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Document&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Material&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Name&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or If the Material name is in the Stock Number then:&lt;/P&gt;&lt;P&gt;SyntaxEditor Code Snippet&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;My_Material&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;iProperties&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Value&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Project&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Stock Number&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your Material names are the same format, then you can use the Mid(My_Material,x,x) to check parts of the Material name for measurements, where the first x is the starting point of your string check, and the second x is the length to check.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, if your material is "Extrusion 1.500" X 2.000" then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If My_x &amp;lt;&amp;gt; Mid(My_Material, 10, 5) And My_x &amp;lt;&amp;gt; Mid(My_Material, 19, 5) Then&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Max_Length = My_x&lt;/P&gt;&lt;P&gt;'Do the same for other measurements with ElseIf statements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the first number in the Mid, the value is 10 since there are 10 characters, including spaces, before the cursor is in front of the "1.500", then the second value is 5 since there are 5 characters to check including periods.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if you need more info on string operations, they are in the snippets portion of the iLogic rule editing window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Philip Martick&lt;BR /&gt;Inventor 2018 Pro, AutoCAD 2018, Autodesk Vault Basic 2018&lt;BR /&gt;Windows 10 Pro&lt;BR /&gt;2X Intel Xeon E5-2630 v4 @ 2.20GHz&lt;BR /&gt;16.00 GB of RAM&lt;BR /&gt;NVIDIA Quadro M2000&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 15:55:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8021335#M88558</guid>
      <dc:creator>philip1009</dc:creator>
      <dc:date>2018-05-23T15:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get correct length of the part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8022106#M88559</link>
      <description>&lt;P&gt;I am assuming you have other code that will update the description after getting the max length.&lt;/P&gt;&lt;P&gt;Aafter you make the cut is the sketch showing from the original extrusion? maybe that is why the extent is still coming out as the original length.&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 20:27:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8022106#M88559</guid>
      <dc:creator>omartin</dc:creator>
      <dc:date>2018-05-23T20:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need to get correct length of the part</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8022946#M88560</link>
      <description>If dX &amp;gt; dY And dX &amp;gt; dZ Then&lt;BR /&gt;'MsgBox "x"&lt;BR /&gt;strLENGTH = dX&lt;BR /&gt;If dY &amp;gt; dZ Then&lt;BR /&gt;strWIDTH = dY&lt;BR /&gt;strTHICKNESS = dZ&lt;BR /&gt;Else&lt;BR /&gt;strWIDTH = dZ&lt;BR /&gt;strTHICKNESS = dY&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;Catch ex As Exception&lt;BR /&gt;&lt;BR /&gt;End Try&lt;BR /&gt;&lt;BR /&gt;If dY &amp;gt; dZ And dY &amp;gt; dX Then&lt;BR /&gt;'MsgBox "y"&lt;BR /&gt;strLENGTH = dY&lt;BR /&gt;&lt;BR /&gt;If dZ &amp;gt; dX Then&lt;BR /&gt;strWIDTH = dZ&lt;BR /&gt;strTHICKNESS = dX&lt;BR /&gt;Else&lt;BR /&gt;strWIDTH = dX&lt;BR /&gt;strTHICKNESS = dZ&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;If dZ &amp;gt; dX And dZ &amp;gt; dY Then&lt;BR /&gt;'MsgBox "z"&lt;BR /&gt;strLENGTH = dZ&lt;BR /&gt;If dX &amp;gt; dY Then&lt;BR /&gt;strWIDTH = dX&lt;BR /&gt;strTHICKNESS = dY&lt;BR /&gt;Else&lt;BR /&gt;strWIDTH = dY&lt;BR /&gt;strTHICKNESS = dX&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;put these into properties and you have what you need</description>
      <pubDate>Thu, 24 May 2018 07:17:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/need-to-get-correct-length-of-the-part/m-p/8022946#M88560</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2018-05-24T07:17:50Z</dc:date>
    </item>
  </channel>
</rss>

