<?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: Counting bends? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3141952#M139356</link>
    <description>&lt;PRE&gt;Public Sub BendCountToIprop()
  'Get the part doc and sheet metal component defn.  No error handling:
  Dim oApp As Inventor.Application
  Dim oDoc As Inventor.Document
  Set oApp = GetObject(, "Inventor.Application")
  If oApp.ActiveDocumentType = kDrawingDocumentObject Then
  Set oDoc = oApp.ActiveDocument
  Else: If TypeOf oApp.ActiveEditObject Is Sketch Then Exit Sub
  Set oDoc = oApp.ActiveEditObject
  End If
  Dim oSheetMetalComp As Inventor.SheetMetalComponentDefinition
  Set oSheetMetalComp = oDoc.ComponentDefinition
  
  'Get the bend count
  Dim iBendCount As Integer
  iBendCount = oSheetMetalComp.Bends.Count
  
  'Get the custom property set
  Dim oCustomProps As Inventor.PropertySet
  Set oCustomProps = oDoc.PropertySets.Item("Inventor User Defined Properties")
  
  'Define the name of the bend count iproperty name:
  Dim sBendPropName As String
  sBendPropName = "Bend Count"
  
  'See if we already have an iproperty for the bend count
  Dim oBendProp As Inventor.Property
  Dim oProp As Inventor.Property
  For Each oProp In oCustomProps
    If oProp.Name = sBendPropName Then
      'We already have an iproperty, we just need to write the new value
      Set oBendProp = oProp
      oBendProp.Value = iBendCount
      Exit Sub
    End If
  Next oProp
  
  'We don't have an iproperty, so we create it and set its value
  If oBendProp Is Nothing Then Set oBendProp = oCustomProps.Add(iBendCount, sBendPropName)
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Works great! Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed it a little, so i dont need to open each part as i usually do this from an assembly...&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2011 07:35:27 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-08-31T07:35:27Z</dc:date>
    <item>
      <title>Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3140396#M139354</link>
      <description>&lt;P&gt;Is there any VBA code that can count the number of bends used in a sheet metal part?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to make a custom property of this, so it can be exported to Excel for input in our ERP system&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2011 05:38:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3140396#M139354</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-30T05:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3141216#M139355</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Public Sub BendCountToIprop()
  'Get the part doc and sheet metal component defn.  No error handling:
  Dim oPartDocument As Inventor.PartDocument
  Set oPartDocument = ThisApplication.ActiveDocument
  Dim oSheetMetalComp As Inventor.SheetMetalComponentDefinition
  Set oSheetMetalComp = oPartDocument.ComponentDefinition
  
  'Get the bend count
  Dim iBendCount As Integer
  iBendCount = oSheetMetalComp.Bends.Count
  
  'Get the custom property set
  Dim oCustomProps As Inventor.PropertySet
  Set oCustomProps = oPartDocument.PropertySets.Item("Inventor User Defined Properties")
  
  'Define the name of the bend count iproperty name:
  Dim sBendPropName As String
  sBendPropName = "Bend Count"
  
  'See if we already have an iproperty for the bend count
  Dim oBendProp As Inventor.Property
  Dim oProp As Inventor.Property
  For Each oProp In oCustomProps
    If oProp.Name = sBendPropName Then
      'We already have an iproperty, we just need to write the new value
      Set oBendProp = oProp
      oBendProp.Value = iBendCount
      Exit Sub
    End If
  Next oProp
  
  'We don't have an iproperty, so we create it and set its value
  If oBendProp Is Nothing Then Set oBendProp = oCustomProps.Add(iBendCount, sBendPropName)
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Let me know if it works.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2011 17:14:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3141216#M139355</guid>
      <dc:creator>alewer</dc:creator>
      <dc:date>2011-08-30T17:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3141952#M139356</link>
      <description>&lt;PRE&gt;Public Sub BendCountToIprop()
  'Get the part doc and sheet metal component defn.  No error handling:
  Dim oApp As Inventor.Application
  Dim oDoc As Inventor.Document
  Set oApp = GetObject(, "Inventor.Application")
  If oApp.ActiveDocumentType = kDrawingDocumentObject Then
  Set oDoc = oApp.ActiveDocument
  Else: If TypeOf oApp.ActiveEditObject Is Sketch Then Exit Sub
  Set oDoc = oApp.ActiveEditObject
  End If
  Dim oSheetMetalComp As Inventor.SheetMetalComponentDefinition
  Set oSheetMetalComp = oDoc.ComponentDefinition
  
  'Get the bend count
  Dim iBendCount As Integer
  iBendCount = oSheetMetalComp.Bends.Count
  
  'Get the custom property set
  Dim oCustomProps As Inventor.PropertySet
  Set oCustomProps = oDoc.PropertySets.Item("Inventor User Defined Properties")
  
  'Define the name of the bend count iproperty name:
  Dim sBendPropName As String
  sBendPropName = "Bend Count"
  
  'See if we already have an iproperty for the bend count
  Dim oBendProp As Inventor.Property
  Dim oProp As Inventor.Property
  For Each oProp In oCustomProps
    If oProp.Name = sBendPropName Then
      'We already have an iproperty, we just need to write the new value
      Set oBendProp = oProp
      oBendProp.Value = iBendCount
      Exit Sub
    End If
  Next oProp
  
  'We don't have an iproperty, so we create it and set its value
  If oBendProp Is Nothing Then Set oBendProp = oCustomProps.Add(iBendCount, sBendPropName)
End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Works great! Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed it a little, so i dont need to open each part as i usually do this from an assembly...&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2011 07:35:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3141952#M139356</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-31T07:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3142376#M139357</link>
      <description>&lt;P&gt;There is one problem, if cut or hole cuts the bend line itll count it twice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2011 14:13:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3142376#M139357</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-31T14:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3142452#M139358</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;There is one problem, if cut or hole cuts the bend line itll count it twice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I can't get this behavior. &amp;nbsp;With the attached part (SixBends.ipt / Inventor 2010) try to get the bend count two ways: &amp;nbsp;as is, with end of part above Extrusion1 and Hole1, then with the end of part rolled all the way down. &amp;nbsp;For both cases, I get six bends.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you can upload a simple example file that shows this behavior I'd be curious, but unfortunately I'm still only on 2010...&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2011 14:54:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3142452#M139358</guid>
      <dc:creator>alewer</dc:creator>
      <dc:date>2011-08-31T14:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3143508#M139359</link>
      <description>&lt;P&gt;This only happens when the face is not connected after the bend, hard to explain...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Heres pic of what i mean, this part counts 7 bends.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2011 05:53:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3143508#M139359</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-09-01T05:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3144202#M139360</link>
      <description>&lt;P&gt;I see the issue: &amp;nbsp;on a long enough press brake, this would be formed with two bending operations. &amp;nbsp;But Inventor is counting a bend for each of the flange operations in the model. &amp;nbsp;You could incorporate some logic to remove from the count any colinear bends, but that will cause errors. &amp;nbsp;Open the attached file and walk with me...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To illustrate, let's look at three cases:&lt;/P&gt;&lt;P&gt;1-Real life bend count--how it is made in the shop&lt;/P&gt;&lt;P&gt;2-My code above (all Inventor bends)&lt;/P&gt;&lt;P&gt;3-Code that deducts colinear bend lines from Inventor's bend count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Look at the attached part. &amp;nbsp;For the three cases:&lt;/P&gt;&lt;P&gt;1-Three bends&lt;/P&gt;&lt;P&gt;2-Four bends&lt;/P&gt;&lt;P&gt;3-Two bends. &amp;nbsp;Two "real life" bending operations are required to accomplish what I created with Face4, but the bends are colinear!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am sure it is possible to come up with some more elaborate code to better calculate the number of bends, but you're probably looking at a &lt;EM&gt;lot&lt;/EM&gt;&amp;nbsp;more code, and I doubt you will ever be able to program something that's right every time.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2011 15:55:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3144202#M139360</guid>
      <dc:creator>alewer</dc:creator>
      <dc:date>2011-09-01T15:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3144924#M139361</link>
      <description>&lt;P&gt;I see what you mean...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;we dont have a lot these "problem" parts so its not a big issue...&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2011 07:38:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3144924#M139361</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-09-02T07:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3468280#M139362</link>
      <description>&lt;P&gt;I required the same type of macros for an assembly(If i run the Macros in an assembly i have to get the BendCount for all the parts). Is it possible?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2012 05:26:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/3468280#M139362</guid>
      <dc:creator>k14348</dc:creator>
      <dc:date>2012-05-23T05:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/5299595#M139363</link>
      <description>&lt;P&gt;Would anyone like to update this for 2014?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Sep 2014 21:41:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/5299595#M139363</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-09-25T21:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Counting bends?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/9752744#M139364</link>
      <description>&lt;P&gt;Can anyone please update the code, cause its not working.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 13:28:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/counting-bends/m-p/9752744#M139364</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-17T13:28:07Z</dc:date>
    </item>
  </channel>
</rss>

