One question that I get quite often is “Where do I go to learn more advanced iLogic?” My first response is do you know any programming? If not, it would really help you advance your iLogic skills to know some basic programming concepts and skills.
One way to describe iLogic is that it is a user-friendly wrapper around the Inventor API (application program interface). It allows you to easily change parameters, suppress features, move a drawing view, etc. without having to understand how the Inventor API works.
If you’re not familiar with Object Oriented Programming (OOP), I’d suggest that you read up on that to begin with. There is some very good introductory information on OOP in the online Inventor API User’s Manual online help, which you can access here. It discusses objects, explains their relationships, shows you the Object Model (shown below in very low res), and all kinds of other goodies.
For this post, let us assume that I have a need to move a table on an Inventor drawing. I’m going to explain how I would go about figuring out how to do that (that whole teach a person to fish thing). In case you missed it, my last blog post was about just that, moving a table. You can read that post here.
For now, I’m going to assume that we are fairly versed in the API and know everything else in my Moving Custom Tables With Code post, other than how to move the table. Don’t worry, we’ll revisit the rest in future posts.
I start off with the Inventor Programming/API Help. You can access this by clicking the drop down next to the Help Question Mark icon on the right hand side of your Inventor title bar, hovering over the Help and then choosing Programming/API Help.
Go to the Search tab of the help and enter table.
You’ll see a lot of results, things like CustomTable Object, HoleTable Object, RevisionTable Object, etc. In this case, we want to choose CustomTable Object. Admittedly, it’s not very straightforward to know that we want a CustomTable Object since the Inventor command is called General Table.
Once you’ve clicked on the CustomTable Object, you’ll see the various methods and properties associated with that object. You can think of methods as actions against an object and properties are data associated with that object. Take a moment to look through the various options and then look at the Position property in particular. Its description says “Specifies the position of the table”. That’s what we want to set. If you click on Position, we’ll see the help page associated with it. It lists the following:
- Description: We’ve already seen this on the last page
- Specifies the position of the table
- Syntax: How the property is to be used in your code
- CustomTable.Position() As Point2d
- Property Value: This tells you that it’s a read/write value and it requires a Point2d, which is also given to us in the Syntax
- This is a read/write property whose value is a Point2d
- Version: This tells us what version of the Inventor API this was introduced
- Introduced in version 9
Based on this, I now know that I can move or set the position of my custom table by the following steps:
- Get a reference to the table I want to move
- Create a Point2d
- Pass the Point2d to the Position property of my table
To make it easier, I’m going to post the code from my previous post below.
' 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
I hope that I’ve shed a tiny bit of light on the Inventor API and how you can go about searching for what you need. In future posts, I’ll dig a little deeper into the API.
Thanks and Happy Coding!