<?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: Write Macro to Place Parts List  and then run ilogic rule on Drawing. in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10890949#M133693</link>
    <description>&lt;P&gt;It might be better to add the partslist directly with the API as with the command you would still need to position and set the style manually. &lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-automactly-place-parts-list/td-p/7354068" target="_blank" rel="noopener"&gt;Here&lt;/A&gt; is a forum post for that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is lots of settings to set up the parts list so &lt;A href="https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-CC993480-55C0-4C1C-9B2F-E522B879E990" target="_blank" rel="noopener"&gt;here&lt;/A&gt; is the API help as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the API sample.&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;This sample demonstrates the creation of a parts list. The parts list is placed at the top right corner of the border if one exists, else it is placed at the top right corner of the sheet. Code Samples&lt;DIV class=""&gt;&lt;UL&gt;&lt;LI&gt;&lt;A target="_blank"&gt;VBA&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;To run this sample, have a drawing document open. The active sheet in the drawing should have at least one drawing view and the first drawing view on the sheet should not be a draft view.&amp;nbsp;&lt;PRE&gt;Public Sub CreatePartsList()    
    On Error Resume Next
    
    &lt;SPAN&gt;' Set a reference to the drawing document.&lt;/SPAN&gt;
    &lt;SPAN&gt;' This assumes a drawing document is active.&lt;/SPAN&gt;
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    &lt;SPAN&gt;'Set a reference to the active sheet.&lt;/SPAN&gt;
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    &lt;SPAN&gt;' Set a reference to the first drawing view on&lt;/SPAN&gt;
    &lt;SPAN&gt;' the sheet. This assumes the first drawing&lt;/SPAN&gt;
    &lt;SPAN&gt;' view on the sheet is not a draft view.&lt;/SPAN&gt;
    Dim oDrawingView As DrawingView
    Set oDrawingView = oSheet.DrawingViews(1)
    
    &lt;SPAN&gt;' Set a reference to th sheet's border&lt;/SPAN&gt;
    Dim oBorder As Border
    Set oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    
    If Not oBorder Is Nothing Then
        &lt;SPAN&gt;' A border exists. The placement point&lt;/SPAN&gt;
        &lt;SPAN&gt;' is the top-right corner of the border.&lt;/SPAN&gt;
        Set oPlacementPoint = oBorder.RangeBox.MaxPoint
    Else
        &lt;SPAN&gt;' There is no border. The placement point&lt;/SPAN&gt;
        &lt;SPAN&gt;' is the top-right corner of the sheet.&lt;/SPAN&gt;
        Set oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.height)
    End If
    
    &lt;SPAN&gt;' Create the parts list.&lt;/SPAN&gt;
    Dim oPartsList As PartsList
    Set oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
End Sub&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 19 Jan 2022 15:51:15 GMT</pubDate>
    <dc:creator>A.Acheson</dc:creator>
    <dc:date>2022-01-19T15:51:15Z</dc:date>
    <item>
      <title>Write Macro to Place Parts List  and then run ilogic rule on Drawing.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10890835#M133691</link>
      <description>&lt;P&gt;I am trying to write a macro to first run the place Parts List command in a drawing. Once that parts list is place on the drawing it then runs an iLogic rule I wrote.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ilogic run runs fine when I run the macro but I can't figure out how to run the place parts list command first and then run the ilogic rule under after it is placed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure how to even add the "DrawingPartsListCmd"(I'm guessing this is the API call to place aparts list) to VB to make it run the command. Any help would be a huge help and I appreciate your time very much. If there is anything else wrong with the code I wrote or is not needed to run the ilogic rule please let me know. I basically put this together based on others posts in here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Code so far:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub BOMSort()
RuniLogic "BOMSort"
End Sub

Public Sub RuniLogic(ByVal RuleName As String)
Dim iLogicAuto As Object
Dim oDoc As Document

Set oDoc = ThisApplication.ActiveDocument
If oDoc Is Nothing Then
MsgBox "Missing Inventor Document"
Exit Sub
End If

Set iLogicAuto = GetiLogicAddin(ThisApplication)
If (iLogicAuto Is Nothing) Then Exit Sub

iLogicAuto.RunExternalRule oDoc, RuleName
End Sub

Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Set addIns = oApplication.ApplicationAddIns

'Find the add-in you are looking for
Dim addIn As ApplicationAddIn
On Error GoTo NotFound
Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")

If (addIn Is Nothing) Then Exit Function

addIn.Activate
Set GetiLogicAddin = addIn.Automation
Exit Function
NotFound:
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 15:20:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10890835#M133691</guid>
      <dc:creator>fred.markle</dc:creator>
      <dc:date>2022-01-19T15:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Write Macro to Place Parts List  and then run ilogic rule on Drawing.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10890949#M133693</link>
      <description>&lt;P&gt;It might be better to add the partslist directly with the API as with the command you would still need to position and set the style manually. &lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-automactly-place-parts-list/td-p/7354068" target="_blank" rel="noopener"&gt;Here&lt;/A&gt; is a forum post for that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is lots of settings to set up the parts list so &lt;A href="https://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-CC993480-55C0-4C1C-9B2F-E522B879E990" target="_blank" rel="noopener"&gt;here&lt;/A&gt; is the API help as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the API sample.&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;This sample demonstrates the creation of a parts list. The parts list is placed at the top right corner of the border if one exists, else it is placed at the top right corner of the sheet. Code Samples&lt;DIV class=""&gt;&lt;UL&gt;&lt;LI&gt;&lt;A target="_blank"&gt;VBA&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class=""&gt;To run this sample, have a drawing document open. The active sheet in the drawing should have at least one drawing view and the first drawing view on the sheet should not be a draft view.&amp;nbsp;&lt;PRE&gt;Public Sub CreatePartsList()    
    On Error Resume Next
    
    &lt;SPAN&gt;' Set a reference to the drawing document.&lt;/SPAN&gt;
    &lt;SPAN&gt;' This assumes a drawing document is active.&lt;/SPAN&gt;
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    &lt;SPAN&gt;'Set a reference to the active sheet.&lt;/SPAN&gt;
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    &lt;SPAN&gt;' Set a reference to the first drawing view on&lt;/SPAN&gt;
    &lt;SPAN&gt;' the sheet. This assumes the first drawing&lt;/SPAN&gt;
    &lt;SPAN&gt;' view on the sheet is not a draft view.&lt;/SPAN&gt;
    Dim oDrawingView As DrawingView
    Set oDrawingView = oSheet.DrawingViews(1)
    
    &lt;SPAN&gt;' Set a reference to th sheet's border&lt;/SPAN&gt;
    Dim oBorder As Border
    Set oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    
    If Not oBorder Is Nothing Then
        &lt;SPAN&gt;' A border exists. The placement point&lt;/SPAN&gt;
        &lt;SPAN&gt;' is the top-right corner of the border.&lt;/SPAN&gt;
        Set oPlacementPoint = oBorder.RangeBox.MaxPoint
    Else
        &lt;SPAN&gt;' There is no border. The placement point&lt;/SPAN&gt;
        &lt;SPAN&gt;' is the top-right corner of the sheet.&lt;/SPAN&gt;
        Set oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.height)
    End If
    
    &lt;SPAN&gt;' Create the parts list.&lt;/SPAN&gt;
    Dim oPartsList As PartsList
    Set oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
End Sub&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Jan 2022 15:51:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10890949#M133693</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2022-01-19T15:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Write Macro to Place Parts List  and then run ilogic rule on Drawing.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10892020#M133708</link>
      <description>&lt;P&gt;That is working perfectly, except one thing, I can't figure out is how to get it to go into the lower left corner instead.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 23:55:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10892020#M133708</guid>
      <dc:creator>fred.markle</dc:creator>
      <dc:date>2022-01-19T23:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Write Macro to Place Parts List  and then run ilogic rule on Drawing.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10892114#M133710</link>
      <description>&lt;P&gt;You will need to get the bottom left corner and then subtract the length of the revision block. Here is a sub routine to do that. Hopefully that works for you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Private&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Positiontable&lt;/SPAN&gt;(&lt;SPAN&gt;oSheet&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Sheet&lt;/SPAN&gt;)

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartsTable&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartsList&lt;/SPAN&gt;
&lt;SPAN&gt;Set&lt;/SPAN&gt; &lt;SPAN&gt;oPartsTable&lt;/SPAN&gt; = &lt;SPAN&gt;oSheet&lt;/SPAN&gt;.&lt;SPAN&gt;PartsLists&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(1)


&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oWidthPartsTable&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Double&lt;/SPAN&gt;
 &lt;SPAN&gt;oWidthPartsTable&lt;/SPAN&gt; = &lt;SPAN&gt;oPartsTable&lt;/SPAN&gt;.&lt;SPAN&gt;RangeBox&lt;/SPAN&gt;.&lt;SPAN&gt;MaxPoint&lt;/SPAN&gt;.&lt;SPAN&gt;X&lt;/SPAN&gt; - &lt;SPAN&gt;oPartsTable&lt;/SPAN&gt;.&lt;SPAN&gt;RangeBox&lt;/SPAN&gt;.&lt;SPAN&gt;MinPoint&lt;/SPAN&gt;.&lt;SPAN&gt;X&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oHeightPartsTable&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Double&lt;/SPAN&gt;
&lt;SPAN&gt;oHeightPartsTable&lt;/SPAN&gt; = &lt;SPAN&gt;oPartsTable&lt;/SPAN&gt;.&lt;SPAN&gt;RangeBox&lt;/SPAN&gt;.&lt;SPAN&gt;MaxPoint&lt;/SPAN&gt;.&lt;SPAN&gt;Y&lt;/SPAN&gt; - &lt;SPAN&gt;oPartsTable&lt;/SPAN&gt;.&lt;SPAN&gt;RangeBox&lt;/SPAN&gt;.&lt;SPAN&gt;MinPoint&lt;/SPAN&gt;.&lt;SPAN&gt;Y&lt;/SPAN&gt;

&lt;SPAN&gt;Set&lt;/SPAN&gt; &lt;SPAN&gt;oTablePt&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;.&lt;SPAN&gt;CreatePoint2d&lt;/SPAN&gt;(&lt;SPAN&gt;oSheet&lt;/SPAN&gt;.&lt;SPAN&gt;Border&lt;/SPAN&gt;.&lt;SPAN&gt;RangeBox&lt;/SPAN&gt;.&lt;SPAN&gt;MinPoint&lt;/SPAN&gt;.&lt;SPAN&gt;X&lt;/SPAN&gt; + &lt;SPAN&gt;oWidthPartsTable&lt;/SPAN&gt;, &lt;SPAN&gt;oSheet&lt;/SPAN&gt;.&lt;SPAN&gt;TitleBlock&lt;/SPAN&gt;.&lt;SPAN&gt;RangeBox&lt;/SPAN&gt;.&lt;SPAN&gt;MinPoint&lt;/SPAN&gt;.&lt;SPAN&gt;Y&lt;/SPAN&gt; + &lt;SPAN&gt;oHeightPartsTable&lt;/SPAN&gt;)

&lt;SPAN&gt;oPartsTable&lt;/SPAN&gt;.&lt;SPAN&gt;Position&lt;/SPAN&gt; = &lt;SPAN&gt;oTablePt&lt;/SPAN&gt;
    
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 00:51:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10892114#M133710</guid>
      <dc:creator>A.Acheson</dc:creator>
      <dc:date>2022-01-20T00:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Write Macro to Place Parts List  and then run ilogic rule on Drawing.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10904479#M133888</link>
      <description>&lt;P&gt;Got this all up and running. Figured I'd post this here in case anyone else wanted the code. Also added the option to Sort and enable "autosortonupdate".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Public Sub PlacePartsList()
    On Error Resume Next
    
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    'Set a reference to the active sheet.
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    ' Set a reference to the first drawing view on
    ' the sheet. This assumes the first drawing
    ' view on the sheet is not a draft view.
    Dim oDrawingView As DrawingView
    Set oDrawingView = oSheet.DrawingViews(1)
    
    ' Set a reference to th sheet's border
    Dim oBorder As Border
    Set oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    
    If Not oBorder Is Nothing Then
        ' A border exists. The placement point
        ' is the bottom-left corner of the border.
        Set oPlacementPoint = oBorder.RangeBox.MinPoint
    Else
        ' There is no border. The placement point
        ' is the bottom-left corner of the sheet.
        Set oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
    End If
    
    ' Create the parts list.
    Dim oPartsList As PartsList
    If oSheet.PartsLists.Count = 0 Then
        Set oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
    Else
        Set oPartsList = oSheet.PartsLists.Item(1)
    End If
    
    Dim oPartsListSize As Vector2d
    Set oPartsListSize = ThisApplication.TransientGeometry.CreateVector2d(0, 0)
    oPartsListSize.X = oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X
    oPartsListSize.Y = oPartsList.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MinPoint.Y
    
    oPlacementPoint.X = oPlacementPoint.X + oPartsListSize.X
    oPlacementPoint.Y = oPlacementPoint.Y + oPartsListSize.Y
    
    oPartsList.Position = oPlacementPoint
    
    'PartsList.Sort2( PrimaryColumnTitle As String, [PrimaryColumnAscending] As Boolean, [SecondaryColumnTitle] As String, [SecondaryColumnAscending] As Boolean, [TertiaryColumnTitle] As String, [TertiaryColumnAscending] As Boolean, [SortByString] As Boolean, [AutoSortOnUpdate] As Boolean )
    Call oPartsList.Sort2("ITEM", True, "PART NUMBER", True, "QTY", True, True, True)
    'Call oPartsList.Sort2("ITEM", True, AutoSortOnUpdate, True)

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 14:06:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/write-macro-to-place-parts-list-and-then-run-ilogic-rule-on/m-p/10904479#M133888</guid>
      <dc:creator>fred.markle</dc:creator>
      <dc:date>2022-01-25T14:06:38Z</dc:date>
    </item>
  </channel>
</rss>

