ilogic rule to round up to nearest foot

ilogic rule to round up to nearest foot

DougJohnston
Contributor Contributor
209 Views
4 Replies
Message 1 of 5

ilogic rule to round up to nearest foot

DougJohnston
Contributor
Contributor

Good afternoon all,

 

I need some help creating a rule, but I am not that experienced with the "MATH" ilogic functions.  So, I would appreciate any help I can get.

 

 

I have an assembly that is being driven by a parameter ("door_WIDTH") and I would like to round-up the overall length in (2) stages / increments.

 

The first increment is to round-up to the next inch: 

  eg.  ( 66.625" + 0.375" ) = 67"  

 

Then the second increment is to round-up to the next foot:

   eg.  ( 67" )  to ( 72" )

 

Can anyone help me out with the code ??

 

Thanks,

Doug J.

 

0 Likes
Accepted solutions (1)
210 Views
4 Replies
Replies (4)
Message 2 of 5

Curtis_Waguespack
Consultant
Consultant

Hi @DougJohnston , I think this will do what you're asking.

 

Curtis_Waguespack_1-1747088586477.png

 

 

Hope that helps,

Curtis

 

' Get the door width parameter
Dim doorWidth As Double = door_WIDTH

roundedToInch = Ceil(doorWidth)

inc = 12 
roundedToFootInches = Ceil(Round(doorWidth) / inc) * inc

roundedToFoot = Ceil(Round(doorWidth) / inc) 

' Display the results for verification
MessageBox.Show("Original width: " & doorWidth & """" & vbCrLf & _
                "Rounded to inch: " & roundedToInch & """" & vbCrLf & _
                "Rounded to feet in inches : " & roundedToFootInches & """" & vbCrLf & _
                "Rounded to feet: " & roundedToFoot & "'")

 

EESignature

0 Likes
Message 3 of 5

DougJohnston
Contributor
Contributor

Morning Curtis,

 

It works the way I wanted .... 

 

Now I need that final (36") to be transferred as a custom parameter I can use in my model (parameter "track_hinged_section_length")

 

 

I know it is pretty easy, but I am having a "blonde moment" and can't remember how to convert it to a custom parameter.

 

Thanks, Doug J.

0 Likes
Message 4 of 5

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Good morning @DougJohnston,

 

Here's an update. This version will try to get the parameter and then create it, if it does not exist.

 

Hope that helps,

Curtis

 

 

Curtis_Waguespack_0-1747143259328.png

 

iLogicVb.UpdateWhenDone = True

' Get the door width parameter
Dim doorWidth As Double = door_WIDTH

roundedToInch = Ceil(doorWidth)

inc = 12
roundedToFootInches = Ceil(Round(doorWidth) / inc) * inc

' Get the UserParameters collection
Dim UserParams As UserParameters = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters
Dim ParameterName As String = "track_hinged_section_length"
Dim trackParam As UserParameter

Try' Try to get the parameter	
	trackParam = UserParams.Item(ParameterName)
Catch' Parameter not found, so create it with the correct units	
	trackParam = UserParams.AddByValue(ParameterName, 1, UnitsTypeEnum.kInchLengthUnits)
End Try

Parameter(ParameterName) = roundedToFootInches 

' Display the results for verification
MessageBox.Show("Original width: " & doorWidth & """" & vbCrLf & _
"Rounded to inch: " & roundedToInch & """" & vbCrLf & _
"Rounded to feet in inches : " & roundedToFootInches & """")

 

EESignature

Message 5 of 5

DougJohnston
Contributor
Contributor

Thank you very much Curtis 

 

The updated code works perfectly for what I need .... I appreciate all assistance !!