iLogic Rounding Issue when going from 2016 to 2018
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We're in the process of migrating from Inventor 2016 to 2018. I've run into an odd minor issue with an iLogic rule that had previously worked fine, and thus far haven't been able to figure out why it now behaves differently.
The issue is with the rounding. In 2016 and older, the rule would round the mass to the nearest whole number (zero decimal places). So if a piece actually weighed 99.5 lbs per the model, it would determine a value of "100", which then gets written to a custom iProperty.
Now, in 2018, the same code gives slightly different results. The rounding is correct numerically, but it displays an additional digit after the decimal place. So instead of "100", we get "100.0".
Can someone give me some direction as to why it now behaves differently, and what to do about it? Code is below.
' This rule copies the mass of the referenced model to a custom iProperty of the drawing. ' Allows stripping of the lbmass from the model mass, and forces update of model mass, ' keeping drawing weight up to date. Try model = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) mass = iProperties.Mass(model) lbs = Round(mass*2.20462262, 0) iProperties.Value("Custom", "Weight") = lbs InventorVb.DocumentUpdate() Catch iProperties.Value("Custom", "Weight") = 0 End Try