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: 

Inventor ilogic - programatically add parts list

4 REPLIES 4
Reply
Message 1 of 5
craigzcool
2559 Views, 4 Replies

Inventor ilogic - programatically add parts list

Hi im trying to programatically add a parts list into a drawing whilst programatically creating the drawing - the code works fine without the parts list code. The error its showing is 'Parameter incorect' on the line that sais PartsList.add(...   In the past when ive got this error with other code it has been because ive used an incorrect parameter (e.g. decimal instead of an integer). My error is somewhere inside the oPartsList.add(>>ERROR SOMEWHERE HERE<<<) Please Help!

 

oDrawDoc = InvApp.Documents.Add(Inventor.DocumentTypeEnum.kDrawingDocumentObject,AssyTemplate, True) 
oSheet = oDrawDoc.Sheets.Item(1)


Dim oPoint1 = InvApp.TransientGeometry.CreatePoint2d(12, 14)
Dim oPoint2 = InvApp.TransientGeometry.CreatePoint2d(12, 32)
Dim oPoint3 = InvApp.TransientGeometry.CreatePoint2d(35, 14)
Dim oPoint4 = InvApp.TransientGeometry.CreatePoint2d(50, 32)
Dim oPoint5 = InvApp.TransientGeometry.CreatePoint2d(10, 10)

 

oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, ViewScale, Inventor.ViewOrientationTypeEnum.kFrontViewOrientation, Inventor.DrawingViewStyleEnum.kShadedDrawingViewStyle, "Default")

 

oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, Inventor.DrawingViewStyleEnum.kShadedDrawingViewStyle, ViewScale)


oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint3, Inventor.DrawingViewStyleEnum.kShadedDrawingViewStyle, ViewScale)


oView4 = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint4, Inventor.DrawingViewStyleEnum.kShadedDrawingViewStyle, IsoScale)

 

Dim oPartsList1 As PartsList
oDrawDoc.Sheets(1).PartsLists.Add(oDrawDoc, oPoint5, PartsListLevelEnum.kPartsOnly, NumberingSchemeEnum.kNumericNumbering, 1, True)

 

'ERROR SOMEWHERE ON THE LINE ABOVE ^^^


oPartsList1 = oDrawDoc.oSheet.PartsLists.Item(1)
oPartsList1.Sort("VENDOR", 1, "PART NUMBER", 1)
oPartsList1.Renumber()

 

 

 

Thanks in advance, Craig

4 REPLIES 4
Message 2 of 5

Could you please modify the following line:

Dim oPoint5 as Point2d = InvApp.TransientGeometry.CreatePoint2d(10, 10)

and let me know the result.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 5
MechMachineMan
in reply to: craigzcool

When your Bill of Materials for the Assembly has its view properties set to all levels rather than First Level it can cause some weird errors. This might be it.

 

Just thought i would post this in case anyone else is searching for parts list things again and comes across this.


--------------------------------------
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 4 of 5
michael.tadros
in reply to: craigzcool

The parts list is added to a view, not a drawing. So the first parameter should be a drawing view, not a drawing.

Also change "NumberingSchemeEnum.kNumericNumbering" to "Nothing".

 

E.g.

 

oDrawDoc = ThisApplication.ActiveDocument
oSheet = oDrawDoc.ActiveSheet
Dim oPoint5 = ThisApplication.TransientGeometry.CreatePoint2d(0, oSheet.Height)
Dim viw As DrawingView = oDrawDoc.ActiveSheet.DrawingViews.Item(1)
oDrawDoc.Sheets(1).PartsLists.Add(viw, oPoint5, PartsListLevelEnum.kPartsOnly, Nothing, 1, False)
Message 5 of 5

Not entirely true...

 

From API Documentation:

PartsLists.Add( ViewOrModel As Object, PlacementPoint As Point2d, [Level] As PartsListLevelEnum, [NumberingScheme] As Variant, [NumberOfSections] As Long, [WrapLeft] As Boolean ) As PartsList
ViewOrModel: Input object that specifies the source for the parts list. This can either be a DrawingView object
or a Document object. Valid document types include part files and assembly files. Use the Documents.Open method
to open the file if not already open and obtain a Document object. Typically you'll want to set the OpenVisible
argument of the Open method to False so the open is invisible to the user.

Thus, he can just change the oDrawDoc to oPartDoc in his partslist call, rather than pulling from a view.


--------------------------------------
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

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

Post to forums  

Autodesk Design & Make Report