Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic automactly place parts list

22 REPLIES 22
SOLVED
Reply
Message 1 of 23
Anonymous
7085 Views, 22 Replies

ilogic automactly place parts list

Anonymous
Not applicable

Hi All,

 

When placing a base view, I would like to have the part list inmediatly placed on the top right border. I have different parts list styles. One for assemblies, and one for individual parts. Is there a way to also incorporate this in the Ilogic rule?

 

Thanks

0 Likes

ilogic automactly place parts list

Hi All,

 

When placing a base view, I would like to have the part list inmediatly placed on the top right border. I have different parts list styles. One for assemblies, and one for individual parts. Is there a way to also incorporate this in the Ilogic rule?

 

Thanks

22 REPLIES 22
Message 2 of 23
waynehelley
in reply to: Anonymous

waynehelley
Collaborator
Collaborator
Accepted solution

Sorry that its a bit messy but here is some logic I wrote a long time ago for placing a Parts List.  I'm not quite sure how you would go about getting the logic to automatically trigger when you place a drawing view.

 

Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
    
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet

'Detect if the template has a parts list
Try 
Dim oPartslistCheck As PartsList
oPartslistCheck = oSheet.PartsLists(1)
partslistpresent=True
Catch
partslistpresent=False
End Try

If partslistpresent=True
        
        'Delete the current parts list
        Dim oPartsList As PartsList
        oPartsList = oDrawingDoc.ActiveSheet.PartsLists.Item(1)
        oPartsList.Delete
        
End If
                
    ' 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
    oDrawingView = oSheet.DrawingViews(1)
    
    ' Set a reference to the sheet's border
    Dim oBorder As Border
    oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    
        xrev = oBorder.RangeBox.MaxPoint.X
        yrev = oBorder.RangeBox.MaxPoint.Y
        
        oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
        
    ' Create the parts list.
    Dim oPartsList1 As PartsList
    oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
oPartsLis1t = oDrawingDoc.ActiveSheet.PartsLists.Item(1)


oPartsList1.Sort("PART NUMBER")
oPartsList1.Renumber

oPartsList1.Style.UpdateFromGlobal 

'Switch style back and forth to ensure style is up-to-date oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ANSI)") oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ISO)") InventorVb.DocumentUpdate()

 

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit

Sorry that its a bit messy but here is some logic I wrote a long time ago for placing a Parts List.  I'm not quite sure how you would go about getting the logic to automatically trigger when you place a drawing view.

 

Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
    
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet

'Detect if the template has a parts list
Try 
Dim oPartslistCheck As PartsList
oPartslistCheck = oSheet.PartsLists(1)
partslistpresent=True
Catch
partslistpresent=False
End Try

If partslistpresent=True
        
        'Delete the current parts list
        Dim oPartsList As PartsList
        oPartsList = oDrawingDoc.ActiveSheet.PartsLists.Item(1)
        oPartsList.Delete
        
End If
                
    ' 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
    oDrawingView = oSheet.DrawingViews(1)
    
    ' Set a reference to the sheet's border
    Dim oBorder As Border
    oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    
        xrev = oBorder.RangeBox.MaxPoint.X
        yrev = oBorder.RangeBox.MaxPoint.Y
        
        oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
        
    ' Create the parts list.
    Dim oPartsList1 As PartsList
    oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
oPartsLis1t = oDrawingDoc.ActiveSheet.PartsLists.Item(1)


oPartsList1.Sort("PART NUMBER")
oPartsList1.Renumber

oPartsList1.Style.UpdateFromGlobal 

'Switch style back and forth to ensure style is up-to-date oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ANSI)") oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ISO)") InventorVb.DocumentUpdate()

 

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 3 of 23
Anonymous
in reply to: waynehelley

Anonymous
Not applicable
Accepted solution

Thank you for this code. Placing the parts list works well. But regardless if it is an .iam or .ipt, it still places the parts list with the same style. Can you help me with that last part

0 Likes

Thank you for this code. Placing the parts list works well. But regardless if it is an .iam or .ipt, it still places the parts list with the same style. Can you help me with that last part

Message 4 of 23
waynehelley
in reply to: Anonymous

waynehelley
Collaborator
Collaborator
Accepted solution

Using something like this should work.

 

Dim oRefDocType As DocumentTypeEnum

oRefDocType = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocumentType

 

Select Case oRefDocType

Case DocumentTypeEnum.kPartDocumentObject

   MsgBox("This is a part")

Case DocumentTypeEnum.kAssemblyDocumentObject

    MsgBox("This is an assembly")

End Select

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit

Using something like this should work.

 

Dim oRefDocType As DocumentTypeEnum

oRefDocType = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocumentType

 

Select Case oRefDocType

Case DocumentTypeEnum.kPartDocumentObject

   MsgBox("This is a part")

Case DocumentTypeEnum.kAssemblyDocumentObject

    MsgBox("This is an assembly")

End Select

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 5 of 23
Anonymous
in reply to: waynehelley

Anonymous
Not applicable

Thanks!!!

0 Likes

Thanks!!!

Message 6 of 23
Anonymous
in reply to: waynehelley

Anonymous
Not applicable

Any idea's why this wouldn't work with Inventor 2018?

 

It fails on this line

 

 oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

 

0 Likes

Any idea's why this wouldn't work with Inventor 2018?

 

It fails on this line

 

 oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

 

Message 7 of 23
MechMachineMan
in reply to: Anonymous

MechMachineMan
Advisor
Advisor

@Anonymous

 

There could be a lot of reasons, which I addressed in the other thread. But a more wordy reasoning of why it might not work:

 

1. The variable you are trying to assign it to is not the proper type for what the function returns - or the function may not even be a function, and may have no return value, in which case it also wouldn't work. If you were to have oPartsList1 typed as anything but a parts list somewhere else in the code, it wouldn't work.

 

2. You are not providing a proper "parent" for the function call. If oSheet is not in fact a Sheet, it would not work.

 

3. The parameters you are trying to pass the method call are not proper. You need to look up the documentation in the API regarding this as it is different for every method, and there are often exceptions that are documented there ****** THIS IS VERY OFTEN THE CASE****

 

4. You could have things spelled wrong.

 

5. There could be invisible characters on the line

 

6. Syntax could be wrong depending if you are using VB or VBA

 

7. It could just be an invalid method/operation - which kind of goes back to Item 2. If the oSheet belongs to a drawing document that already has a different type of partslist placed somewhere, it could also fail.

 

8. The things you are doing are not possible through the UI for valid reasons... Sometimes you can do extra things through API that you can't through UI, but the default assumption should be that if you can't do the steps through the UI without error, then you probably can't do it through the API without error.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes

@Anonymous

 

There could be a lot of reasons, which I addressed in the other thread. But a more wordy reasoning of why it might not work:

 

1. The variable you are trying to assign it to is not the proper type for what the function returns - or the function may not even be a function, and may have no return value, in which case it also wouldn't work. If you were to have oPartsList1 typed as anything but a parts list somewhere else in the code, it wouldn't work.

 

2. You are not providing a proper "parent" for the function call. If oSheet is not in fact a Sheet, it would not work.

 

3. The parameters you are trying to pass the method call are not proper. You need to look up the documentation in the API regarding this as it is different for every method, and there are often exceptions that are documented there ****** THIS IS VERY OFTEN THE CASE****

 

4. You could have things spelled wrong.

 

5. There could be invisible characters on the line

 

6. Syntax could be wrong depending if you are using VB or VBA

 

7. It could just be an invalid method/operation - which kind of goes back to Item 2. If the oSheet belongs to a drawing document that already has a different type of partslist placed somewhere, it could also fail.

 

8. The things you are doing are not possible through the UI for valid reasons... Sometimes you can do extra things through API that you can't through UI, but the default assumption should be that if you can't do the steps through the UI without error, then you probably can't do it through the API without error.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 8 of 23
milan5
in reply to: MechMachineMan

milan5
Enthusiast
Enthusiast

HI,

 

My name is Milan.

I am new to API and codes, recently tried this code for BOM placing in inventor but didnot work for me. 

Can anyone guide me how to exactly run this code.

 

Regads,

Milan Kantaria   

 

0 Likes

HI,

 

My name is Milan.

I am new to API and codes, recently tried this code for BOM placing in inventor but didnot work for me. 

Can anyone guide me how to exactly run this code.

 

Regads,

Milan Kantaria   

 

Message 9 of 23
MechMachineMan
in reply to: milan5

MechMachineMan
Advisor
Advisor

@milan5 Google is the most powerful tool of the 21st century, and if you use proper keywords, you can usually find answers to your questions.

 

For Example, if I google "Autodesk Inventor + iLogic + how to use rule"

the first link that pops up is quite valuable. As is the 2nd link, and so on and so forth.

 

There are also tutorials done by Autodesk on the topic.

 

 

However, noted below is also pretty much the exact same steps that 

 

Step 1: Identify if code is VB or VBA:

           - There are no variable assignment lines that begin with "set", so we can guess this is likely vb.net - which is used in the rule environment.

 

Step 2: Enable the iLogic browser.

           - In the ribbon bar: Tools > Addins. Ensure iLogic is set to load automatically, and is loaded.

           - Also in the ribbon bar (while you have a document open:): View > User Interface. Ensure iLogic Browser is checked

 

Step 3:

          - Copy the code from the forums.

 

Step 4:

         - In the iLogic Browser, go to the external rules tab.

         - Right click the "Standard Directories"

         - Click "Create New External Rule"

         - Establish the file name

         - Paste the copied code from the forums into the rule editor window that pops up.

         - Click Save

         - Close the rule dialog

 

Step 5:

         - Right click the rule name in the iLogic browser

         - Click "Run Rule"


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type

@milan5 Google is the most powerful tool of the 21st century, and if you use proper keywords, you can usually find answers to your questions.

 

For Example, if I google "Autodesk Inventor + iLogic + how to use rule"

the first link that pops up is quite valuable. As is the 2nd link, and so on and so forth.

 

There are also tutorials done by Autodesk on the topic.

 

 

However, noted below is also pretty much the exact same steps that 

 

Step 1: Identify if code is VB or VBA:

           - There are no variable assignment lines that begin with "set", so we can guess this is likely vb.net - which is used in the rule environment.

 

Step 2: Enable the iLogic browser.

           - In the ribbon bar: Tools > Addins. Ensure iLogic is set to load automatically, and is loaded.

           - Also in the ribbon bar (while you have a document open:): View > User Interface. Ensure iLogic Browser is checked

 

Step 3:

          - Copy the code from the forums.

 

Step 4:

         - In the iLogic Browser, go to the external rules tab.

         - Right click the "Standard Directories"

         - Click "Create New External Rule"

         - Establish the file name

         - Paste the copied code from the forums into the rule editor window that pops up.

         - Click Save

         - Close the rule dialog

 

Step 5:

         - Right click the rule name in the iLogic browser

         - Click "Run Rule"


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 10 of 23
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

I know this is an old thread but I was reading through and saw that the question regarding the error on the "PartsLists.Add()" line may not have gotten an answer.  If you're doing this in VBA you'll need to put a "Set" keyword in front of that line.  It should look something like this:

Set oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
0 Likes

I know this is an old thread but I was reading through and saw that the question regarding the error on the "PartsLists.Add()" line may not have gotten an answer.  If you're doing this in VBA you'll need to put a "Set" keyword in front of that line.  It should look something like this:

Set oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
Message 11 of 23
galin.filipov
in reply to: Anonymous

galin.filipov
Explorer
Explorer

Try this code instead of the short one.

 

oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint, PartsListLevelEnum.kStructuredAllLevels)

It works in my case. You need to add  "PartsListLevelEnum. ...." .

0 Likes

Try this code instead of the short one.

 

oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint, PartsListLevelEnum.kStructuredAllLevels)

It works in my case. You need to add  "PartsListLevelEnum. ...." .

Message 12 of 23
Anonymous
in reply to: waynehelley

Anonymous
Not applicable

@waynehelley , What i have to do to move partlist to top left corner.

Thank

0 Likes

@waynehelley , What i have to do to move partlist to top left corner.

Thank

Message 13 of 23
waynehelley
in reply to: Anonymous

waynehelley
Collaborator
Collaborator

Hi,

 

I think you would just need to replace 'MaxPoint' with 'MinPoint' for the x-axis.

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
0 Likes

Hi,

 

I think you would just need to replace 'MaxPoint' with 'MinPoint' for the x-axis.

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 14 of 23
Anonymous
in reply to: waynehelley

Anonymous
Not applicable

@waynehelley , i already repalced but the position seems still wrong like this

 

image.png

I think we need to calculate partlists frame size then + with it, but when i replaced this

xrev = oBorder.RangeBox.MinPoint.X 

by this one

xrev = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X)

then run rule it said

Error on Line 37 : 'oPartsList' is not declared. It may be inaccessible due to its protection level.

 

ngoc1357_0-1598854782678.png

 

 

here is my code

Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
    
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet

'Detect if the template has a parts list
Try 
Dim oPartslistCheck As PartsList
oPartslistCheck = oSheet.PartsLists(1)
partslistpresent=True
Catch
partslistpresent=False
End Try

If partslistpresent=True
        
        'Delete the current parts list
        Dim oPartsList As PartsList
        oPartsList = oDrawingDoc.ActiveSheet.PartsLists.Item(1)
        oPartsList.Delete
        
End If
                
    ' 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
    oDrawingView = oSheet.DrawingViews(1)
    
    ' Set a reference to the sheet's border
    Dim oBorder As Border
    oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    
        xrev = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X)
        yrev = oBorder.RangeBox.MaxPoint.Y
        
        oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
        
    ' Create the parts list.
    Dim oPartsList1 As PartsList
    oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
oPartsLis1t = oDrawingDoc.ActiveSheet.PartsLists.Item(1)


oPartsList1.Sort("PART NUMBER")
oPartsList1.Renumber

oPartsList1.Style.UpdateFromGlobal 

'Switch style back and forth to ensure style is up-to-date    
    oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ANSI)")
    oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ISO)")

InventorVb.DocumentUpdate()
 
0 Likes

@waynehelley , i already repalced but the position seems still wrong like this

 

image.png

I think we need to calculate partlists frame size then + with it, but when i replaced this

xrev = oBorder.RangeBox.MinPoint.X 

by this one

xrev = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X)

then run rule it said

Error on Line 37 : 'oPartsList' is not declared. It may be inaccessible due to its protection level.

 

ngoc1357_0-1598854782678.png

 

 

here is my code

Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
    
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet

'Detect if the template has a parts list
Try 
Dim oPartslistCheck As PartsList
oPartslistCheck = oSheet.PartsLists(1)
partslistpresent=True
Catch
partslistpresent=False
End Try

If partslistpresent=True
        
        'Delete the current parts list
        Dim oPartsList As PartsList
        oPartsList = oDrawingDoc.ActiveSheet.PartsLists.Item(1)
        oPartsList.Delete
        
End If
                
    ' 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
    oDrawingView = oSheet.DrawingViews(1)
    
    ' Set a reference to the sheet's border
    Dim oBorder As Border
    oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    
        xrev = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X)
        yrev = oBorder.RangeBox.MaxPoint.Y
        
        oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
        
    ' Create the parts list.
    Dim oPartsList1 As PartsList
    oPartsList1 = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
oPartsLis1t = oDrawingDoc.ActiveSheet.PartsLists.Item(1)


oPartsList1.Sort("PART NUMBER")
oPartsList1.Renumber

oPartsList1.Style.UpdateFromGlobal 

'Switch style back and forth to ensure style is up-to-date    
    oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ANSI)")
    oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ISO)")

InventorVb.DocumentUpdate()
 
Message 15 of 23
JBerns
in reply to: galin.filipov

JBerns
Advisor
Advisor
@galin.filipov,

Thank you for your suggestion to add the PartsListLevelEnum option.
I had similar code to above which worked for most assemblies, but failed on a few.
The few that failed I discovered had BOM 'Structured' and 'Parts Only' tabs both enabled.
Apparently the iLogic code could not decide which level to use.
Problem solved with your code. Well done!

Regards,
Jerry
-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes

@galin.filipov,

Thank you for your suggestion to add the PartsListLevelEnum option.
I had similar code to above which worked for most assemblies, but failed on a few.
The few that failed I discovered had BOM 'Structured' and 'Parts Only' tabs both enabled.
Apparently the iLogic code could not decide which level to use.
Problem solved with your code. Well done!

Regards,
Jerry
-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 16 of 23
JBerns
in reply to: galin.filipov

JBerns
Advisor
Advisor
Our top-level assemblies use BOM 'Structured', while most subassemblies use BOM 'Parts Only'.
I will need to test the assembly to see which level is available.
'StructuredAllLevels' option seems to fail if that BOM tab has not been enabled in the assembly.
I am using Try-Catch statements, but will search for a better solution.
-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes

Our top-level assemblies use BOM 'Structured', while most subassemblies use BOM 'Parts Only'.
I will need to test the assembly to see which level is available.
'StructuredAllLevels' option seems to fail if that BOM tab has not been enabled in the assembly.
I am using Try-Catch statements, but will search for a better solution.
-----------------------------------------------------------------------------------------
CAD Administrator
Using Inventor 2022
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
Message 17 of 23
JMGunnar
in reply to: JBerns

JMGunnar
Advocate
Advocate

i found too solve error 

switch in viewproperites  to firstlevel 

 

Best Regards Johan 

 

@JBerns 

 

 

ViewProperties.PNG

 

ViewProperties2.PNG

0 Likes

i found too solve error 

switch in viewproperites  to firstlevel 

 

Best Regards Johan 

 

@JBerns 

 

 

ViewProperties.PNG

 

ViewProperties2.PNG

Message 18 of 23
MichaëlStienstra
in reply to: Anonymous

MichaëlStienstra
Participant
Participant

Thomas Fitzgerald has written some code with the same outcome. The partlist is positioned in the upright corner of the active document.

https://github.com/AlexFielder/iLogic/blob/master/Autodesk/Thomas%20Fitzgerald/Parts%20List.iLogicVb

0 Likes

Thomas Fitzgerald has written some code with the same outcome. The partlist is positioned in the upright corner of the active document.

https://github.com/AlexFielder/iLogic/blob/master/Autodesk/Thomas%20Fitzgerald/Parts%20List.iLogicVb

Message 19 of 23
MichaëlStienstra
in reply to: Anonymous

MichaëlStienstra
Participant
Participant

This is the code I am using now. The list is located on the up left corner of the drawing. If you want it is pretty easy to change the position with use of lines 12 and 13. 

Sub Main
 Dim invDoc As DrawingDocument = ThisApplication.ActiveDocument
 Dim oSheet As Sheet = invDoc.ActiveSheet
 Try
 DeletePartsList(oSheet)
 Catch
 End Try
 Dim oDrawingView As DrawingView = oSheet.DrawingViews(1)
 Dim oBorder As Border = oSheet.Border
 Dim oPlacementPoint As Point2d
 If Not oBorder Is Nothing Then
	xrev = oBorder.RangeBox.MinPoint.X+"17"
	yrev = oBorder.RangeBox.MaxPoint.Y
	oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
 End If
Dim partsListBomType As PartsListLevelEnum = 46593
 Dim oPartsList As PartsList = oSheet.PartsLists.Add(oDrawingView,
oPlacementPoint, partsListBomType)
End Sub
Private Sub DeletePartsList(oSheet As Sheet)
 Dim oPartList As PartsList
 For Each oPartList In oSheet.PartsLists
 oPartList.Delete()
 Next
End Sub

 

0 Likes

This is the code I am using now. The list is located on the up left corner of the drawing. If you want it is pretty easy to change the position with use of lines 12 and 13. 

Sub Main
 Dim invDoc As DrawingDocument = ThisApplication.ActiveDocument
 Dim oSheet As Sheet = invDoc.ActiveSheet
 Try
 DeletePartsList(oSheet)
 Catch
 End Try
 Dim oDrawingView As DrawingView = oSheet.DrawingViews(1)
 Dim oBorder As Border = oSheet.Border
 Dim oPlacementPoint As Point2d
 If Not oBorder Is Nothing Then
	xrev = oBorder.RangeBox.MinPoint.X+"17"
	yrev = oBorder.RangeBox.MaxPoint.Y
	oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
 End If
Dim partsListBomType As PartsListLevelEnum = 46593
 Dim oPartsList As PartsList = oSheet.PartsLists.Add(oDrawingView,
oPlacementPoint, partsListBomType)
End Sub
Private Sub DeletePartsList(oSheet As Sheet)
 Dim oPartList As PartsList
 For Each oPartList In oSheet.PartsLists
 oPartList.Delete()
 Next
End Sub

 

Message 20 of 23

engineeringSEZWD
Contributor
Contributor

@MichaëlStienstrathis Ilogic rule worked well for me, however I want to change the style as I have 3 different part list but can i identify the correct PartsListLevelEnum = ?????

thank you

as you can see in the picture, the ilogic rule add the parts list (iso) template, but I want to add the Cut list (ISO) templete for all drawing that are frames

 

engineeringSEZWD_0-1723161575487.png

 

0 Likes

@MichaëlStienstrathis Ilogic rule worked well for me, however I want to change the style as I have 3 different part list but can i identify the correct PartsListLevelEnum = ?????

thank you

as you can see in the picture, the ilogic rule add the parts list (iso) template, but I want to add the Cut list (ISO) templete for all drawing that are frames

 

engineeringSEZWD_0-1723161575487.png

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report