<?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 How to debug this automate drafting rule in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-debug-this-automate-drafting-rule/m-p/11995288#M153204</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I got this rule from a cool guy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this rule is purpose to generate drawing with file in every class&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main()
    Dim doc As AssemblyDocument = ThisDoc.Document
    Dim def As AssemblyComponentDefinition = doc.ComponentDefinition

    Dim dDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject)
    Dim sheet As Sheet = dDoc.ActiveSheet

    FillSheet(sheet, doc)

    For Each refDoc As Document In doc.AllReferencedDocuments
        Dim newSHeet = dDoc.Sheets.Add()
        FillSheet(newSHeet, refDoc)
    Next
End Sub

Private Sub FillSheet(sheet As Sheet, doc As Document)
    sheet.Name = doc.DisplayName
    Dim sheetW4 = sheet.Width / 4
    Dim sheetH4 = sheet.Height / 4

    Dim position As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4, sheetH4)
    Dim baseView As DrawingView = sheet.DrawingViews.AddBaseView(doc, position, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
    Dim scale = CalculateScale(baseView)

    position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4 * 3, sheetH4)
    Dim view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
    scale = Math.Min(scale, CalculateScale(view))

    position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4, sheetH4 * 3)
    view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
    scale = Math.Min(scale, CalculateScale(view))

    position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4 * 3, sheetH4 * 3)
    view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
    scale = Math.Min(scale, CalculateScale(view))

    baseView.Scale = scale
End Sub

Private Function CalculateScale(view As DrawingView) As Double
    Dim scaleX = view.Parent.Width / view.Width / 2
    Dim scaleY = view.Parent.Height / view.Height / 2
    Return Math.Min(scaleX, scaleY)
End Function&lt;/LI-CODE&gt;&lt;P&gt;I've run this rule and there is error on 26row&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ssiem12_0-1685335380109.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1220358i306E920B319E08B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ssiem12_0-1685335380109.png" alt="ssiem12_0-1685335380109.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could any guy help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;additionally it generate sheet with size A and i use size A3 usually can i change this setting?&lt;/P&gt;&lt;P&gt;and I will use this like run this rule and generate sheets and copy these sheets then past it on my drawing file that I'm working&lt;/P&gt;&lt;P&gt;but the style is not updated so line color is not fit like below&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ssiem12_1-1685335782514.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1220361iFC26736A524534E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ssiem12_1-1685335782514.png" alt="ssiem12_1-1685335782514.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;above is a drawing made from sheet generated by rule&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ssiem12_2-1685335818564.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1220362i5EB666075BF07CFB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ssiem12_2-1685335818564.png" alt="ssiem12_2-1685335818564.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;above is pasted on my working drawing file&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ssiem12_3-1685335842767.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1220363iBF3449035E3F1F1A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ssiem12_3-1685335842767.png" alt="ssiem12_3-1685335842767.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;above is a style I use usually on my working drawing file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 May 2023 04:52:54 GMT</pubDate>
    <dc:creator>ssiem12</dc:creator>
    <dc:date>2023-05-29T04:52:54Z</dc:date>
    <item>
      <title>How to debug this automate drafting rule</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-debug-this-automate-drafting-rule/m-p/11995288#M153204</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I got this rule from a cool guy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this rule is purpose to generate drawing with file in every class&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main()
    Dim doc As AssemblyDocument = ThisDoc.Document
    Dim def As AssemblyComponentDefinition = doc.ComponentDefinition

    Dim dDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject)
    Dim sheet As Sheet = dDoc.ActiveSheet

    FillSheet(sheet, doc)

    For Each refDoc As Document In doc.AllReferencedDocuments
        Dim newSHeet = dDoc.Sheets.Add()
        FillSheet(newSHeet, refDoc)
    Next
End Sub

Private Sub FillSheet(sheet As Sheet, doc As Document)
    sheet.Name = doc.DisplayName
    Dim sheetW4 = sheet.Width / 4
    Dim sheetH4 = sheet.Height / 4

    Dim position As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4, sheetH4)
    Dim baseView As DrawingView = sheet.DrawingViews.AddBaseView(doc, position, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
    Dim scale = CalculateScale(baseView)

    position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4 * 3, sheetH4)
    Dim view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
    scale = Math.Min(scale, CalculateScale(view))

    position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4, sheetH4 * 3)
    view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
    scale = Math.Min(scale, CalculateScale(view))

    position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4 * 3, sheetH4 * 3)
    view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
    scale = Math.Min(scale, CalculateScale(view))

    baseView.Scale = scale
End Sub

Private Function CalculateScale(view As DrawingView) As Double
    Dim scaleX = view.Parent.Width / view.Width / 2
    Dim scaleY = view.Parent.Height / view.Height / 2
    Return Math.Min(scaleX, scaleY)
End Function&lt;/LI-CODE&gt;&lt;P&gt;I've run this rule and there is error on 26row&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ssiem12_0-1685335380109.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1220358i306E920B319E08B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ssiem12_0-1685335380109.png" alt="ssiem12_0-1685335380109.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could any guy help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;additionally it generate sheet with size A and i use size A3 usually can i change this setting?&lt;/P&gt;&lt;P&gt;and I will use this like run this rule and generate sheets and copy these sheets then past it on my drawing file that I'm working&lt;/P&gt;&lt;P&gt;but the style is not updated so line color is not fit like below&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ssiem12_1-1685335782514.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1220361iFC26736A524534E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ssiem12_1-1685335782514.png" alt="ssiem12_1-1685335782514.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;above is a drawing made from sheet generated by rule&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ssiem12_2-1685335818564.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1220362i5EB666075BF07CFB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ssiem12_2-1685335818564.png" alt="ssiem12_2-1685335818564.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;above is pasted on my working drawing file&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ssiem12_3-1685335842767.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1220363iBF3449035E3F1F1A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ssiem12_3-1685335842767.png" alt="ssiem12_3-1685335842767.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;above is a style I use usually on my working drawing file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 04:52:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-debug-this-automate-drafting-rule/m-p/11995288#M153204</guid>
      <dc:creator>ssiem12</dc:creator>
      <dc:date>2023-05-29T04:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug this automate drafting rule</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-debug-this-automate-drafting-rule/m-p/11996784#M153213</link>
      <description>&lt;P&gt;I changed the code a bit and you should not get the exception any more. About the styles; the code uses your default drawing template I guess you use another template. In the code a line (6) where you can set the full file name of the template that you want to use.&lt;/P&gt;
&lt;LI-CODE lang="visual-basic"&gt;Sub Main()
    Dim doc As AssemblyDocument = ThisDoc.Document
    Dim def As AssemblyComponentDefinition = doc.ComponentDefinition

    ' Change this if you dont want to use the default template
    Dim templateFileName As String = ""

    Dim dDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, templateFileName)
    Dim sheet As Sheet = dDoc.ActiveSheet

    FillSheet(sheet, doc)

    For Each refDoc As Document In doc.AllReferencedDocuments
        Dim newSHeet = dDoc.Sheets.Add()
        FillSheet(newSHeet, refDoc)
    Next
End Sub

Private Sub FillSheet(sheet As Sheet, doc As Document)
    sheet.Name = doc.DisplayName
    Dim sheetW4 = sheet.Width / 4
    Dim sheetH4 = sheet.Height / 4

    Try
        Dim position As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4, sheetH4)
        Dim baseView As DrawingView = sheet.DrawingViews.AddBaseView(doc, position, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
        Dim scale = CalculateScale(baseView)
        baseView.Scale = scale

        position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4 * 3, sheetH4)
        Dim view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, scale)
        scale = Math.Min(scale, CalculateScale(view))

        position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4, sheetH4 * 3)
        view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, scale)
        scale = Math.Min(scale, CalculateScale(view))

        position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4 * 3, sheetH4 * 3)
        view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle, scale)
        scale = Math.Min(scale, CalculateScale(view))

        baseView.Scale = scale
        view.Scale = scale
    Catch ex As Exception
        MsgBox("Something went wrong while creating sheet for model: " &amp;amp; doc.DisplayName)
        Return
    End Try
End Sub

Private Function CalculateScale(view As DrawingView) As Double
    Dim scaleX = view.Parent.Width / view.Width / 2
    Dim scaleY = view.Parent.Height / view.Height / 2
    Return Math.Min(scaleX, scaleY)
End Function&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 19:25:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-debug-this-automate-drafting-rule/m-p/11996784#M153213</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2023-05-29T19:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug this automate drafting rule</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-debug-this-automate-drafting-rule/m-p/11997344#M153222</link>
      <description>&lt;P&gt;are you god of programming?&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 04:36:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/how-to-debug-this-automate-drafting-rule/m-p/11997344#M153222</guid>
      <dc:creator>ssiem12</dc:creator>
      <dc:date>2023-05-30T04:36:32Z</dc:date>
    </item>
  </channel>
</rss>

