Material area?
-
In Sketchup, if you right click on a material theres an option to see the total area. Can I call this in my script?
-
Not as a single method, you'd have to iterate the whole model, test for visibility and calculate the area of the faces you traverse with the total transformation of that context.
-
Let's assume you have a reference to a material '
mat
'
OR you get it from a selection thus
mat=nil Sketchup.active_model.selection.each{|e| (mat=e.material;break) if e.class==Sketchup::Face end }
Then iterate through the model's active entities thus:
area=0 Sketchup.active_model.active_entities.each{|e| area+=e.area if e.class==Sketchup::Face and e.material==mat }
You now have the total area of faces in the active context using that material in sq".
IF you want ALL of the areas of ALL of the faces everywhere, then you need to iterateSketchup.active_model.entities
, then eachdefinition
inSketchup.active_model.definitions
- which includes components, groups and images so you'll need to filter for those.
Also remember that each definition might have several instances [or even none] so you need to adjust the area total for the number of instances.... AND perhaps take into account the scaling transformation of each instance because [and the scaling of its container if any etc] it'll affect the [apparent] area too... but it's all do-able... -
And remember that a group or component can be skewed, affecting the area calculation as well.
Advertisement