add parts list in the lower corner using API

add parts list in the lower corner using API

Anonymous
Not applicable
881 Views
2 Replies
Message 1 of 3

add parts list in the lower corner using API

Anonymous
Not applicable

Hello all,

 

I am trying to add a parts list into a drawing using the API. Adding the list itself is not the problem, however the placement is rather tricky.

The drawing informtion is placed in the lower left corner. I want to place a parts list on top of the infobox.
The amount of parts varies because the assembly it corresponds to is configurable.  So when there are less parts a gap appears between the drawing info and the parts list. (see image for example)drawing example.png

 

 

Also, here is the code I got from the inventor API/programming help page.

On Error Resume Next
    ' 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
    oDrawingView = oSheet.DrawingViews(1)
    
    ' Set a reference to th sheet's border
    Dim oBorder As Border
    oBorder = oSheet.Border
    
    Dim oPlacementPoint As Point2d
    
    
        ' There is no border. The placement point
        ' is the top-right corner of the sheet.
       oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(41, 12.5)
   
    
    ' Create the parts list.
    Dim oPartsList As PartsList
    oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)

 

How can ik make the partslist snap to the drawing info box regardless of the amount of parts?

 

Thank you in advance.

 

Lennart

 

 

 



 

0 Likes
Accepted solutions (1)
882 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor
Accepted solution

Hi,

How about something like this? 🙂

Dim oSheet As Sheet = ActiveSheet.Sheet
Dim oDrawingView As DrawingView
oDrawingView = oSheet.DrawingViews(1)
Dim oPlacementPoint As Point2d
xrev = oSheet.TitleBlock.RangeBox.MaxPoint.X
yrev = oSheet.TitleBlock.RangeBox.MaxPoint.Y
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
Dim oPartsList As PartsList
oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)
oPartsList.Position = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev + oPartsList.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MinPoint.Y)
Message 3 of 3

Anonymous
Not applicable

Thank you @JhoelForshav,

 

your code worked great.
At line 6 I have added + 1.5 because the list overlapped the titleblock a bit.

It looks great now! 😃