Is there any way to return the volume of a dc as an attribute? An irregular patio slab for example. I feel as though there should be an attribute or function for this…
As per your redraw solution, use ruby to extend the power of your DC
Sketchup.active_model.selection.grep(Sketchup::ComponentInstance).each do |s| if s.volume>-1 s.set_attribute "dynamic_attributes","vol_inch", s.volume s.set_attribute "dynamic_attributes","volume", "0" s.set_attribute "dynamic_attributes", "_volume_access","VIEW" s.set_attribute "dynamic_attributes","_volume_formlabel","Volume (cubic ft) " s.set_attribute "dynamic_attributes","_volume_formula", "ROUND(vol_inch/1728,2)" end $dc_observers.get_latest_class.redraw_with_undo(s) end
Been a very busy building season up here in Canada. Just got time to try this AWESOME bit of Ruby. Thank you! I’d love to learn at some point, just need more free time…
Question, when I try to reference the attribute inside the DC, to add it to a formula in another attribute i get this error message. Any way to fix this?
If the attribute ‘volume’ and ‘vol_inch’ are already in the DC, then it is defined as far as the DC code is concerned. I am yet to figure how to assure this is passed via the script
Hey @pcmoor, did you ever get any further with this? I found by manually entering the attribute name I can bypasses the error and use it in other formulas. Wondering about getting it to refresh on a re draw, currently you need to run the script again.