sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Material area?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 1.1k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      duke
      last edited by

      In Sketchup, if you right click on a material theres an option to see the total area. Can I call this in my script?

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        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.

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          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 iterate Sketchup.active_model.entities, then each definition in Sketchup.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...

          TIG

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            And remember that a group or component can be skewed, affecting the area calculation as well.

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement