sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Get height and width of an entity

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 3 Posters 284 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.
    • J Offline
      janad
      last edited by

      Hi,
      I'm trying to create a plugin where I need to get the height and width of each entity. Does anyone know how I do that?

      best Jan

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

        The API's .bounds returns a bounding-box, from that you can find many things... http://code.google.com/apis/sketchup/docs/ourdoc/boundingbox.html

        TIG

        1 Reply Last reply Reply Quote 0
        • J Offline
          janad
          last edited by

          Hi and thanks for your quick reply,
          what I really meant was how to get hight and width for each face.

          Best Jan

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

            A face has bounds too...
            A face also has an area - which might be a quick way of getting what I am deducing you want... ❓

            TIG

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

              If you want to iterate through to find all faces then use something like
              faces = []; Sketchup.active_model.active_entities.each{|e|faces << e if e.class == Sketchup::Face}
              then process the faces
              area = 0.0; faces.each{|face|area = area + face.area}
              The variable area is returned in square inches so apply a factor to it to suit your needs - e.g.
              area_sqm = area * 0.00064516
              to make it into square meters...
              If you actually need the height/width of each face use face.bounds - note that the 'bounds' height/width/depth terminology is contrary to what you might think - so play around with different sized faces to see which method returns what...

              TIG

              1 Reply Last reply Reply Quote 0
              • J Offline
                janad
                last edited by

                Super - thanks!
                I've already managed to find the area, but had problems finding width and height. But thanks to the bounds class it seems that I can solve it. Thanks again πŸ˜„

                best Jan

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by

                  Just a note -

                  Sketchup.format_area manages the conversion from sq. in. to model units.

                  If the Model Units are mm;

                  Sketchup.format_area(1.0).to_f
                  ==> 645.16
                  

                  Hi

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

                    @jim said:

                    Just a note -

                    Sketchup.format_area manages the conversion from sq. in. to model units.

                    If the Model Units are mm;

                    Sketchup.format_area(1.0).to_f
                    > ==> 645.16
                    

                    One of the more useless aspects of this 'method' [ .format_area] is that you will often draw in mmor cmbut want areas in sqm! Like drawing in inchesand wanting areas in sqft...

                    SUp has many methods that are easily done another way but lacks so many methods it still really needs... 😠

                    TIG

                    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