Parts List Problems

Parts List Problems

Anonymous
Not applicable
1,051 Views
7 Replies
Message 1 of 8

Parts List Problems

Anonymous
Not applicable

Hello,

 

I was working with my Marco this weekend and I am having problems generating a Parts List for my Assembly.

My drawing consists of one base assembly view and 5 projected views. It also has 1 part  view (view 7).   

I copied the code from (Help- Programming Help- Cut and Past Sample Code-Drawing Tables-Create Parts List) and it works if I use (base View 7) which generates a Parts List for one object but I cannot get the Parts List of the entire assembly (base View1). Please see simplified description of code below. Thank you for your time. 

 

 

Private Sub UserButtonz1_Click()

  '

Creates several iParts and saves them

  '

Creates an Assembly with the above iParts and saves it.

  '

Creates an Exported BOM and saves it.

  '

Creates the drawing

  '

(Base View 1 Assembly) 

Dim oBaseView As DrawingView
Set oBaseView = oSheet.DrawingViews.AddBaseView(oDoc2, oPnt, SCALE1, kFrontViewOrientation, kHiddenLineDrawingViewStyle)
  '

Projected Views

  '

(Base View 7 of part)

Set oPnt = ThisApplication.TransientGeometry.CreatePoint2d(62#, 30#)
Set oBaseView = oSheet.DrawingViews.AddBaseView(oDoc3, oPnt, SCALE2, kFrontViewOrientation, kHiddenLineDrawingViewStyle)
  '

Add Notes to the Drawing

  '

ADDING THE PARTS LIST TO DRAWING

On Error Resume Next
     
Set oDrawDoc = ThisApplication.ActiveDocument

Set oSheet = oDrawDoc.ActiveSheet

Dim oDrawingView As DrawingView
Set oDrawingView = oSheet.DrawingViews(1) '(If I use View(7) here It works but for only that part)

Dim oBorder As Border
Set oBorder = oSheet.Border

Dim oPlacementPoint As Point2d
Set oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(85, 11)

Dim oPartsList As PartsList
Set oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

  '

Create revision table

  '

Save Drawing

End Sub

 

0 Likes
1,052 Views
7 Replies
Replies (7)
Message 2 of 8

Ralf_Krieg
Advisor
Advisor

Hello

 

If your code really runs in this way, you will only create a PartsList of View7. If you need a PartsList for every View, try:

 

for each oView in oSheet.DrawingViews

    Set oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

next

 

or if you need a PartsList for View1 and View7 try

 

Set oBaseView = oSheet.DrawingViews.AddBaseView(oDoc2, oPnt, SCALE1, kFrontViewOrientation, kHiddenLineDrawingViewStyle)

Set oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

.

.

.

Set oBaseView = oSheet.DrawingViews.AddBaseView(oDoc3, oPnt, SCALE2, kFrontViewOrientation, kHiddenLineDrawingViewStyle)

Set oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 8

Anonymous
Not applicable

Thank you for your response. Probably I was not very clear in explaining my problem.  There is a line in the code which specifies the view you want to use for the Parts List (Set oDrawingView = oSheet.DrawingViews(1)). When I use  View 1 (which is my Assy base view) and comment out "On Error Resume Next" I get an error message (Run-Time error '5' Invalid Procedure call or augument). If I use View 7 (which is a base part view) it works. What I need is  Assy View 1.

 

Thanks         

0 Likes
Message 4 of 8

Ralf_Krieg
Advisor
Advisor

Hello

 

Now I understand. Smiley Happy

 

If your View1 is an assembly, you'll need to set the Level. I know it is optional, but in assemblys it seems to be necessesary.

 

Try:

Set oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint, kPartsOnly or kStructuredAllLevels)

 

Be sure that the selected Level is activated in BOM or you'll get an exception.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 5 of 8

Anonymous
Not applicable

That did it. Thanks.

I have one more question if I may. Our company places the Parts List on the bottom right corner above the Title Block on our drawings. My Parts List will vary in size (length) depending on the number of parts in the assembly. How can I  calculate the length of the parts list so that I can place it in the correct position in my drawing ?

 

Thanks again.

 

 

 

0 Likes
Message 6 of 8

Ralf_Krieg
Advisor
Advisor

Hello

 

The PartsList has the RangeBox and Position properties. The RangeBox has a max (upper right) and a min (lower left) point. With this you can calculate the dimension of the partslist. Position means the point in the middle of the partslist.

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 7 of 8

Anonymous
Not applicable

So I can calculate the width and length of the PartsList (PL) by using the code below: 

 

Dim oPartsList As PartsList

XX = oPartsList.RangeBox.MaxPoint.X
YY = oPartsList.RangeBox.MinPoint.X

PL_WIDTH = XX - YY


XX1 = oPartsList.RangeBox.MaxPoint.Y
YY1 = oPartsList.RangeBox.MinPoint.Y

PL_LENGTH = XX1 - YY1

 

George

 

0 Likes
Message 8 of 8

Anonymous
Not applicable

Man I love these forums. I was pulling out what little hair I have left on this very issue.

 

I could not add a parts list to an automatically created idw of an automatically created assembly.

I was leaving out the optional Level parameter.

So, when I ran across this post I tried adding kStructured for the Level Argument.  It did not work.

 

Then I remembered that my Assembly BOM Structured View is set to All Levels. So, I changed the parameter to kStructuredAllLevels and presto.Smiley Happy

0 Likes