Change a number in a range using I-logic

Change a number in a range using I-logic

Anonymous
Not applicable
791 Views
2 Replies
Message 1 of 3

Change a number in a range using I-logic

Anonymous
Not applicable

Hello,

 

I have a question. I made in my past several I-logic rule, only now im running stuck. 

I want to round up my custom property (weight="gewicht").

 

Only when i get the mass the custom property keeps on 0. Why?

 

I made the following rule:

Dim propertyName As String = "Gewicht"

If (mass <= 30) Then
	iProperties.Value("Custom", "Gewicht") = Ceil(mass / 1) * 1 & " Kg"
	
ElseIf (mass > 30) And (mass <= 100)  Then
	iProperties.Value("Custom", "Gewicht") = Ceil(mass / 5) * 5 & " Kg"
	
ElseIf (mass > 100) And (mass <= 1000)  Then
	iProperties.Value("Custom", "Gewicht") = Ceil(mass / 10) * 10 & " Kg"
	
ElseIf (mass > 1000) Then 
	iProperties.Value("Custom", "Gewicht") = Ceil(mass/50)*50 & " Kg"	

	
End If

 Can someone help me out, thx.

0 Likes
Accepted solutions (1)
792 Views
2 Replies
Replies (2)
Message 2 of 3

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, Try the following rule, I have not used the ilogic shortcut to access the property of mass, because this access uses the units that you assign to the document, then use the access that uses the units in kg regardless of the units used in Document properties
I placed a message box to check that the value has the unit I need, then I have grayed it out as a comment. 

Dim oDoc As Document = ThisDoc.Document
Dim oCD As ComponentDefinition = oDoc.componentdefinition

Dim oMass as Double = oCD.MassProperties.mass' units in kg
'MessageBox.Show(oMass)

Dim propertyName As String = "Gewicht"

If (oMass <= 30) Then ' oMass <= 30 kg
	iProperties.Value("Custom", "Gewicht") = Ceil(oMass / 1) * 1 & " Kg"
ElseIf (oMass > 30) And (oMass <= 100)  Then 
	iProperties.Value("Custom", "Gewicht") = Ceil(oMass / 5) * 5 & " Kg"
ElseIf (oMass > 100) And (oMass <= 1000)  Then
	iProperties.Value("Custom", "Gewicht") = Ceil(oMass / 10) * 10 & " Kg"
ElseIf (oMass > 1000) Then 
	iProperties.Value("Custom", "Gewicht") = Ceil(oMass/50)*50 & " Kg"	
End If

I hope this helps solve your problem. Regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 3

Anonymous
Not applicable

Thank you very much!

0 Likes