sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Retrieve Color Layer assigned by Sketchup

    Scheduled Pinned Locked Moved Developers' Forum
    16 Posts 4 Posters 1.4k Views 4 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.
    • C Offline
      c.plassais
      last edited by

      thank you TIG

      I downloaded your plugin and I looked
      It's for my little plugin ➑ http://forums.sketchucation.com/viewtopic.php?f=323&t=28957#p251619
      I try to add a tool to draw lines with the color of the active layer

      Probably the best solution is with the API SDK C + +, as indicated Thomthom.
      I found in SDK, this method

      OLE_COLOR ISkpLayer::Color [get] Returns the color associated with this layer.

      but it is too complicated, Ruby and English is already a lot of work for me πŸ˜†

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

        @dan rathbun said:

        I found [url][Plugin] List Layer Colors.rb[/url] (the topic title is a bit mis-spelled BTW.)
        It creates a CSV file of Layers and their Colors. But I don't see it setting colors.
        [Any further comments on the above plugin, I'll post in that topic.]
        EDIT [ Maybe I missed the plugin you were refering to? ]
        Nevermind.. I found it, it is a [Code] not a [Plugin].
        It's here: [Code] layer-color= v1.2...

        That's my code to 'set' a layer's color - it does NOT 'get' it - hence the layer.color**=** method.
        There are several ways of using it layer.color="red" etc. It is terribly clunky, only works for colors [not textures] and would be much better as a built-in method...
        There was talk of another layer.material method to get the layer's material [I recall it was AdamB's ?] but it hasn't arrived as far as I know... http://forums.sketchucation.com/viewtopic.php?f=180&t=25697&p=224534&hilit=layer#p224534

        TIG

        1 Reply Last reply Reply Quote 0
        • C Offline
          c.plassais
          last edited by

          Thank you Dan

          For your help and your time

          even a csv list of color layers, it's good for me

          1 Reply Last reply Reply Quote 0
          • C Offline
            c.plassais
            last edited by

            and thank also TIG

            for your plugin and your time πŸ‘
            I use only color, no materials
            layer.color one method is perfect for me
            Not to change the color layer, just retrieve and use

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

              This is the 'layer color' csv listing tool http://forums.sketchucation.com/viewtopic.php?p=11924#p11924
              It needs Pro though... πŸ˜•

              TIG

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                I found [Plugin] List Layer Colors.rb (the topic title is a bit mis-spelled BTW.)
                It creates a CSV file of Layers and their Colors. But I don't see it setting colors.
                [Any further comments on the above plugin, I'll post in that topic.]

                EDIT [ Maybe I missed the plugin you were refering to? ]
                Nevermind.. I found it, it is a [Code] not a [Plugin].
                It's here: [Code] layer-color= v1.2

                Jim's new indexes are great!!

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  Woops! Messed up the url... updated my previous post.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    c.plassais
                    last edited by

                    ListLayerColors is perfect for me
                    must be an object layer to export the layer color

                    Thx TIG

                    Is it possible to use it in my plugin ?

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

                      @c.plassais said:

                      ListLayerColors is perfect for me
                      must be an object layer to export the layer color
                      Thx TIG
                      Is it possible to use it in my plugin ?

                      A layer needs to have been used [i.e. have at least one face on it] to export as an OBJ and thereby get the color listed, BUT you could simply make a grouped triangular face and give that face a layer - iterate through the model.layers adding the grouped faces until all layers are all done, then run your version of the tool and you have ALL layer colors including unused ones listed in the csv...
                      You can keep a tally of the temporary face-groups as you make them and then erase them as the OBJ export completes...
                      Feel free to use my code as you like: a brief mention of my original code/ideas would be kind; if you are to use it commercially then a small donation would be even kinder [if so, PM me about that]... πŸ€“

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        c.plassais
                        last edited by

                        TIG,
                        I understand the tip to export all layers
                        My plugin is not commercial, freeware only on SCF and my French forum
                        A thousand times thank you πŸ‘

                        1 Reply Last reply Reply Quote 0
                        • C Offline
                          c.plassais
                          last edited by

                          Hy,
                          TIG plugin ListLayerColors after some modifications, can create new colors in the pallet with layer's colors

                          require 'sketchup.rb'
                          ###
                          class CreateLayerColors
                          def CreateLayerColors ;;get()
                            model=Sketchup.active_model
                            entities = model.active_entities    
                            materials=model.materials
                            layers=model.layers
                            
                            if model.rendering_options["DisplayColorByLayer"]==false
                              model.rendering_options["DisplayColorByLayer"]=true
                          	already_on=false
                            else
                              already_on=true
                            end#if
                            # create temporary entities for exporting layers
                            vecteur = Geom;;Vector3d.new 0,0,1
                            centre = Geom;;Point3d.new 0,0,0
                            group_temp=entities.add_group()
                            entities = group_temp.entities
                            x =0
                            layers.each {|layer|
                            model.active_layer = layer
                            centre = [centre[0], centre[1], centre[2] + x]
                            edges = entities.add_circle centre, vecteur, 0.01
                            cercle = entities.add_face(edges)
                            x= x + 0.01
                            }
                             
                            model.save "temp"
                            mpath = Sketchup.find_support_file "temp", "Plugins/"
                            model.export(mpath +".obj",false)
                            mtl=mpath+".mtl"
                            text=IO.readlines(mtl)
                           0.upto(text.length-1) do |i|
                            if text[i]=~/^newmtl */
                              name=text[i].slice(7..-2)### layer name only
                              rgbR=((text[i+2].slice(3..11).to_f)*255).to_i.to_s### color rgb values	
                              rgbG=((text[i+2].slice(12..20).to_f)*255).to_i.to_s### color rgb values	
                              rgbB=((text[i+2].slice(21..29).to_f)*255).to_i.to_s### color rgb values
                              
                            	couleur_calque = Sketchup;;Color.new(rgbR.to_i, rgbG.to_i, rgbB.to_i)
                                  unless materials[name]
                          	    new_matiere = materials.add name
                          	    new_matiere.color = couleur_calque
                          	    new_matiere = new_matiere.name
                          	else
                          	    materials[name].color = couleur_calque
                          	end
                            end#if
                           end#upto
                          
                            File.delete(mpath+".obj")
                            File.delete(mtl)
                            File.delete(mpath)
                            group_temp.erase!
                            ###
                            model.rendering_options["DisplayColorByLayer"]=false if already_on==false
                            ###
                          end#def
                          end#class
                          ### menu
                          # add menu items
                          if(not file_loaded?("CreateLayerColors.rb"))
                            UI.menu("Plugins").add_item("Create Layer Colors"){CreateLayerColors;;get}
                          end#if
                          file_loaded("CreateLayerColors.rb")
                          ###
                          

                          CreateColorLayer

                          Christophe

                          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