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

    [Plugin] Make Unique (find or request)

    Scheduled Pinned Locked Moved Plugins
    11 Posts 5 Posters 1.2k Views 5 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.
    • fredo6F Offline
      fredo6
      last edited by

      Tom,

      FredoScale includes a Make uniquefunction that should work on a pre-selection or by pick and choose.

      It is however recursive, that is components within groups and components will also be made unique.

      Fredo

      Make unique.gif

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

        This code snippet will 'make_unique' all selected instances.
        It does not affected nested components.

        def makeallunique()
          model=Sketchup.active_model
          sel=model.selection
          sela=sel.to_a
          sela.each{|e|
            if e.class==Sketchup;;ComponentInstance and e.definition.instances[1]
              e.make_unique
            end#if
          }
        end#def
        
        

        If you want to remove their 'face_me-ness' use this afterwards...

        def makeallnotfaceme()
          model=Sketchup.active_model
          sel=model.selection
          sela=sel.to_a
          sela.each{|e|
            if e.class==Sketchup;;ComponentInstance and not e.definition.instances[1] and e.definition.behavior.always_face_camera
              e.definition.behavior.always_face_camera=false
            end#if
          }
        end#def
        

        makeallunique.rb

        TIG

        1 Reply Last reply Reply Quote 0
        • T Offline
          tomsdesk
          last edited by

          Thanks, Guys, I'll guess one or both of these would work...but I don't understand some of your terms, so I'd better explain better what I'm looking for:

          My new 2.5D+ trees are non-face-me components with face-me leaf-bunch components nested within them...so you can rotate the tree (or change the view) and another side of the trunk and branches show (like a real tree, sorta). One (or several copies facing the same way) renders great:
          unique1.jpg

          Once a copy is rotated all the nested face-me components render as if facing the same (in relation to the "front" of the outside tree component) as the last copy...below the right copy is rotated 90deg:
          unique2.jpg

          ...below the copy is made unique, and now both render correctly:
          unique3.jpg

          ...below the first copy is rotated 60deg, the second an additional 60deg, so the original is rendered as if the leaf pngs are facing away from the camera:
          unique6.jpg

          But SU's "make unique" does not make the nested leaf-bunch components unique, only the outside tree component...an obvious advantage, to me at least: so, do either of these ruby's work as I'm hoping?

          http://www.tomsdesk.moonfruit.com/
          2.5D Trees & Shrubs!

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

            @tig said:

            This code snippet will 'make_unique' all selected instances.
            It does not affected nested components.

            I can't seem to make this script work (the make unique script). I'm pasting the script into the web console, selecting all the components I want to make unique, and evaluating the code. It appears that it's working, but then the names of the components remain unchanged.

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

              @danbig said:

              @tig said:

              This code snippet will 'make_unique' all selected instances.
              It does not affected nested components.

              I can't seem to make this script work (the make unique script). I'm pasting the script into the web console, selecting all the components I want to make unique, and evaluating the code. It appears that it's working, but then the names of the components remain unchanged.

              Recopy it now!
              I've corrected a typo that should have returned an error message!
              It should now work... 😳

              TIG

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

                @tig said:

                Recopy it now!
                I've corrected a typo that should have returned an error message!
                It should now work... 😳

                Hmmm. It's still behaving the same way.

                The outliner "blinks" like the script is working, but the names still remain the same.

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

                  Here's a similar thread where a script is posted that is working for me (TIG, I remain grateful to you for this and your many other contributions; I'm not sure why this one isn't working for me):

                  http://forums.sketchucation.com/viewtopic.php?f=323&t=31648&p=279496#p279496

                  1 Reply Last reply Reply Quote 0
                  • honoluludesktopH Offline
                    honoluludesktop
                    last edited by

                    Tig, your script runs OK in my system, could Tom be experiencing problems with another plugin? Anyway, can you tell me why you elected to make an array sela=sel.to_a of sel = model.selection, and then use class.e==..... instead of e.is_a? ?

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

                      @honoluludesktop said:

                      Tig, your script runs OK in my system, could Tom be experiencing problems with another plugin? Anyway, can you tell me why you elected to make an array sela=sel.to_a of sel = model.selection, and then use class.e==..... instead of e.is_a? ?

                      If you process a selection that changes [typically from an 'erase!'] [and the same with entities] and where later you might rely on its contents to be consistent, it's a good idea to take a 'snapshot' of it with .to_a AND use e.valid? tests... Otherwise every time you look at the 'selection' or 'entities' it might change unexpectedly...
                      There are several ways of checking on the 'type' of thing you have.
                      The SUp method e.typename=="Edge" is fine for testing a few things... but it's slow if there are many iterations.
                      Ruby native methods like e.is_a?("Edge") or e.kind_of?("Edge") or even e.instance_of?("Edge") are [usually] quicker, but...
                      the base method e.class==Sketchup::Edge is the base test and it is [usually] the fastest...
                      [you have a typo in your post, it's e.class... NOT class.e...]

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • honoluludesktopH Offline
                        honoluludesktop
                        last edited by

                        Tig, thanks for the lesson. Class.e, must have been thinking about that Benz model:-)

                        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