- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report