Inserting a parameter formula into the dimension of a part with iLogic?

Inserting a parameter formula into the dimension of a part with iLogic?

werft60
Contributor Contributor
648 Views
5 Replies
Message 1 of 6

Inserting a parameter formula into the dimension of a part with iLogic?

werft60
Contributor
Contributor

I'm trying to build an ilogic rule that inserts a new component into an assembly re-sizes it to fit properly and then constrains it properly to the rest of the parts. So far I have had success in doing so but I have had to "hard code" the size of the inserted part.

 

The rest of the assembly is all built parametrically and can be controlled via a few major dimensions, which allows me the ability to quickly change everything's sizes.

 

I know the parametric formulas I would like to add to the new component to control its size but I can't figure out how to insert the formula string into the dimensions. Any help would be really appreciated. Below is how I "hardcode" the values of the inserted component. 

 

For Each oParameter In DV.DoorParameters
	If oParameter.Name.ToLower = "master_width" Then
		oParameter.Value = DV.DoorWidth / 10
	Else If oParameter.Name.ToLower = "master_height" Then
		oParameter.Value = DV.DoorHeight / 10
	Else If oParameter.Name.ToLower = "number_of_panels" Then
		oParameter.Value = DV.NumberOfPanels
		oParameter.Units = "ul"	
	End If
Next

 

 

EDIT: I've just realized an important part of this problem is that I need to link the newly inserted component to one of the parts within the existing assembly in order to use its parameters. 

0 Likes
Accepted solutions (3)
649 Views
5 Replies
Replies (5)
Message 2 of 6

SometimesInventorMakesMeAngry
Advocate
Advocate
Accepted solution
oParameter.Expression = "DoorWidth / 10"
0 Likes
Message 3 of 6

werft60
Contributor
Contributor

Please see my edit to the post. I did try your solution before I made this post but didn't realize why it wasn't working. I understand now that the problem isn't due to the inserting of the formula but because the part I just inserted isn't linked with the rest of assembly. Therefor it doesn't have access to any of the parameter names. 

 

Any idea on how I would do this?

0 Likes
Message 4 of 6

J-Camper
Advisor
Advisor
Accepted solution

This Autodesk Sample shows how to link parameters between documents.  It is written in VBA, but all you need to do to get it to work with iLogic is eliminate all the instances of "Set".  "Set" is understood and not needed to be written out in an iLogic rule.

 

Once you have the parameters linked, you set the Parameter Expression instead of Value as @SometimesInventorMakesMeAngry showed.

 

If you have any further questions, let me know.

0 Likes
Message 5 of 6

SometimesInventorMakesMeAngry
Advocate
Advocate

It depends on your situation. Basically, the part you need is

part1.Parameters.UserParameters.Item("width").value = part2.Parameters.UserParameters.Item("width").value

How you get part1 and part2 is what depends. You could iterate over the occurrences in your assembly until you find the part by ComponentOccurrence.Definition.Document.DisplayName, or by ComponentOccurrence.Definition.Document.FullFileName.

 

If you don't want to do a lot of coding to find each part, you could always have the two parts in the assembly, rename their browser nodes and then replace them via iLogic with 

Parameter("Part1", "width") = Parameter("Part2","width")

This way, you can always access them with the same name without having to "look" for them. 

 

There are many, many other ways of getting part1 and part2. If the above won't work for you, give me a bit more info so I can think of a way of doing it for your situation.

0 Likes
Message 6 of 6

werft60
Contributor
Contributor
Accepted solution

I've figured out the solution.

 

Using the link provided in @J-Camper 's response helped understand how linking parameters works in iLogic.

 

In my case it boiled down to a one liner:

 

Dim oDerivedParamTable As DerivedParameterTable = DV.DoorDoc.ComponentDefinition.Parameters.DerivedParameterTables.Add("File Path")

 

This links all exported parameters from the given file path. In my situation I'm always going to know the file path of the part I want to link so it is the most convenient to not worry about specifics and just link all of the parameters.

 

After linking I just altered my code to follow what @SometimesInventorMakesMeAngry said in their first post.

 

	For Each oParameter In DV.DoorParameters
	If oParameter.Name.ToLower = "master_width" Then
		oParameter.Expression = "(CW_1/2) - 3"
	Else If oParameter.Name.ToLower = "master_height" Then
		oParameter.Expression = "CH_1 - Mantle_Height - 3"
	Else If oParameter.Name.ToLower = "number_of_panels" Then
		oParameter.Value = DV.NumberOfPanels
		oParameter.Units = "ul"	
	End If
	Next

 

0 Likes