<?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: Sheet Metal Drawing automation in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/sheet-metal-drawing-automation/m-p/12008180#M22916</link>
    <description>&lt;P&gt;This rule is not finished (but I'm tired.) I guess that this does most of what you are looking for. Give it a try:&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Sub Main()

    Dim doc As AssemblyDocument = ThisDoc.Document

    For Each refDoc As Document In doc.AllReferencedDocuments
        If (IsSheetmetal(refDoc) = False) Then Return

        Dim drawing = CreateNewDrawing()
        Dim flatView = CreateFlatpatternView(drawing.ActiveSheet, refDoc)
        Dim isoView = CreateIsoView(drawing.ActiveSheet, refDoc)
    Next
End Sub

Public Function IsSheetmetal(doc As Document) As Boolean
    Return doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
End Function

Public Function CreateNewDrawing() As DrawingDocument
    Dim templateFileName = "C:\Users\Public\Documents\Autodesk\Inventor 2023\Templates\en-US\Metric\ANSI (mm).idw"
    Return ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templateFileName)
End Function

Public Function CreateFlatpatternView(sheet As Sheet, doc As Document) As DrawingView
    Dim point = CreatePoint(17.5, 22.2)

    Dim nvm = ThisApplication.TransientObjects.CreateNameValueMap()
    nvm.Add("SheetMetalFoldedModel", False)

    Dim view = sheet.DrawingViews.AddBaseView(doc, point, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "VIEW1",, nvm)

    SetScale(view)
    view.Center = point
    AddBendNotes(view)
    Return view
End Function

Public Function CreateIsoView(sheet As Sheet, doc As Document) As DrawingView
    Dim point = CreatePoint(45, 26.25)

    Dim view = sheet.DrawingViews.AddBaseView(doc, point, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "VIEW2")

    SetScale(view)
    view.Center = point
    Return view
End Function

Public Sub SetScale(view As DrawingView)
    view.Scale = 1

    If (view.Height &amp;lt; 25) Then
        view.Scale = 0.6
    ElseIf (view.Height &amp;lt; 500) Then
        view.Scale = 0.4
    ElseIf (view.Height &amp;lt; 1000) Then
        view.Scale = 1 / 4.5
    End If

End Sub

Public Function CreatePoint(x As Double, y As Double)
    Return ThisApplication.TransientGeometry.CreatePoint2d(x, y)
End Function

Public Sub AddBendNotes(view As DrawingView)
    Dim sheet = view.Parent

    For Each curve In view.DrawingCurves
        If (curve.EdgeType = DrawingEdgeTypeEnum.kBendDownEdge Or
                curve.EdgeType = DrawingEdgeTypeEnum.kBendUpEdge) Then

            sheet.DrawingNotes.BendNotes.Add(curve)
        End If
    Next

End Sub
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jun 2023 22:05:23 GMT</pubDate>
    <dc:creator>JelteDeJong</dc:creator>
    <dc:date>2023-06-02T22:05:23Z</dc:date>
    <item>
      <title>Sheet Metal Drawing automation</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/sheet-metal-drawing-automation/m-p/12006768#M22915</link>
      <description>&lt;P&gt;IS THERE ANY POSSIBITY TO AUTOMATE THIS PROCESS?&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;FROM ASSEMBLY OPEN SHEETMETAL COMPONENTS ONE BY ONE&lt;/LI&gt;&lt;LI&gt;OPEN DRAFTING FILE ANSI.idw (PATH - "C:\Users\Public\Documents\Autodesk\Inventor 2023\Templates\en-US\Metric\ANSI (mm).idw")&lt;/LI&gt;&lt;LI&gt;VIEW1 = PLACE BASE VIEW (Flat Pattern (Sheet Metal View)) &amp;nbsp;(Style = Hidden Line Removed)&lt;/LI&gt;&lt;LI&gt;VIEW2 = PLACE ISOMATRIC VIEW (Style = Hidden Line Removed)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;FOR THE SCALE AND POSITION OF THIS TWO VIEW CONSIDE FOLLOWING CODE&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="general"&gt;If ActiveSheet.View("VIEW1").Height &amp;lt; 250 Then

        ActiveSheet.View("VIEW1").Scale = 0.6

        ActiveSheet.View("VIEW1").SetCenter(175, 222)

        ActiveSheet.View("VIEW2").SetCenter(450,262.5)

       

ElseIf ActiveSheet.View("VIEW1").Height &amp;lt; 500 Then

        ActiveSheet.View("VIEW1").Scale = 0.4

        ActiveSheet.View("VIEW1").SetCenter(175, 222)

        ActiveSheet.View("VIEW2").SetCenter(450,262.5)

       

ElseIf ActiveSheet.View("VIEW1").Height &amp;lt; 1000 Then

        ActiveSheet.View("VIEW1").Scale = 1/4.5

        ActiveSheet.View("VIEW1").SetCenter(175, 222)

        ActiveSheet.View("VIEW2").SetCenter(450,262.5)

       

End If

ActiveSheet.View("VIEW2").Scale = ActiveSheet.View("VIEW1").Scale
&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;GIVE BEND ANNOTATION (FOR BEND ANNOTATION USE FOLLOWING CODE)&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="general"&gt;Dim oDoc As DrawingDocument
Dim oSheet As Sheet
Dim oView As DrawingView
Dim oCurve As DrawingCurve
Dim oBendNote As BendNote
Dim BendNoteCount As Integer

oDoc = ThisApplication.ActiveDocument
oSheet = oDoc.ActiveSheet
BendNoteCount = oSheet.DrawingNotes.BendNotes.Count

If BendNoteCount=0 Then
    '[add bend notes to views
	For Each oView In oSheet.DrawingViews
	 For Each oCurve In oView.DrawingCurves
	  If oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendDownEdge _
	  Or oCurve.EdgeType = Inventor.DrawingEdgeTypeEnum.kBendUpEdge Then
		' Create the bend note
		oBendNote = oSheet.DrawingNotes.BendNotes.Add(oCurve)
	  End If
	 Next 'oCurve
	Next ']oView
	Else
	'do nothing
End If&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;SAVE IDW FILE (IF POSSIBLE, FILE NAME SHOULD BE LIKE &amp;lt;PART NO&amp;gt; &amp;amp; &amp;lt;MATERIAL&amp;gt; &amp;amp; &amp;lt;THIKNESS&amp;gt;&lt;/LI&gt;&lt;LI&gt;EXPORT DWG FILE WITH SAME NAME&lt;/LI&gt;&lt;LI&gt;EXPORT PDF FILE WITH SAME NAME&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SAVE THESE FILES IN TO SAME FOLDER&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 10:29:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/sheet-metal-drawing-automation/m-p/12006768#M22915</guid>
      <dc:creator>jaimin.ja.3</dc:creator>
      <dc:date>2023-06-02T10:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sheet Metal Drawing automation</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/sheet-metal-drawing-automation/m-p/12008180#M22916</link>
      <description>&lt;P&gt;This rule is not finished (but I'm tired.) I guess that this does most of what you are looking for. Give it a try:&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Sub Main()

    Dim doc As AssemblyDocument = ThisDoc.Document

    For Each refDoc As Document In doc.AllReferencedDocuments
        If (IsSheetmetal(refDoc) = False) Then Return

        Dim drawing = CreateNewDrawing()
        Dim flatView = CreateFlatpatternView(drawing.ActiveSheet, refDoc)
        Dim isoView = CreateIsoView(drawing.ActiveSheet, refDoc)
    Next
End Sub

Public Function IsSheetmetal(doc As Document) As Boolean
    Return doc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
End Function

Public Function CreateNewDrawing() As DrawingDocument
    Dim templateFileName = "C:\Users\Public\Documents\Autodesk\Inventor 2023\Templates\en-US\Metric\ANSI (mm).idw"
    Return ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templateFileName)
End Function

Public Function CreateFlatpatternView(sheet As Sheet, doc As Document) As DrawingView
    Dim point = CreatePoint(17.5, 22.2)

    Dim nvm = ThisApplication.TransientObjects.CreateNameValueMap()
    nvm.Add("SheetMetalFoldedModel", False)

    Dim view = sheet.DrawingViews.AddBaseView(doc, point, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "VIEW1",, nvm)

    SetScale(view)
    view.Center = point
    AddBendNotes(view)
    Return view
End Function

Public Function CreateIsoView(sheet As Sheet, doc As Document) As DrawingView
    Dim point = CreatePoint(45, 26.25)

    Dim view = sheet.DrawingViews.AddBaseView(doc, point, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "VIEW2")

    SetScale(view)
    view.Center = point
    Return view
End Function

Public Sub SetScale(view As DrawingView)
    view.Scale = 1

    If (view.Height &amp;lt; 25) Then
        view.Scale = 0.6
    ElseIf (view.Height &amp;lt; 500) Then
        view.Scale = 0.4
    ElseIf (view.Height &amp;lt; 1000) Then
        view.Scale = 1 / 4.5
    End If

End Sub

Public Function CreatePoint(x As Double, y As Double)
    Return ThisApplication.TransientGeometry.CreatePoint2d(x, y)
End Function

Public Sub AddBendNotes(view As DrawingView)
    Dim sheet = view.Parent

    For Each curve In view.DrawingCurves
        If (curve.EdgeType = DrawingEdgeTypeEnum.kBendDownEdge Or
                curve.EdgeType = DrawingEdgeTypeEnum.kBendUpEdge) Then

            sheet.DrawingNotes.BendNotes.Add(curve)
        End If
    Next

End Sub
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 22:05:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/sheet-metal-drawing-automation/m-p/12008180#M22916</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2023-06-02T22:05:23Z</dc:date>
    </item>
  </channel>
</rss>

