- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Previously, I used the Snippets in the iLogic rule editor to pass parameters from part to assembly and suppress components/features with conditional statements. However, I've seen some of the really cool stuff some people here have come up with and I want to get there eventually. So I read through the first few paragraphs of the "AutoDesk Inventor 2015 API Help" document to attempt to recreate passing parameters using fully-qualified references so I can start getting the hang of "traversing" Inventor's Object Model. So I looked at their 2013 API Object Model and tried to create a parameter based on a previous post I found here
oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters oParameter=oMyParameter.AddByExpression("Length_inch", "3", UnitsTypeEnum.kInchLengthUnits)
Which I figured is the same thing as
ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters.AddByExpression("Width_mm", "3", "mm")
So that works perfectly, but based on what I read in the Help document, it seems that "This Application" and "ActiveDocument" are shortcuts of sorts to avoid having to type out the whole
Application.Documents.AssemblyDocument.AssemblyComponentDefinition
path. So I just followed the full path based on the Object diagram linked above and came up with
Application.Documents.AssemblyDocument.AssemblyComponentDefinition.Parameters.UserParameters.AddByExpression("Width_mm", "3", "mm")
But when I run it, I get an error "Error on Line 1 : Reference to a non-shared member requires an object reference."
I've tried variations of this like substituting "Inventor" in place of "Application" and substituting the actual file name in place of "Documents" and/or "AssemblyDocument" and deleting "UserParameters" but nothing seems to work. Can someone tell me what I'm doing wrong? I'm sure it's something really basic, but I couldn't find it in the Help Doc.
I've also tried to reverse engineer other rules posted on here, but I've been unsuccessful. I find that people often use
"Dim oDoc As PartDocument" or something like that and then "oDoc=ThisApplication.ActiveDocument", but I'm not sure how that works. The first seems like they're declaring a variable but the data types I've found are integers, strings, etc. I haven't seem "Part Document" as a data type. The second seems straightforward. I think they're just condensing the long "ThisApplication.ActiveDocument" into "oDoc" to make it shorter and easier to read.
I am new to programming (though I know some related things like for loops, while loops, variables, conditional statements, arrays, etc from using an automation app for smartphones) so please keep that in mind and if you have any resources for me to look at, that would be great.
Solved! Go to Solution.