Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
fred.markle
398 Views, 4 Replies

Write Macro to Place Parts List and then run ilogic rule on Drawing.

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.

 

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.

 

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.

 

My Code so far:

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