- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
wrong reading of Desity. why and how to fix it ?
I have a code that read the Density. but some times it read it wrong ... is there a way to fix it ?
My current code look somthing close to this, but if I run it on the files I send it say densit is = 1 but it is 3,141 . normaly I can just make small change in the file... and it will fix it .. but I would like to have the right number always.. is that possible ?.. My real code run on an assambly
Dim rDoc As Document
rDoc = ThisDoc.Document
Dim docPropertySet As PropertySet
docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties")
Dim test
test = docPropertySet.Item("Density").Value
MsgBox(test)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I would probably update all the physical properties of the document by adding this line :
Dim rDoc As Document
rDoc = ThisDoc.Document
Dim docPropertySet As PropertySet
docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties")
Dim test As Double
ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute
test = docPropertySet.Item("Density").Value
MsgBox(test)
Maybe you can find what you are looking for here :
Kind regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I use this for mass in iLogic:
Dim NewMass As Double
NewMass = Round(iProperties.Mass, 2)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It's working like a charm on my end. How are you updating the density of the part ?
Kind regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When dealing with things like Mass, Volume, & Density, it is almost always best to go the API route, and access the MassProperties object. Then, if you need to make sure the value is up to date, you may need to adjust the 'Accuracy' setting. Adjusting the accuracy will force an update and recalculation before retrieving the new value at that accuracy level. There was a thread about this somewhere here on this forum a couple\few years ago in which an Autodesk employee pointed this out. And the one API sample VBA macro shows an example of this type of thing too, but goes into too much other detail for most folks. However, values obtained through the API route will usually need to have the units converted from 'database units' (g/cm^3) to 'document units'. The simplistic iLogic snippet iProperties.Mass will return the Mass value in document units directly, but the online documentation for that property does not say anything about causing an update.
Edit: By the way, I know the MassProperties object does not have a direct property for Density, but getting that value is as simple as Mass/Volume, so it is fairly simple to obtain that way.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Density 1 is from Material "Generic".
Mass is override, density is calculated.