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

    [Request] Create an Edge or Surface using a Predefined Color

    Scheduled Pinned Locked Moved Plugins
    9 Posts 4 Posters 1.8k 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.
    • JClementsJ Offline
      JClements
      last edited by

      Wondering if this could be done with a script.

      Rather than drawing edges or creating surfaces and then selecting a color (material) to apply, what about being about doing the converse, define the material/color for edges and surfaces before using the drawing tools? Then when geometry is drawn, those material "profiles" are applied automatically.

      I think this would come in handy especially when adding geometry to an already densely populated model as it would eliminate zooming in to make selections in order to apply a material. Plus, for some users, it might be more intuitive as it would be similar to what 2D illustrative applications use.

      Perhaps the UI could be dialog with matrix 32 or 64 predefined swatches to pick from with a custom color button.

      John | Illustrator | Beaverton, Oregon

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

        I imagine something like that could be done, although it would likely require quite a lot of work, as it isnt possible to alter the default SU tools using the API.

        It should be fairly simple to make a line tool that draws in a predefined colour, though, by just adding a material applying element to the line.rb example script. I could have a go if that sounds like roughly the sort of thing you were thinking of...

        http://remusrendering.wordpress.com/

        1 Reply Last reply Reply Quote 0
        • JClementsJ Offline
          JClements
          last edited by

          Hi Remus,

          If you think you can alter the line.rb sample script that would be nice.

          If it works, eventually would it be possible to have a two-icon toolbar; one to change the color and the other to return back to the default color?

          John

          John | Illustrator | Beaverton, Oregon

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

            i'll add it to the list of things to do πŸ‘

            http://remusrendering.wordpress.com/

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

              I tried my hand at it, and came up with a version using observers. I have very little experience with observers, but I am wanting to find out if and when they are useful. Perhaps this is an instance of where they could come in handy.

              This script is very simple, it just watches the model and anytime a new face is made, it colors the front face with the current color. Select the code and save it into your plugins folder as any name you wich, just end it with .rb

              I don't want to upload my own actual rb file because this is not a plugin that is ready for primetime yet. So I don't want to make it too easy for people who don't know what they are getting into to install this one yet πŸ˜„ But I'm sure you can handle it John, it is your idea after all.

              One known quirk is that it only work on the first opened model in SU. If you open a new model, it will stop working. I'll try to get that worked out. I need to get the OnNewModel observer working.

              class MyEntitiesObserver < Sketchup;;EntitiesObserver
                def onElementAdded(entities, entity)
                  current_mat = Sketchup.active_model.materials.current
                  entity.material = current_mat if entity.is_a? Sketchup;;Face
                end
              end
              
              Sketchup.active_model.entities.add_observer(MyEntitiesObserver.new)
              

              Try that, see what you think of the functionality. It is interesting.

              Chris

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

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

                If you do want to get it working in a model that was opened after the first opened model (ie open the first model, then open a second new model and the script stops working). To get it to start working again, just opent he ruby console and enter that last line of code back into the console and it will start again.

                Sketchup.active_model.entities.add_observer(MyEntitiesObserver.new)
                

                Chris

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

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

                  Didnt tihnk of using observers, a cunning plan indeed chris πŸ‘

                  Is material.current the material selected in the materials browser?

                  http://remusrendering.wordpress.com/

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

                    class MyAppObserver < Sketchup;;AppObserver
                      def OnNewModel(model)
                        model.entities.add_observer(MyEntitiesObserver.new)
                      end
                    end
                    
                    

                    Sketchup.add_observer(MyAppObserver.new)

                    Seems like it should work...

                    TIG

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

                      Thanks TIG, I'll try that when I get a few monets to play. I had played with the OnNewModel observer, but I could not get it to fire. I probably was doing something wronge. I mostly just copied and pasted the example from the Docs. Thanks!

                      Chris

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

                      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