Custom property updated with wrong value

Custom property updated with wrong value

alexander.hendrix
Contributor Contributor
418 Views
5 Replies
Message 1 of 6

Custom property updated with wrong value

alexander.hendrix
Contributor
Contributor

Hi all,

 

I'm stumped why this does not work. I want to populate a custom iProperty with the paint weight in kg based on the area of the model: 

 

 

 

iProperties.Value("Custom", "LakkVektkg") = (Ceiling(iProperties.Area * 0.125e-6 kg/mm^2*1000)/1000) & " kg"

 

 

 

 When I run this in a separate external rule directly, it works as it should. The paint weight reads for example: "0,129 kg" (without the "). The strange behaviour exists when I either call the external rule from another rule or put the same code inside another external rule. Then the value becomes: "0,000 kg". However, when I use a messagebox to show the value of the iProperty during running the code, it shows "0,129 kg".

 

I tested one more thing and running the external rule "Overflate" with an event trigger, gives the same result of 0,000 kg.

 

 
0 Likes
419 Views
5 Replies
Replies (5)
Message 2 of 6

JelteDeJong
Mentor
Mentor

in some cases (and maybe this case) Inventor uses the database units and not the document units. therefore the area might be in cm^2 and mm^2 in the other case. Maybe that is the problem. (More info also here http://hjalte.nl/46-parameter-document-database-units )

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 6

alexander.hendrix
Contributor
Contributor
Hi Jelte,

Thanks for the clarification. I'm trying to use the function you linked to on your blog, but this is created for parameters and not iProperties. So it throws a lot of errors because the iProperty is not a parameter.
0 Likes
Message 4 of 6

alexander.hendrix
Contributor
Contributor
0 Likes
Message 5 of 6

JelteDeJong
Mentor
Mentor

I did have a better look at the problem. I should have noticed the units in your formula. In normal programming languages that would not be allowed. But iLogic seems to make something out of it and converts it to something. Something is the problem here. I did check and the first time it was converted to the following:

iProperties.Value("Custom", "LakkVektkg") = (Ceiling(iProperties.Area * CDbl(CDec(0.000000125) * CDec(1422.3343307119562)) * 1000) / 1000) & " kg"

in another part it was converted to:

iProperties.Value("Custom", "LakkVektkg") = (Ceiling(iProperties.Area * 0.125e-6 * 1000) / 1000) & " kg"

That is at best not stable.  I would suggest that you convert the line to something that doesn't need to be converted by iLogic. (Preventing wrong conversions)

Something like this:

iProperties.Value("Custom", "LakkVektkg") = (Ceiling(iProperties.Area * 0.125 * 10 ^ (-6) * 1000) / 1000) & " kg"

Or you can do this:

iProperties.Value("Custom", "LakkVektkg") = (Ceiling(iProperties.Area * 0.125 * 10 ^ (-3)) / 1000) & " kg"

 

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 6 of 6

alexander.hendrix
Contributor
Contributor

That make sense. I do not know why I put the units inside the formula. I tried the following and ended up with the same result:

iProperties.Value("Custom", "LakkVektkg") = (Ceiling(iProperties.Area / (8 * 10^6) * 1000) / 1000) & " kg"

When the external rule is run directly, the iProperty shows the correct value. Whenever I have added it to another external rule or run with event triggers, the outcome is 0,000 kg. So it seems to me that it has something to do with the database units as you described before where the Area has another unit and the result of the formula is so small, it shows as 0,000 kg.

 

Regarding the database units, I have tried to dig into how to work with database units and iProperties, but all I can find is regarding parameters and not iProperties. I'm still no expert, so I am lost on how to 'convert' it to the correct unit in the calculation (either it is local or external rules that are run).

 

I still do find it strange that the output in the messagebox during code execution shows the correct value (see the screencast link in one of my replies above), but it still shows 0,000 kg when I open the iProperties afterwards.

0 Likes