I was recently asked if it's possible to move the position of a custom table on an Inventor Drawing using iLogic. The straight answer to that question is "No".... but we can do it with a little API code.
Unfortunately, there are no out of the box iLogic Snippets that give us access to a custom table. For this, we need to dig into the API just a bit.
The CustomTable object is accessed through the Sheet object, which is accessed through the DrawingDocument. In the example code below, I'm assuming that the drawing we're working in only has 1 sheet and also that it only has 1 custom table. I'm also not verifying that a custom table exists. If you want to run such a rule against drawings that may not have a custom table, you'd want to check and exit the rule if there are none.
The position property of the CustomTable object is based on the upper left corner of the table, regardless of how the table layout is set up on your Styles & Standards. Because of this, I'm also determining the height of the table so that I can position the table by it's lower left corner. I'm doing this by subtracting the MinPoint.Y from the MaxPoint.Y.
Remember, values in the API are in centimeters. I typically create a multiplier object and use that throughout my code. In the example below, I'm positioning the lower left corner of my table 1" in the X and 1" in the Y from the drawings 0,0.
' Declarations. Assuming this is a drawing
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
' Assuming first sheet
Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets(1)
' Assuming first custom table found
Dim oTable As CustomTable
oTable = oSheet.CustomTables.Item(1)
' Get height of table. Insert of table is at top of table.
' Height is required if you want to drive by bottom of table.
Dim oHeight As Double = oTable.RangeBox.MaxPoint.Y - oTable.RangeBox.MinPoint.Y
' Set point. Dimensions are in cm
Dim oMultiplier As Double = 2.54
Dim oPoint As Point2d
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(1 * oMultiplier, 1 * oMultiplier + oHeight)
' Move table
oTable.Position = oPoint
Let me know in the comments if you have any further questions or comments.
Thanks and Happy Coding!
Randy
Comments
You can follow this conversation by subscribing to the comment feed for this post.