Reading an Object Model

Reading an Object Model

rcolon9E4ZX
Advocate Advocate
2,095 Views
2 Replies
Message 1 of 3

Reading an Object Model

rcolon9E4ZX
Advocate
Advocate

Hey guys,

 

I've been exploring VBA and it's uses with Inventor for the past six months. I recently found an object model online for Inventor 2016. I'm looking for help understanding what is presented. (i.e. squares enveloping vs. round enveloping, meaning of ensuing brackets and parenthesis, properties vs. methods, rules for reading and accessing any property or method). 

 

Any help would expedite my exploration and would be greatly appreciated.

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

MechMachineMan
Advisor
Advisor
Accepted solution

The object model itself isn't enough information to get you up and running, it's really just a roadmap to show you all of the sub-objects you have to access to access a certain property/method.

 

The next/first step is to use the API object browser, or programming help to find the functionality you want, and use the object model to understand how to get there.

 

See this thead for instruction on using help/object browser.

http://forums.autodesk.com/t5/inventor-customization/add-selection-filter-to-ilogic-code/m-p/6700118...

 

 

For example, if I want to access iProperties in a part file, I look through all of the tree'd info under part document.

 

Looking there I find nothing, but under the generic Document tree, I see Property is available, which is what the API refers to iProperties as.

 

Following the tree up, it looks like this:

 

Property -> PropertySet -> (PropertySets) -> Document -> (Documents) -> Application

Given that there are enums (in brackets above), it tells me I need to have a way to select a specific item out of that set, and what is described above is really only the TYPE of the object I need to access. At this part, we go into the Object Browser/Programming help and find Application, then work our way backwards by finding the path through the objects of the right type to get to the iProperty.

 

Accessing iProperties is actually relatively complex as there are a lot of identifiers you need to know to access specific iProperties. This is where google-fu comes in, and you can quickly find the "mod the machine" blog guide on "Accessing iProperties" which will guide you through to finding/accessing a specific iProperty.

 

An example of accessing an iProperty without any of the sub-objects assigned to a variable would look like:

 

ThisApplication.ActiveDocument.PropertySets("Design Tracking Properties").Item("Description").Value

 

Really, how this looks more like when writing code will be:

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

Dim oDTPProperties As PropertySet
oDTPProperties = oDoc.PropertySets("Design Tracking Properties")

Dim oiPropDescription As String
oiPropDescription = oDTPProperties.Item("Description").Value

'To call a different design tracking property at the same time would be as easy as adding

Dim oiPropStockNumber As String
oiPropStockNumber  = oDTPProperties.Item("Stock Number").Value

MsgBox(oiPropDescription & vblf & oiPropStockNumber)

The reason we assign sub-objects to variables is so the computer can access them faster, and it also makes the code easier to read for more complex programs. I could accomplish the exact same thing with the code below and in one line, but it would take longer for the program to process.

 

MsgBox(ThisApplication.ActiveDocument.PropertySets("Design Tracking Properties").Item("Description").Value & vblf & _
ThisApplication.ActiveDocument.PropertySets("Design Tracking Properties").Item("Stock Number").Value)

*note the "_" is the next line char for the compiler. you can delete it if you move the code right after it to the same line.

 

 

Any more questions, feel free to ask! Don't forget google/searching the forums is your friend!

 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 3

MechMachineMan
Advisor
Advisor

Also, you should try searching the Autodesk University resources!

 

I see this year there were at least 3 good iLogic/API presenters, which all have info available online!

 

See here:

http://au.autodesk.com/au-online/classes-on-demand/search?full-text=Inventor&productName=&language=&...

 

ex://

 

http://aucache.autodesk.com/au2016/sessionsFiles/20619/11818/handout_20619_SD20619-BOWSER-AU2016.pdf


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type