iLogic insert Parts List for parts and Assmeblies

iLogic insert Parts List for parts and Assmeblies

donaldleigh
Advocate Advocate
2,077 Views
5 Replies
Message 1 of 6

iLogic insert Parts List for parts and Assmeblies

donaldleigh
Advocate
Advocate

Hi all

 

I currently have the below code (pieced together from here) that added a parts list to a drawing. This will only work if the base view is a part. How can I get this to work if the base view is an assembly.

 

to automate this one step further it would be great also if depending on the base view the right parts Style is used.

 

Part - Parts List

Assembly - Assembly List

Sheet Metal - DXF List

 

Cheers

Donald

 

SyntaxEditor Code Snippet

oDrawDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
Dim oBorder As Border = oSheet.Border
Dim oDrawingView As DrawingView
oDrawingView = oSheet.DrawingViews(1)
Dim oPartsList As PartsList
Dim oDrawParams As UserParameters = oDrawDoc.Parameters.UserParameters

'check For PartListType Parameter and create If Not found
Try
oTest = Parameter("PartListType")
Catch
Dim oViewPar As UserParameter = oDrawParams.AddByValue("PartListType" , "AWE Assembly List", UnitsTypeEnum.kTextUnits)
'MultiValue.SetList("SheetViews", "Front, Side, Top, Iso", "Front, Side, Iso", "Front, Top, Iso", "Front, Iso")
End Try
'Set the list of SheetViews
MultiValue.SetList("PartListType", "AWE Assembly List", "AWE Part List", "AWE DXF List", "AWE Procurement List")
'Get user Input And Set Views
PartList = InputListBox("Choose Views Required.", _
MultiValue.List("PartListType"), MultiValue.List("PartListType").Item(0), "iLogic", "List of Views Available:")

'Boarder
If Not oBorder Is Nothing Then
    oPlacementPoint = oBorder.RangeBox.MaxPoint
Else
    oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height)
End If

'Look for Parts List
Try
    'Parts List Found, Do Nothing
    oPartslist = oSheet.PartsLists(1)
Catch
    'Create the parts list.
     oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
End Try

'Set Parts List Type
Dim oStyleMgr As DrawingStylesManager
oStyleMgr = oDrawDoc.StylesManager
Dim oPartListStyle As PartsListStyle
oPartListStyle = oStyleMgr.PartsListStyles.Item(PartList)
'Dim oPartsList As PartsList
For Each oPartsList In oDrawDoc.ActiveSheet.PartsLists
oPartsList.Style = oPartListStyle
Next

'Move the Parts List
PartHight=oSheet.PartsLists.Item(1).RangeBox.MaxPoint.Y-oSheet.PartsLists.Item(1).RangeBox.MinPoint.Y
TitleY=oSheet.TitleBlock.RangeBox.MaxPoint.Y
PointX=oBorder.Rangebox.Maxpoint.x
PointY=TitleY+PartHight
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(PointX,PointY)
oPartslist.position = oPlacementPoint

iLogicVb.UpdateWhenDone = True

 

2,078 Views
5 Replies
Replies (5)
Message 2 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

@donaldleigh,

 

Try below iLogic code to set partslist style depends on DocumentSubtype of referenced document in Drawing document. Same code works for assembly document in Baseview.

 

Part - Parts List

Assembly - Assembly List

Sheet Metal - DXF List

 

oDrawDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
Dim oBorder As Border = oSheet.Border 
Dim oDrawingView As DrawingView
oDrawingView = oSheet.DrawingViews(1)
Dim oPartsList As PartsList 
'Boarder
If Not oBorder Is Nothing Then
    oPlacementPoint = oBorder.RangeBox.MaxPoint
Else
    oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height)
End If

'Look for Parts List
Try
    'Parts List Found, Do Nothing
    oPartsList = oSheet.PartsLists(1)
Catch
    'Create the parts list.
     oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
End Try

doc = ThisDrawing.ModelDocument


'Set Parts List Type
Dim oStyleMgr As DrawingStylesManager
oStyleMgr = oDrawDoc.StylesManager
Dim oPartListStyle As PartsListStyle
Select doc.SubType 
Case "{4D29B490-49B2-11D0-93C3-7E0706000000}" 'PartDocument
	oPartListStyle = oStyleMgr.PartsListStyles.Item("AWE Part List")
Case "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" 'SheetMetal Document
	oPartListStyle = oStyleMgr.PartsListStyles.Item("AWE DXF List")
Case "{E60F81E1-49B3-11D0-93C3-7E0706000000}" 'Assembly Document
	oPartListStyle = oStyleMgr.PartsListStyles.Item("AWE Assembly List")
End Select

'Dim oPartsList As PartsList
For Each oPartsList In oDrawDoc.ActiveSheet.PartsLists
oPartsList.Style = oPartListStyle
Next

'Move the Parts List
PartHight=oSheet.PartsLists.Item(1).RangeBox.MaxPoint.Y-oSheet.PartsLists.Item(1).RangeBox.MinPoint.Y
TitleY=oSheet.TitleBlock.RangeBox.MaxPoint.Y
PointX=oBorder.RangeBox.MaxPoint.X
PointY=TitleY+PartHight
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(PointX,PointY)
oPartsList.Position = oPlacementPoint

iLogicVb.UpdateWhenDone = True

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 3 of 6

donaldleigh
Advocate
Advocate

Hi Shandra

 

that works for a part and Sheet metal but on an assembly I get the attached error.

Seems to be when placing the part list. Also I notice that the parts list is a "Structured" BOM View parts List. Is there a way of making this a "Structured (legacy)" BOM View?

 

Donald

0 Likes
Message 4 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

@donaldleigh,

 

Can you please provide assembly to investigate further or replicate of same assembly?

 

Please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 6

donaldleigh
Advocate
Advocate

Hi Shandra

 

The rule works when run for a part and Sheet Metal part well.

but when run for An assembly some work. It works on the "Assembly 1" but fails on the other 2.

 

As requested above we would like to to use the "Structured (legacy)" BOM View also.

Please see attached as requested

Donald

 

0 Likes
Message 6 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

@donaldleigh,

 

Try below iLogic code which works for all sample assemblies.

 

oDrawDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
 
Dim oBorder As Border = oSheet.Border 
Dim oDrawingView As DrawingView
oDrawingView = oSheet.DrawingViews(1)
Dim oPartsList As PartsList 
'Boarder
If Not oBorder Is Nothing Then
    oPlacementPoint = oBorder.RangeBox.MaxPoint
Else
    oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width, oSheet.Height)
End If

'Look for Parts List
Try
    'Parts List Found, Do Nothing
    oPartsList = oSheet.PartsLists(1)
Catch
    'Create the parts list.	 
     oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint) 
 Catch 
	oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint, PartsListLevelEnum.kStructuredAllLevels)
End Try


doc = ThisDrawing.ModelDocument

'Set Parts List Type
Dim oStyleMgr As DrawingStylesManager
oStyleMgr = oDrawDoc.StylesManager
Dim oPartListStyle As PartsListStyle 

Select doc.SubType

Case "{4D29B490-49B2-11D0-93C3-7E0706000000}" 'PartDocument
	oPartListStyle = oStyleMgr.PartsListStyles.Item("AWE Part List")
Case "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" 'SheetMetal Document
	oPartListStyle = oStyleMgr.PartsListStyles.Item("AWE DXF List")
Case "{E60F81E1-49B3-11D0-93C3-7E0706000000}" 'Assembly Document

	oPartListStyle = oStyleMgr.PartsListStyles.Item("AWE Assembly List")
End Select

'Dim oPartsList As PartsList
For Each oPartsList In oDrawDoc.ActiveSheet.PartsLists
oPartsList.Style = oPartListStyle
Next

'Move the Parts List
PartHight=oSheet.PartsLists.Item(1).RangeBox.MaxPoint.Y-oSheet.PartsLists.Item(1).RangeBox.MinPoint.Y
TitleY=oSheet.TitleBlock.RangeBox.MaxPoint.Y
PointX=oBorder.RangeBox.MaxPoint.X
PointY=TitleY+PartHight
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(PointX,PointY)
oPartsList.Position = oPlacementPoint

iLogicVb.UpdateWhenDone = True

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network