• Login
sketchucation logo sketchucation
  • Login
โ„น๏ธ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

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

Scheduled Pinned Locked Moved Plugins
9 Posts 4 Posters 1.8k Views
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.
  • J Offline
    JClements
    last edited by 12 Aug 2009, 01:13

    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 18 Aug 2009, 13:15

      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
      • J Offline
        JClements
        last edited by 18 Aug 2009, 16:01

        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 18 Aug 2009, 22:10

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

          http://remusrendering.wordpress.com/

          1 Reply Last reply Reply Quote 0
          • C Offline
            Chris Fullmer
            last edited by 18 Aug 2009, 23:03

            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
            • C Offline
              Chris Fullmer
              last edited by 18 Aug 2009, 23:09

              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 19 Aug 2009, 07:32

                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
                • T Offline
                  TIG Moderator
                  last edited by 19 Aug 2009, 10:45

                  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
                  • C Offline
                    Chris Fullmer
                    last edited by 19 Aug 2009, 14:29

                    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
                    1 / 1
                    • First post
                      1/9
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement