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

      You might be able to add some code to apply the offset to all loops of the face - currently it only works on the outer-loop, so inner 'holes' are not processed...

      Feel free to mess around with the code...

      TIG

      1 Reply Last reply Reply Quote 0
      • E Offline
        Einstein
        last edited by

        Well, I know there one was a plugin called TruOffset, which - I think as the only one - respected holes in faces and was also able to offset them. But it's lost in space, and I couldn't find it anywhere these days.
        I am referring to this thread:
        https://forums.sketchup.com/t/hole-aware-offset/83561
        It must have been removed from the Extension Warehouse. I saw it there a few years ago. Maybe it can be found somewhere.

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

          Hi TIG - I wonder if you'd give me access to the original ruby code - the plugin is not working in my 2020 version of SketchUP and I'd be interested in trouble-shooting the code.

          Thanks!

          Karen

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

            The tool's code is in the main RB file [because it's NOT made as an extension].

            Although the file's header says © & ...all-rights-reserved... etc I'd be happy for you to troubleshoot it...

            What are your problems with it ?

            TIG

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

              Hi TIG,

              The file I downloaded is "TIG_Smart_offset_v3.0.rbz"

              Forgive me - I've done extensive coding for my own use, but very little with other people's files. My understanding of *.rbz is that is a protected format and there isn't a way to view the original *.rb.

              I am getting one error related to Fixnum being deprecated, but the tool is also simply not offsetting for one of my test faces. It's a tricky face, and I haven't been able to write my own offset tool that works for it, which is how I came across your tool. (see below):


              Capture.PNG

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

                If you install an RBZ it puts various things into your Plugins folder automatically.
                Typically there'll be an RB 'loader' [easily read/edited in a text-editor like Notepad++]
                AND a subfolder named after the RB file - containing at least one 'signing' file, and in this case an image file used for a button ?
                All of the code for this tool just happens to be in the main RB file...

                A more complex 'extension' will include other Ruby files in the subfolder, which are loaded by the extension code set up in the first RB [these can be RB [readable] or RBE [encrypted] or defunct RBS [hackable] format].
                There might also be files such as HTML, JS, CSS, TXT, Images etc... used by the parts of code...

                The 'signing' file [SUSIG used currently, or also HASH once used in older SketchUps] is a snapshot of various sensitive files' set ups, as included in the originally submitted RBZ, signed by Trimble.
                Changing any of those files affects the SUSIG signing status - but with your Extension Manager's Loading Policy set to 'Unrestricted' the extensions will still load [of course you might have broken something whilst editing !]

                So to recap - if you install the RBZ you get its contents in your Plugins folder.
                BUT an RBZ file is only a ZIP file with another filetype suffix - so you could make a copy of it, rename it with a trailing .ZIP filetype and extract its contents to another folder...
                Conversely, adding suitable files and subfolders to a ZIP file and re-filetyping it as an RBZ, works...
                Of course it'll be missing any 'SUSIG' signing file added to the RBZ during processing by Trimble...

                TIG

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

                  Ah, there you go. Thank you!

                  If I figure out how to make it work for this face, I'll let you know with the updates.

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

                    Hi TIG - I got something working for my test case. I've inserted the following code at line 834:

                    ### CODE BY KAREN WALKERMAN
                    face.outer_loop.edges.each do |edge|
                       t1 = get_90_trans(face,edge,edge.start.position,dist)
                       t2 = get_90_trans(face,edge,edge.end.position,dist)
                       p1 = edge.start.position.transform(t1)
                       v1 = edge.line[1].reverse
                       v1.length = dist
                       p1.transform! Geom;;Transformation.new(v1)
                       p2 = edge.end.position.transform(t2)
                       v2 = edge.line[1]
                       v2.length = dist
                       p2.transform! Geom;;Transformation.new(v2)
                       line = gents.add_line(p1,p2)
                    end
                    			gp.entities.intersect_with(true,gp.transformation,gp.entities,gp.transformation,false,gp)
                    edges = []
                    gents.each{|e| edges << e if e.is_a? Sketchup;;Edge}
                    edges.each{|e| e.find_faces}
                    togos = []
                    gents.each do |e|
                       if e.is_a? Sketchup;;Edge
                          if e.faces.length != 1
                             togos << e
                          end
                       end
                    end
                    gents.erase_entities(togos)
                    # now add back original edges
                    o_points = []
                    face.outer_loop.vertices.each{|v| o_points << v.position}
                    gents.add_face(o_points)
                    ### END CODE BY KAREN WALKERMAN
                    

                    I've also added a method:

                    def self.get_90_trans(face,edge,p,length)
                       if edge.reversed_in? face
                          t = Geom;;Transformation.rotation(p,face.normal,Math;;PI/2)
                       else
                          t = Geom;;Transformation.rotation(p,face.normal,-Math;;PI/2)
                       end
                       trans_vector = edge.line[1].transform t
                       trans_vector.length = length
                       #Vector3d_Functions.round_vector_keep_length(trans_vector,6)
                       new_t = Geom;;Transformation.new(trans_vector)
                       return new_t
                    end
                    

                    what's the best way to test this further and (if successful) integrate it into the code?

                    I gather that with the updates to the native offset tool, people are probably not using this tool directly anymore, but for me it is helpful to be able to call an offset programmatically.


                    TIG-Smart_offset.rb

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      rv1974
                      last edited by rv1974

                      @TIG It'd be Genius Offset if it could perform in 'extend mode' (via modifier key - Alt, Ctrl..)
                      Screenshot 2024-05-05 073009.jpg

                      1 Reply Last reply Reply Quote 0
                      • V Offline
                        VD20
                        last edited by

                        This version is not working in SU 2025. Please if you could help in resolving this issue.

                        1 Reply Last reply Reply Quote 0
                        • BoxB Offline
                          Box
                          last edited by Box

                          Works fine for me. Do you have the most recent version?

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

                            The latest version works fine for me too, across all newer SketchUp versions.
                            What is your exact issue ?

                            TIG

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

                            Advertisement