Insert parts list above titleblock

Insert parts list above titleblock

checkcheck_master
Advocate Advocate
347 Views
3 Replies
Message 1 of 4

Insert parts list above titleblock

checkcheck_master
Advocate
Advocate

I would like to use iLogic to put a Parts List on a drawing that is in the correct position above the title block in one go.
In a previous post it was stated that you should measure the top coordinate of the title block, see:

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/insert-parts-list-above-titleblock/t... 

I get that, title blocks can be different.
The top right corner is taken as the insert point for the parts list.
In that case, the number of rows would affect the insert point above the title block.
In the Inventor help under PartsLists.Add Method I don't see an option to choose another corner as insert point.
Am I missing something?
How can I accomplish this?
Do I have to determine how many rows there are to get to the correct insert point?

0 Likes
348 Views
3 Replies
Replies (3)
Message 2 of 4

JelteDeJong
Mentor
Mentor

You can do it like this. (this code assumes that your title block is in the lower-left corner.)

Dim oTg = ThisApplication.TransientGeometry
Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim border As Border = sheet.Border
Dim titleBlock As TitleBlock = sheet.TitleBlock

Dim x As Double = 0
Dim y As Double = 0

Dim insertPoint As Point2d = oTg.CreatePoint2d(0, 0)
Dim partsList As PartsList = sheet.PartsLists.Add(sheet.DrawingViews.Item(1), insertPoint)
partsList.HeadingPlacement = HeadingPlacementEnum.kHeadingAtBottom
partsList.TableDirection = TableDirectionEnum.kBottomUpDirection

Dim plHeight = partsList.RangeBox.MaxPoint.Y - partsList.RangeBox.MinPoint.Y
Dim plWidth = partsList.RangeBox.MaxPoint.X - partsList.RangeBox.MinPoint.X

x = titleBlock.RangeBox.MaxPoint.X
y = titleBlock.RangeBox.MaxPoint.Y + plHeight
partsList.Position = oTg.CreatePoint2d(x, y)

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 4

A.Acheson
Mentor
Mentor

As you pointed out you cannot change the position point of the partlist in the object  so you have to work around this fixed placement to work out the new position. To work out the position point for an object you would use the "RangeBox" methods to find the width and height of the objects, most objects have this. Then do some calculation to place it in the appropriate position.  Because you may need to work out the size of the partslist you will place it first then work out it's size then position to the correct location. In the code below the first sub routine Moves Partslist from Right of Border to Left. If you need any more help please show the partslist position with an image. 

 

Sub Main
'Set a reference To the drawing Document.    ' This assumes a drawing document is active.    
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument

'Set a reference to the active sheet.    
Dim oSheet As Sheet = oDrawDoc.ActiveSheet    

Dim oBorder As Border = oSheet.Border
Dim oTitleBlock As TitleBlock = oSheet.TitleBlock
Dim oPartsList As PartsList = oSheet.PartsLists(1)

Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oPt As Point2d = oTG.CreatePoint2d(0, 0)'loosely position Table if inserting for the first time

'Move Partlist
PositionPartslist(oPt, oPartsList, oSheet)
'Show Sizes
Showsize(oBorder,oTitleBlock,oPartsList)

End Sub 

'Moves Partslist from Right of Border to Left
Private Sub PositionPartslist(oPt As Point2d,oPartsList As PartsList,oSheet As Sheet)

Dim dWidthPartslist As Double = oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X

Dim dHeightPartslist As Double = oPartsList.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MinPoint.Y

oPt = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Border.RangeBox.MinPoint.X + dWidthPartslist, oSheet.Border.RangeBox.MaxPoint.Y)

oPartsList.Position = oPt
End Sub




Private Sub Showsize(oBorder As Border ,oTitleBlock As TitleBlock,oPartsList As PartsList)
Dim dBorderMaxX, dBorderMinX, dBorderMaxY, dBorderMinY As Double
Dim dTitleBlockMaxX, dTitleBlockMinX, dTitleBlockMaxY, dTitleBlockMinY As Double
Dim dPartsListMaxX, dPartsListMinX, dPartsListMaxY, dPartsListMinY As Double

    dBorderMaxX = oBorder.RangeBox.MaxPoint.X
	dBorderMinX = oBorder.RangeBox.MinPoint.X
	dBorderMaxY = oBorder.RangeBox.MaxPoint.Y
	dBorderMinY = oBorder.RangeBox.MinPoint.Y
Logger.Info(oBorder.Name & "-" & dBorderMaxX  & "-" & dBorderMinX & "-" & dBorderMaxY & "-" & dBorderMinY)
	dTitleBlockMaxX = oTitleBlock.RangeBox.MaxPoint.X
	dTitleBlockMinX = oTitleBlock.RangeBox.MinPoint.X
	dTitleBlockMaxY = oTitleBlock.RangeBox.MaxPoint.Y
	dTitleBlockMinY = oTitleBlock.RangeBox.MinPoint.Y   
Logger.Info(oTitleBlock.Name & "-" & dTitleBlockMaxX  & "-" & dTitleBlockMinX & "-" & dTitleBlockMaxY & "-" & dTitleBlockMinY)
	dPartsListMaxX = oPartsList.RangeBox.MaxPoint.X
	dPartsListMinX = oPartsList.RangeBox.MinPoint.X
	dPartsListMaxY = oPartsList.RangeBox.MaxPoint.Y
	dPartsListMinY = oPartsList.RangeBox.MinPoint.Y   
Logger.Info(oPartsList.Style.Name & "-" & dPartsListMaxX & "-" & dPartsListMinX & "-" & dPartsListMaxY & "-" & dPartsListMinY)
End Sub

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 4

checkcheck_master
Advocate
Advocate

Thank you both, I'll look into it.

0 Likes