iLOGIC Multiple BOM Part List Creator

iLOGIC Multiple BOM Part List Creator

Anonymous
Not applicable
1,024 Views
6 Replies
Message 1 of 7

iLOGIC Multiple BOM Part List Creator

Anonymous
Not applicable

I'm trying to have the ability to insert different styles of BOM's depending on the style of drawing I'm working on using iLOGIC.

The "Internal" BOM uses predesigned columns, ITEM, QTY, DESCRIPTION, PART NUMBER.

I want to create an "External" BOM with ITEM, QTY, DESCRIPTION, STOCK NUMBER, VENDOR.

Below is my code, can this be edited to change the specified inserted columns?

These are triggered from a created form with buttons.

 

Form.JPG

 

 

iLogicVb.UpdateWhenDone = True   
    
    ' Set a reference to the drawing document.    
	' This assumes a drawing document is active.    
	Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument

    'Set a reference to the active sheet.    
	Dim oSheet As Sheet
    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
	
	Try
    	oDrawingView = oSheet.DrawingViews(1)
	Catch
		MessageBox.Show("No view found, can not continue. Please insert base a view.", "iLogic")
		Return
	End Try
    
    ' Set a reference to th sheet's border    
	Dim oBorder As Border
    oBorder = oSheet.Border
    
    Dim oPlacePoint As Point2d
    
    If Not oBorder Is Nothing Then
        ' A border exists. The placement point        
		' is the top-right corner of the border. 
		oOffset = -1.42875 'user defined offset
		oX = oBorder.RangeBox.MaxPoint.X + oOffset
		oY = oBorder.RangeBox.MaxPoint.Y
		oPlacePoint = ThisApplication.TransientGeometry.CreatePoint2d(oX,oY)
    Else
        ' There is no border 
		 
		oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(20, 20)
         
         iLogicVb.UpdateWhenDone = True
    End If
	
	Dim oPartslist As PartsList
	
	Try		
		'look for the first parts list found on the sheet 
		'if succesful finding it, 
		'tell the user,then Do Nothing
		oPartslist = oSheet.PartsLists(1)
		MessageBox.Show("There is an existing Internal Parts List", "iLogic")
		
	Catch
		' Create the parts list.  
		oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacePoint)
	End Try
0 Likes
Accepted solutions (2)
1,025 Views
6 Replies
Replies (6)
Message 2 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi PhilLindsay4781,

 

I followed you over here from the other thread.

 

 

Have a look at this example, it looks for 2 named parts list styles:

  • PartsList_Internal
  • PartsList_External

 

It gets input from the user and then sets the style for an existing, or newly placed parts list.

 

Using this example you would only have one button on your form, that would be called something like:

Create or Update Parts List

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

iLogicVb.UpdateWhenDone = True  

Dim bStyle As Boolean
bStyle = InputRadioBox("Select one:", "Internal", "External", True, "iLogic")

Dim sStye As String
'set the parts list style names to use
If bStyle = True Then
	sStyle = "PartsList_Internal"
Else
	sStyle = "PartsList_External"
End If

' Set a reference to the drawing document.    
' This assumes a drawing document is active.    
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

'Set a reference to the active sheet.    
Dim oSheet As Sheet
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

Try
	oDrawingView = oSheet.DrawingViews(1)
Catch
	MessageBox.Show("No View found. Can not continue", "iLogic")
	Return
End Try

' Set a reference to th sheet's border    
Dim oBorder As Border
oBorder = oSheet.Border

Dim oPlacePoint As Point2d

If Not oBorder Is Nothing Then
    ' A border exists. The placement point        
	' is the top-right corner of the border. 
	oOffset = -1.42875 'user defined offset
	oX = oBorder.RangeBox.MaxPoint.X + oOffset
	oY = oBorder.RangeBox.MaxPoint.Y
	oPlacePoint = ThisApplication.TransientGeometry.CreatePoint2d(oX,oY)
Else
    ' There is no border 
	 
	oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(20, 20)
     
     iLogicVb.UpdateWhenDone = True
End If

' Get the style.
Dim oStyle As Style
For Each aStyle As Style In oDrawDoc.StylesManager.PartsListStyles
    If aStyle.Name = sStyle Then
        oStyle = aStyle
        Exit For
    End If
Next

Dim oPartslist As PartsList

Try		
	'look for the first parts list found on the sheet 
	'if succesful finding it, 
	'tell the user,then Do Nothing
	oPartslist = oSheet.PartsLists(1)

Catch
	' Create the parts list.  
	oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacePoint)
End Try

'set the style
oPartsList.Style = oStyle

 

EESignature

Message 3 of 7

Anonymous
Not applicable
I used that code, and both instances place the same style BOM with the same columns. Im trying to get different columns for the Internal & External. I also obtained an error when running this. Can iLOGIC edit the column designation or am I trying to do something that isn't possible? I would like Internal to be the following: ITEM, QTY, DESCRIPTION, PART NUMBER I would like External to be the following: ITEM, QTY, DESCRIPTION, STOCK NUMBER, VENDOR Im also very very new at this stuff, so please be patient with me. Thanks
0 Likes
Message 4 of 7

Curtis_Waguespack
Consultant
Consultant

Hi PhilLindsay4781,

 

So just to clarify: you first created 2 parts list styles and ensured that the code matched the names of those styles, and in those styles you have the columns set up as needed?

 

If that is correct, then this code should work. It works by checking for an existing parts list, and placing one if not. Then it sets the style for the parts list.

 


@Anonymous wrote:
Can iLOGIC edit the column designation or am I trying to do something that isn't possible?

 

It might be possible, but it would basically be creating a style override for your parts list, which would make updating drawings later a bit more difficult. So I don't think it would not be the recommended method due to that.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 5 of 7

Anonymous
Not applicable
I was able to tweak it ... THANKS One more thing ... How can I sort one column, then the next column? I want to sort VENDOR if no PART NUMBER, that works. After that, I want to sort STOCK NUMBER within the VENDOR sort. On Error Resume Next Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument Dim oPartsList1 As PartsList oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1) If oPartsList1 Is Nothing Then Resume Next oPartsList1.Sort("PART NUMBER") If ("PART NUMBER") Is Nothing Then Resume Next oPartsList1.Sort("VENDOR") oPartsList1.Renumber oPartsList1.SaveItemOverridesToBOM
0 Likes
Message 6 of 7

Curtis_Waguespack
Consultant
Consultant

Hi PhilLindsay4781,

 

You're code formatting got a bit jumbled (note that there is an "Insert Code" tool in the forum's reply tools that will help prevent this.

 

But as for sorting, see this link (look for the examples below the ****EDIT*** 8-24-2011

 

http://inventortrenches.blogspot.com/2011/02/ilogic-code-for-parts-lists-title.html

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 7 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution
0 Likes