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

[Plugin] Scale Face to Target Area - TIG

Scheduled Pinned Locked Moved Plugins
46 Posts 11 Posters 25.3k Views
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
    jorge2011
    last edited by 8 Aug 2012, 02:20

    You see this plugin?

    http://rubits.com/play.php?file=areascale

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 8 Aug 2012, 07:47

      @jorge2011 said:

      You see this plugin?

      http://rubits.com/play.php?file=areascale

      That's nice looking. The VCB is a nice way to control it. But I think $10 is too much for such a trivial script. πŸ˜•

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

      1 Reply Last reply Reply Quote 0
      • E Offline
        EarthMover
        last edited by 8 Aug 2012, 13:18

        TIG, having an issue with your script loading properly. I copied and pasted the code exactly into a notepad file and named it - TIG-scale_face.rb. Upon loading Sketchup, I get no errors, but none of my toolbars load. When I delete the script, all the toolbars load again.

        3D Artist at Clearstory 3D Imaging
        Guide Tool at Winning With Sketchup
        Content Creator at Skapeup

        1 Reply Last reply Reply Quote 0
        • E Offline
          EarthMover
          last edited by 8 Aug 2012, 14:43

          Thom, excuse my ignorance, but how would I going about testing your code?

          3D Artist at Clearstory 3D Imaging
          Guide Tool at Winning With Sketchup
          Content Creator at Skapeup

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 8 Aug 2012, 15:15

            @earthmover said:

            Thom, excuse my ignorance, but how would I going about testing your code?

            Sorry Adam, I typed it up and posted in a hurry. You'd put it in a .rb file and form the console invoke: TT_ScaleToArea.scale_face( Sketchup.active_model.selection[0], 4000 )

            Didn't have the time to add UI.

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

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 8 Aug 2012, 15:53

              The code is now tested and working version... I edited the original ! http://forums.sketchucation.com/viewtopic.php?p=419936#p419936
              Stupid typo unless**.**file_loaded? instead of unless file_loaded?
              I added the UI as an afterthought and never tested it sorry!

              TIG

              1 Reply Last reply Reply Quote 0
              • E Offline
                EarthMover
                last edited by 9 Aug 2012, 14:11

                Thanks TIG. It works as long as I am using a decimal unit type. With fractional units, it deletes everything in the model. Not sure why, just have to remember to switch the units before using the plugin. Thanks again. I'll update the first post with the rb file.

                Also it is still stating inches in the dialog even when the units are feet. No big deal though. Works for what I need. Thanks again! πŸ‘ πŸ‘


                Clipboard01.jpg

                3D Artist at Clearstory 3D Imaging
                Guide Tool at Winning With Sketchup
                Content Creator at Skapeup

                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 9 Aug 2012, 14:21

                  I'll adjust the code... I did type it on the fly...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • E Offline
                    EarthMover
                    last edited by 9 Aug 2012, 15:18

                    If you have time. If not, no worries. I just figured I'd mention the issues in case anyone else needed to use the plugin.

                    3D Artist at Clearstory 3D Imaging
                    Guide Tool at Winning With Sketchup
                    Content Creator at Skapeup

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      TIG Moderator
                      last edited by 9 Aug 2012, 15:26

                      I've updated the .rb in your post and edited the post's text to match [hope you are OK with that πŸ˜‰ ]
                      It now handles all Unit-types/Fractional/Engineering etc properly.
                      One oddity is that 'Engineering' displays on screen in 'feet', but the API unit-type [LengthUnit] is left in 'inches' [0] - unlike all other types where the 'LengthUnit' matches the displayed-unit.

                      Anyway it now works for all combos... I hope πŸ˜•

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • E Offline
                        EarthMover
                        last edited by 9 Aug 2012, 16:12

                        Works great now. Thanks again.

                        3D Artist at Clearstory 3D Imaging
                        Guide Tool at Winning With Sketchup
                        Content Creator at Skapeup

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          hebeijianke
                          last edited by 9 Aug 2012, 17:36

                          @tig said:

                          I've updated the .rb in your post and edited the post's text to match [hope you are OK with that πŸ˜‰ ]

                          This plug-in only applies to the quadrangle

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            TIG Moderator
                            last edited by 9 Aug 2012, 18:04

                            NO, it works on any face.
                            The selected face is simply scaled to have the desired area.
                            The dialog shows the current area in current units.
                            You enter the new area and OK.
                            The selected face is made to have that area.
                            So if it's a square, a star or a circle it doesn't matter...

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • B Offline
                              bmike
                              last edited by 9 Aug 2012, 19:31

                              This is a great little plugin.
                              Any chance to make it work in square ft, when my units are set to Architectural?

                              Or do I need to divide by hand first...?

                              mike beganyi design + consulting llc

                              1 Reply Last reply Reply Quote 0
                              • E Offline
                                EarthMover
                                last edited by 9 Aug 2012, 19:34

                                Works on almost any face. Faces created by the freehand tool seem to fail to resize properly. Not sure why.

                                3D Artist at Clearstory 3D Imaging
                                Guide Tool at Winning With Sketchup
                                Content Creator at Skapeup

                                1 Reply Last reply Reply Quote 0
                                • J Offline
                                  jorge2011
                                  last edited by 9 Aug 2012, 20:52

                                  @thomthom said:

                                  @jorge2011 said:

                                  You see this plugin?

                                  http://rubits.com/play.php?file=areascale

                                  That's nice looking. The VCB is a nice way to control it. But I think $10 is too much for such a trivial script. πŸ˜•

                                  YES thomthom. You are right, it's a plugin with a high cost.
                                  I made the post, the plugin is very interesting, and has features that can be added to the free version plugin of sr. TIG.

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    TIG Moderator
                                    last edited by 10 Aug 2012, 08:46

                                    @bmike said:

                                    This is a great little plugin.
                                    Any chance to make it work in square ft, when my units are set to Architectural?
                                    Or do I need to divide by hand first...?
                                    Here's a version of the code for users who want to work in feet OR inches [any kind] and see 'sq ft' areas; it also does 'sq m' areas if the user is using any metric units [m/cm/mm]... Copy the code and paste it into the .rb file using Notepad or similar plain-text editor - overwriting all of the original code...

                                    require 'sketchup.rb'
                                    ###
                                    module TIG
                                    ### scales a selected face about its center to a new area, in current units.
                                    	def self.scale_face()
                                    		model=Sketchup.active_model
                                    		es=model.active_entities
                                    		ss=model.selection
                                    		fa=nil
                                    		fa=ss[0] if ss[0]
                                    		unless fa && fa.is_a?(Sketchup;;Face)
                                    			UI.messagebox("Scale_Face;\n\nPreSelect ONE FACE !")
                                    			return nil
                                    		end
                                    		ar=fa.area
                                    		mo=model.options["UnitsOptions"]
                                    		if mo["LengthUnit"] > 1 ### metric
                                    			units="m"
                                    			ar=ar*25.4*25.4/1000/1000
                                    		else ### ft/"
                                    			units="ft"
                                    			ar=ar/12.0/12.0
                                    		end
                                    		rs=inputbox(["New Area [sq "+units+"];        "], [ar], "Scale_Face")
                                    		return nil unless rs
                                    		na= rs[0]
                                    		na= -na if na < 0
                                    		unless na>0
                                    			UI.beep
                                    			return nil
                                    		end
                                    		ro=Math.sqrt(na/ar)
                                    		pt=fa.bounds.center
                                    		tr=Geom;;Transformation.scaling(pt, ro)
                                    	  model.start_operation("Scale_Face")
                                    		es.transform_entities(tr, fa.vertices)
                                    	  model.commit_operation
                                    	end
                                    	###
                                    	UI.menu("Plugins").add_item("Scale_Face"){self.scale_face()} unless file_loaded?(__FILE__)
                                    	file_loaded(__FILE__)
                                    	###
                                    end
                                    ###
                                    
                                    

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • E Offline
                                      EarthMover
                                      last edited by 10 Aug 2012, 15:45

                                      Thanks TIG. That's even better!

                                      3D Artist at Clearstory 3D Imaging
                                      Guide Tool at Winning With Sketchup
                                      Content Creator at Skapeup

                                      1 Reply Last reply Reply Quote 0
                                      • T Offline
                                        TIG Moderator
                                        last edited by 10 Aug 2012, 15:46

                                        Do you want to add an alternative version .rb in the first post ?

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • E Offline
                                          EarthMover
                                          last edited by 10 Aug 2012, 16:10

                                          Sure, I can. If you feel like dropping it in it's own thread for proper indexing, let me know and I'll remove the bracketed plugin wording. Or feel free to edit it yourself if need be. I don't mind at all.

                                          3D Artist at Clearstory 3D Imaging
                                          Guide Tool at Winning With Sketchup
                                          Content Creator at Skapeup

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

                                          Advertisement