sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Sequential naming of unique components eg fence palings

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    6 Posts 2 Posters 1.1k Views 2 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.
    • U Offline
      unearthed
      last edited by unearthed

      Hi, I'm designing a fence (see image) where each upright (each is a unique component) is a different length. Then I'm using TIG's component reporter++ http://sketchucation.com/forums/viewtopic.php?p=147658#p147658to export a csv.

      Due to drawing process the components are not 'in order' (to make different lengths I used intersect surface, then Christ Fulmer's loose to groups, then ThomThoms groups to components) - I'd like them numbered e.g. from left to right: 1 to n, then when I export I'd have an in order column which would make it easier for the fabricator to make the fence and easily query me about any variant issues.

      Has anyone solved something like this?

      I'm going to add more info to this later today


      component sequential names eg left to right naming question.JPG

      Growplan - People ∩ Plants ∩ Place

      windows 7 64b, 4GB RAM, SU 8.0.16846
      Gimp, QGIS, Vectorworks 12, Bricscad 11

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        There is a Component Instance name and a Component Definition name

        To sequence the Instance names from left to right

        mod = Sketchup.active_model
        ent = mod.active_entities
        sel = mod.selection
        unless sel.empty?
          cis = sel.grep(Sketchup;;ComponentInstance).sort_by{|ci|ci.bounds.min.x}
          cis.each_with_index{|ci,i| ci.name=(i+1).to_s}
        else
          UI.messagebox "Nothing Selected"
        end
        
        

        To sequence the Definition names

        mod = Sketchup.active_model
        ent = mod.active_entities
        sel = mod.selection
        unless sel.empty?
          cis = sel.grep(Sketchup;;ComponentInstance).sort_by{|ci|ci.bounds.min.x}
          cis.each{|ci| ci.make_unique if ci.definition.count_instances>1}
          cis.each_with_index{|ci,i| ci.definition.name=(i+1).to_s}
        else
          UI.messagebox "Nothing Selected"
        end
        
        

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • U Offline
          unearthed
          last edited by

          Hi again Sdmitch, How do I run this? (Hoping answer isn't too obvious!)

          Growplan - People ∩ Plants ∩ Place

          windows 7 64b, 4GB RAM, SU 8.0.16846
          Gimp, QGIS, Vectorworks 12, Bricscad 11

          1 Reply Last reply Reply Quote 0
          • sdmitchS Offline
            sdmitch
            last edited by

            @unearthed said:

            Hi again Sdmitch, How do I run this? (Hoping answer isn't too obvious!)
            Select the components. Select, copy and paste the code into Window>Ruby Console and press Enter.

            If it works for you, we can make it into a plugin so you can execute it from the Plugins or Context menu.

            Nothing is worthless, it can always be used as a bad example.

            http://sdmitch.blogspot.com/

            1 Reply Last reply Reply Quote 0
            • U Offline
              unearthed
              last edited by

              Hi, It seems to work fine, the first part doesn't seem to change anything (will run again later and check tho'), and the second part does the sequential name/numbering. Amazing.

              I ended up using Aerilius' console http://sketchucation.com/forums/viewtopic.php?p=414816#p414816 as the default doesn't seem to accept multiline paste.


              component sequential naming.JPG

              Growplan - People ∩ Plants ∩ Place

              windows 7 64b, 4GB RAM, SU 8.0.16846
              Gimp, QGIS, Vectorworks 12, Bricscad 11

              1 Reply Last reply Reply Quote 0
              • sdmitchS Offline
                sdmitch
                last edited by

                The "first" part worked because the "Name:" was changed. The "second" part changed the "Definition Name:" which is apparently what you were looking for. So just ignore the first part.

                My apologies, I forgot that SU8 doesn't accept multi-line input. But since you have Aerilius' console, you can save the snippet and recall and use it anytime you need it.

                Be aware that, as written, the code expects the components to not be aligned with or along the "Y" axis. Otherwise, it should always work.

                Nothing is worthless, it can always be used as a bad example.

                http://sdmitch.blogspot.com/

                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