Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing a parameter 3 sub-assemblies deep?

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
546 Views, 6 Replies

Accessing a parameter 3 sub-assemblies deep?

I'm trying to access a paramter thats in a sub-assemby 3 sub-assemby deep, is this possible?

 

I have tried a few thigns incluiding this, but it doesn't work. Anyone have any ideas?

Parameter(MakePath("MegaStalls:1", MakePath("Stall_1", MakePath("Pilaster:1", "xPilaster:1"))), "pilasterHeight")
6 REPLIES 6
Message 2 of 7
cwhetten
in reply to: Anonymous

If your component name is unique, there is no need to use MakePath.  If your desired component is the only one called "xPilaster:1", then try this:

 

Parameter("xPilaster:1", "pilasterHeight")

I tested this on one of my assemblies and it worked just fine.

 

Cameron Whetten
Inventor 2014

Message 3 of 7
Anonymous
in reply to: Anonymous

Looks like this isnt going to work. I do have some conflicts with the subassembly names. 

 

Is there another way? I really need to fully resolve the sub assembly name to avoid conflicts. 

 

Thanks

Message 4 of 7
cwhetten
in reply to: Anonymous

Can you just rename the browser name for that component?  You don't actually need to rename the file if you don't want to, just rename the component in the browser.  To do this, open the assembly that is the immediate parent of the component.  Then, click the component in the browser, then click it again and rename it.

 

If this method won't work for you, it is possible to write out a long bit of code that will drill down, but it won't be pretty...

 

Cameron Whetten
Inventor 2014

Message 5 of 7
Anonymous
in reply to: cwhetten

its a complicated long story, but im not able to rename the components in the browser. 

 

I think im going to have to see that long bit of code....

Message 6 of 7
cwhetten
in reply to: Anonymous

Well, I don't know exactly what you are trying to do with this parameter, but here is something that might work:

 

oComp1 = ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.ItemByName("Sub-Assembly 1 Name Here")
oComp2 = oComp1.Definition.Occurrences.ItemByName("Sub-Assembly 2 Name Here")
oComp3 = oComp2.Definition.Occurrences.ItemByName("Sub-Assembly 3 Name Here")
oComp4 = oComp3.Definition.Occurrences.ItemByName("Part Name Here")

param = oComp4.Definition.Parameters.UserParameters.Item("Parameter Name Here").Value

 So, for the component names you listed in your first post, it would look something like this:

 

oComp1 = ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.ItemByName("MegaStalls:1")
oComp2 = oComp1.Definition.Occurrences.ItemByName("Stall_1")
oComp3 = oComp2.Definition.Occurrences.ItemByName("Pilaster:1")
oComp4 = oComp3.Definition.Occurrences.ItemByName("xPilaster:1")

param = oComp4.Definition.Parameters.UserParameters.Item("pilasterHeight").Value

 Now, you can go on to use the "param" variable however you see fit.  HOWEVER--Note that using parameter( ).Value will return the value of the parameter in database units, which is cm, regardless of the units of the parameter in your part file.  You will have to carefully watch your units, making any conversions as needed to get valid results.

 

The above code can be expanded or contracted depending on how many levels deep you need to go.

 

Cameron Whetten
Inventor 2014

Message 7 of 7
Anonymous
in reply to: Anonymous

This actually isnt too bad. But, i can see how it can get code intensive becauase have so many parameters and they will have to be converted to inches. 

 

Thanks for posting this. I think because i have rule in the sub assemblies that I will just pass the paramter values up through the chain so they can be accssed  with the makepath function. If that gets too complicated ill have to look at this again. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report