Changing custom properties output from inches to feet & inches

Changing custom properties output from inches to feet & inches

spanky
Contributor Contributor
331 Views
4 Replies
Message 1 of 5

Changing custom properties output from inches to feet & inches

spanky
Contributor
Contributor

I'm trying to get my iLogic I've been using to output the Length custom property to ft-in. Right now it sets everything in inches rounded to the 1/16".

 

Any ideas? Any help would be GREATLY appreciated. 

 

Thanks.

 

	    iLogicVb.RunRule("TOGGLEWORKFEATURES")
		InventorVb.DocumentUpdate()
		SPECAdder = 0
		
		Smallest = Measure.ExtentsLength
		Middle = 0
		Largest = 0
		
		If Measure.ExtentsWidth > Measure.ExtentsLength Then
			Middle = Measure.ExtentsWidth
		Else
			Smallest = Measure.ExtentsWidth
			Middle = Measure.ExtentsLength
		End If
		
		If Measure.ExtentsHeight > Middle Then
			Largest = Measure.ExtentsHeight
		Else
			If Measure.ExtentsHeight > Smallest Then
				Largest = Middle
				Middle = Measure.ExtentsHeight
			Else
				Largest = Middle
				Middle = Smallest
				Smallest = Measure.ExtentsHeight
			End If
		End If
		
		Largest = Largest + SPECAdder
		
		'iProperties.Value("Project", "Stock Number") = Round(Largest, 1) & "x" & Round(Middle ,1) & "x" & Round(Smallest , 1) & " "


		iProperties.Value("Custom", "LENGTH") = RoundToFraction(Largest, 1/16, RoundingMethod.RoundUp)
		iProperties.Value("Custom", "WIDTH") = RoundToFraction(Middle, 1/16, RoundingMethod.RoundUp)
		iProperties.Value("Custom", "HEIGHT") = RoundToFraction(Smallest, 1/16, RoundingMethod.RoundUp)
		
		iProperties.Value("Custom", "SECTION DIMS") = CStr(RoundToFraction(Smallest, 1 / 16, RoundingMethod.RoundUp)) + " X " + CStr(RoundToFraction(Middle, 1 / 16, RoundingMethod.RoundUp))
		
		'iProperties.Value("Custom", "LENGTHMM") = iProperties.Value("Custom", "LENGTH") * 25.4
		'iProperties.Value("Custom", "WIDTHMM") = iProperties.Value("Custom", "WIDTH") * 25.4
		'iProperties.Value("Custom", "HEIGHTMM") = iProperties.Value("Custom", "HEIGHT") * 25.4

 

This is the TOGGLEWORKFEATURES iLogic

For Each oWorkPlane In ThisDoc.Document.ComponentDefinition.WorkPlanes
	oWorkPlane.Visible = False
Next

For Each oWorkAxis In ThisDoc.Document.ComponentDefinition.WorkAxes
	oWorkAxis.Visible = False
Next

For Each oWorkPoint In ThisDoc.Document.ComponentDefinition.WorkPoints
	oWorkPoint.Visible = False
Next
0 Likes
Accepted solutions (1)
332 Views
4 Replies
Replies (4)
Message 2 of 5

MercuryOptimizationSolutions
Participant
Participant

Hey @spanky, just want to make sure I understand what you are trying to do, you have a custom "LENGTH" iproperty that is currently displaying as inches and you want it in ft-in?

I know you can do this easily in visual studio so I suspect it should be the same in iLogic, are you able to provide a sample part?

P. Andrew White, P.Eng
Consultant Manufacturing Engineer | Architect of Optimization | Autodesk Developer
0 Likes
Message 3 of 5

spanky
Contributor
Contributor

Here is a sample part with the rules active.

0 Likes
Message 4 of 5

MercuryOptimizationSolutions
Participant
Participant
Accepted solution

Ah, I see the issue. The custom property is created as a number which is effectively "unitless". Not sure if this works for your purposes but I added another custom property as a "text" type and used this equation in the iLogic:

 

		iProperties.Value("Custom", "LENGTH2") = Round(Largest/12,0) & "ft-" & Round(Largest-Round(Largest/12,0)*12) & "in"

So the value in "LENGTH2" in your example would display "10ft-0in" but note this is text so if you have this value being used in an external system, it may not recognize it as a measurement.

Inventor itself will recognize this measurement as the parameters are calculated. So even though the document units are set to inches, Inventor can solve "10ft-0in" to mean a value of 120". 

 

Hope this helps, 

Andrew

 

 

P. Andrew White, P.Eng
Consultant Manufacturing Engineer | Architect of Optimization | Autodesk Developer
0 Likes
Message 5 of 5

spanky
Contributor
Contributor

Thanks

0 Likes