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

    Area to text

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 4 Posters 163 Views 4 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
      Jakesie
      last edited by

      Good day,

      I am trying to make a simple plugin to add up the area of selected faces and write them to txt or perhaps xml?

      I have no idea where to begin 😞

      DOes anyone have a guide or link for me to an example perhaps? will be gladly appreciated!

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

        Set up some variables...
        @model=Sketchup.active_model @ss=@model.selection
        'Collect' the selected faces...
        faces=@ss.grep(Sketchup::Face)
        add up the areas [in sq"]...
        area=0.0 faces.each{|face|area+=face.area}
        Now if desired covert to other units [here sqm]...
        area=area/1,550.00310000620001
        Now add the text [here we'll add it as 'screen-text' aka 'note']
        @model.add_note("Area=#{area}sqm", 0.1, 0.1)

        Obviously there are many ways to do this, e.g. add text with a leader onto one of the faces...
        @model.active_entities.add_text("Area=#{area}sqm", faces[0].bounds.center, [11,11,11]) if faces[0]
        Also sprintf() can be used to adjust the displayed decimal places etc...

        TIG

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          Pay attention to the shaded "sticky" posts at the top of the list. There are code snippet indexes, etc. to help you.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • tt_suT Offline
            tt_su
            last edited by

            Note that when computing the area of the faces you want to apply the transformation of the parent context in order to get the correct size. The Face.area method accepts and optional transformation argument.

            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