Friday 21 July 2017

Precise Move Table

                Do you need to enforce Revision Table position? or any table for that matter?

                We talked about how to place and locate various tables on drawings so this is not new info but it is best if we make a post of its own so you can find it faster.

                This will help you enforce common standard and procedures when working with new recruits/students/temporary workforce.

                The code will move your revision table to lower left corner of your sheet but I did touch on how to find and use other points on drawing.



I did play with “TableDirection” “kBottomUpDirection” & “kTopDownDirection” thinking that the point coordinates will change depending on the drawing style of the table but Inventor outsmarted me (that’s not hard) and worked perfectly out of the box.

                It seems table coordinates will always start from top left corner no matter of your header position (top/bottom) or table direction (bottom up / top down), so we do need to calculate the height of the table.

On this principle, you can play with “Border.RangeBox.MinPoint”  ”Border.RangeBox.MaxPoint” or even specific x y values “Border.RangeBox.MinPoint.X” “Border.RangeBox.MinPoint.Y” to locate it in a different corner.

                This also applies to “TitleBlock.Position” or “TitleBlock.RangeBox” in case you need it next to, or on top of the titleblock.

                You can even search for table specific name if you have more than one tables on the sheet, that’s not possible with revision tables but it is with custom tables.  For example, this will search for Parts List with specific Title:

For i=1 To oPartsLists.Count
    If oPartsLists.Item(i).Title = "PARTS LIST" Then
        oPartsList = oPartsLists.Item(i)
        Exit For
Next

                So here is the code to move Revision Table:

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

'if you want different positions youcan get the MinPoint.X or MaxPoint or MaxPoint.Y
'along those lines
Dim oBorderPt As Point2d
oBorderPt = oSheet.Border.RangeBox.MinPoint

Dim oRevTable As RevisionTable
'I assume you only have 1 rev table on the drawing
oRevTable = oSheet.RevisionTables.Item(1)

Dim oRevPt As Point2d
oRevPt = ThisApplication.TransientGeometry.CreatePoint2d _
            (oBorderPt.X, oBorderPt.Y  + (oRevTable.RangeBox.MaxPoint.Y - oRevTable.RangeBox.MinPoint.Y))

oRevTable.Position = oRevPt

Later,
ADS
               

                

No comments:

Post a Comment