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

    [Plugin] TIG-Smart_offset

    Scheduled Pinned Locked Moved Plugins
    143 Posts 55 Posters 164.8k Views 54 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      TI-Smart_offset.PNGTIG (c) 2012-2017
      All Rights Reserved.
      THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
      WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
      MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

      TIG-Smart_offset.rb

      Offsets edges of a specified face by a distance 'smartly'

      TIG::Smart_offset.new(face, distance)

      Overview:
      A +ve distance offsets the face's outer_loop outside of the loop.
      A -ve distance offsets the face's outer_loop inside the loop.
      If the face's outer_loop perimeter contains a thin inlet or thin peninsula
      then twisted loops are avoided and trimmed off, only a single non-twisted
      new face and edge-set is created.
      New edges crossing other coplanar faces will split them as appropriate.
      Holes in the face or unconnected but coplanar faces that overlap with the new
      geometry might be 'infilled', just as with the native 'offset'.
      On completion it returns an array containing the original face and any new
      face[s] created or affected by the creation of the new geometry, or 'nil'
      if no face could be created - e.g. the face was too small to contain the
      internal offset loop using the given -ve distance.
      The new face[s] have the same front/back material and layer as the face
      itself.
      Some very convoluted faces with 're-entrant' forms and 'inlets' can cause
      failures, because a fully 'neatened' set of offset edges cannot be determined...

      Usage:

      For developers it can be used as a method to call from within their own scripts.
      Add a "require 'TIG-Smart_offset.rb'" line into your code to ensure it's
      loading, OR adjust the [modified] code to run only within your own Module/Class.
      Remember to distribute this file with your scripts, because users probably won't
      have it installed.

      f = Sketchup.active_model.selection[0] # or other method the define 'f'...
      fa = TIG::Smart_offset.new(f, 1.2)

      'fa' returns as an array of faces - usually one face - created by the operation.
      'f' remains as a reference to the original face,
      fa[0] etc is the newly created face -
      with a +ve distance fa[0] etc is the outer 'donut' ring ['f' is the inner face],
      in the case of a -ve distance it is the inner face ['f' is the outer 'donut']

      OR from the 'Tools' menu > 'TIG.Smart_offset'.
      OR from the Context-menu > 'TIG.Smart_offset' .
      OR from the [activated] Toolbar > 'TIG.Smart_offset'.

      Which use the method:
      TIG::Smart_offsetter.dialog()

      In the dialog you enter the required offset in current units,
      [or add a units suffix for non-current dimensions].
      A +ve offset is applied outside of the face's outer_loop and a -ve offset is
      made inside the face's outer_loop.
      It mimics the native offset-tool in most respects, other than removing
      many of the spurious twisted offset line/loops.
      Curves/Arcs are offset as curves in the new offset outline.
      ALL selected faces are offset by the distance specified.
      The last used offset distance is remembered during that session.
      It is one step undo-able for all offsets.
      Do not use with the Outliner open and rolled-down, as this may cause splats!

      Version:
      1.0 20121221 First issue.
      1.1 20121221 Made more robust.
      1.2 20121221 Further robustness in enabling/suitable? [thanks to Jim!].
      1.3 20121221 Removed 'suitable?' method, to suit MACs, more error traps etc.
      1.4 20121222 Validation on applied to PCs, to avoid MAC toolbar glitch,
      1.5 20121224 Coding improved for truer, tidier offsets.
      1.6 20121225 Curves/Arcs are now offset as curves in the new offset outline.
      1.7 20121227 Further glitches and convoluted offsets trapped.
      1.8 20121228 Single welded curve loop offsets correctly. Fixed typo in weld.
      1.9 20121230 Error in code when called within another script fixed.
      2.0 20121231 Further refinements and glitch trapping.
      2.1 20121231 Glitch trapping extended to curves.
      3.0 20170510 Made compatible with newer versions...

      Donations:
      By PayPal.com to info @ revitrev.org
      PayPalButton

      TIG

      1 Reply Last reply Reply Quote 0
      • Rich O BrienR Online
        Rich O Brien Moderator
        last edited by

        Merry Xmas to you too.

        Nice tool

        Download the free D'oh Book for SketchUp πŸ“–

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Awesome TIG! Thanks for this one,

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • A Offline
            alpro
            last edited by

            Thanks TIG

            1 Reply Last reply Reply Quote 0
            • massimoM Offline
              massimo Moderator
              last edited by

              Merry Christmas TIG. πŸ˜„ πŸ‘

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

                Pilou

                There is a Ruby Console error message saying it can't be done [clearly it can !]
                I knew there was as reason I had never released this code !
                Now I need to find out what's wrong with it ??
                Merry Solstice...

                TIG

                1 Reply Last reply Reply Quote 0
                • pilouP Offline
                  pilou
                  last edited by

                  Tahnks for the gift before the end of world ! 😎

                  Seems marvellous but...(maybe I miss something 😳
                  The bow tie must not be disapear ?
                  (Normal Offset = Native Offset, Nothing = TIG_Smart_Offset )
                  Sorry for the inconvenience ! πŸ˜„

                  Cool_but.jpg


                  cool_but.skp

                  Frenchy Pilou
                  Is beautiful that please without concept!
                  My Little site :)

                  1 Reply Last reply Reply Quote 0
                  • pilouP Offline
                    pilou
                    last edited by

                    Bon courage! πŸ‘

                    Frenchy Pilou
                    Is beautiful that please without concept!
                    My Little site :)

                    1 Reply Last reply Reply Quote 0
                    • K Offline
                      kargall
                      last edited by

                      Works very well. Merry Xmas to you too. Thanks πŸ˜‰

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        driven
                        last edited by

                        undefined methodsuitable?' for TIG::Smart_offsetter:ModuleError Loading File TIG-Smart_offset.rb
                        undefined method suitable?' for TIG::Smart_offsetter:Module
                        but worked to a degree, the new border and face are separate and I can't seem to get them to merge with the original face?

                        john

                        learn from the mistakes of others, you may not live long enough to make them all yourself...

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

                          @driven said:

                          undefined methodsuitable?' for TIG::Smart_offsetter:ModuleError Loading File TIG-Smart_offset.rb
                          undefined method suitable?' for TIG::Smart_offsetter:Module
                          but worked to a degree, the new border and face are separate and I can't seem to get them to merge with the original face?

                          john
                          Strange there is a method called that ?
                          It checks selection for suitability and affects how the menu, toolbar and context-menu items display/enabled...
                          Are you on MAC ?
                          Was there a line number with that error ?
                          I'm about to issue v1.1 to resolve Pilou's tolerance issue...
                          I'll swap some code around to see if making that method earlier fixes it for you...
                          Let me know whatever you can... πŸ˜•
                          If it's still an issue a sample SKP might help...

                          TIG

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

                            Here's v1.1 http://sketchucation.com/forums/viewtopic.php?p=446462#p446462
                            It's been made more robust.
                            It now works on Pilou's problem shapes!Capture.PNG

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • D Offline
                              driven
                              last edited by

                              Hi Tig,
                              I'll try the new one but something really odd is going on, and yes I'm on a mac.
                              2012-12-21 01.06.32 am.png
                              I used SU to instal, and had line numbers then, so I removed it from 'plugins' to do again, but
                              this has been uninstalled, moved to trash, emptied trash, restarted computer, but it still there and it works, as well as it did, although sketchup can't find the file.... it's crazy, I don't have hidden files either.

                              I'll over write with the new
                              john

                              learn from the mistakes of others, you may not live long enough to make them all yourself...

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                driven
                                last edited by

                                found it, a new 'finder. replacement doesn't update instantly... bin that
                                ok no errors. menu cmd works, context cmd work, toolbar cmd dosen't do anything

                                It works if I split if the validation proc
                                cmd2=UI::Command.new('TIG.Smart_offset'){self.dialog()} cmd2.small_icon=File.join(dir, 'TIG-Smart_offset.png') cmd2.large_icon=File.join(dir, 'TIG-Smart_offset.png') toolbar=UI::Toolbar.new('TIG.Smart_offset') toolbar.add_item(cmd2)

                                john

                                learn from the mistakes of others, you may not live long enough to make them all yourself...

                                1 Reply Last reply Reply Quote 0
                                • Mistro11M Offline
                                  Mistro11
                                  last edited by

                                  You have no idea how many times I got frustrated doing an offset and have to get in there and clean up the shape. Thanks TIG!

                                  i7-4930k @3.4/3.7GHz, 32Gb RAM, NVidia GTX 980Ti 6Gb, Windows 7 Pro 64bit
                                  Structural Integrity is Not Just Physical...It's in the Design and Purpose

                                  1 Reply Last reply Reply Quote 0
                                  • jeff hammondJ Offline
                                    jeff hammond
                                    last edited by

                                    i'm all greyed out (on two separate computers with different OS & different versions of sketchup on them).. will investigate more tomorrow

                                    (skindigo toolbar as reference to what the blue/blacks should look like)

                                    dotdotdot

                                    1 Reply Last reply Reply Quote 0
                                    • N Offline
                                      notareal
                                      last edited by

                                      Merry Christmas to you too!

                                      Welcome to try [Thea Render](http://www.thearender.com/), Thea support | [kerkythea.net](http://www.kerkythea.net/) -team member

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

                                        in cmd.set_validation_proc (and other places) you want to give the full scope of the suitable? method since it is being called from SketchUp outside the scope of your module.

                                        Also, combine the MF_ bits.

                                        
                                        cmd=UI;;Command.new('TIG.Smart_offset'){self.dialog()}
                                        if TIG;;Smart_offsetter.suitable?()
                                        MF_ENABLED
                                        else
                                        MF_DISABLED | MF_GRAYED
                                        end
                                        
                                        

                                        Hi

                                        1 Reply Last reply Reply Quote 0
                                        • cottyC Offline
                                          cotty
                                          last edited by

                                          Nice gift! Thank you and Merry Christmas! (Are we allowed to use it before 24.12.?)

                                          my SketchUp gallery

                                          1 Reply Last reply Reply Quote 0
                                          • pilouP Offline
                                            pilou
                                            last edited by

                                            Yeeeeeeees! Works like a charm now! πŸ‘
                                            You are the Ruby's king! 😎

                                            And lucky because I can't more test your tricky plugin before the next year! πŸ˜„

                                            Super_TIG.jpg

                                            Frenchy Pilou
                                            Is beautiful that please without concept!
                                            My Little site :)

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 8
                                            • 1 / 8
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement