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!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    Painting Plugin Help

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 422 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.
    • renderizaR Offline
      renderiza
      last edited by

      Hi,

      I want to create a plugin that will feel like I am painting. Have couple ideas but want to start by copying a 2D or 3D geometry and by pressing & holding a key it will keep pasting the geometry so that if I move the mouse it will feel like a Photoshop brush.

      Javascript Code that will be sended to Ruby with other code using params;

      if (keyIsDown[SPACE]) {		
      paint = 1  			
      }
      if (keyIsDown[SPACE] == false) {
      paint = 0 ;
      }
      

      Here is Ruby Script ;

      if params['paint'].to_i == 1  ;	  
        Sketchup.send_action(CMD_PASTE) ; 
      end
      

      The thing is that when I click Spacebar the object paste itself but problem is I need to click with mouse to put it down and this disrupt the flow of things. I want to Press spacebar and object automatically paste itself down without clicking mouse.

      Any Suggestions?

      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

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

        Yeah, you need to specify in your code where to put the instance. You would do that with a pickhelper. Is this plugin written inside a SketchUp Tool class? You will need to do it as a tool to track the cursor position, so you can then insert the instance at the cursor position.

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

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          The description is a bit lacking. Not 100% sure what you're code is doing, but when you say "I need to click with mouse to put it down and this disrupt the flow of things." I then take it you used Model.place_component? In order to just insert a component you use entities.add_instance.

          ... ah ... you trigger SketchUp's Copy and Paste commands. What you probably want to do instead is use a variable to store the reference to the instance or definition you want to "copy" - then you can use entities.add_instance.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

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

            Didier Bur has done several Component Spray plugins. Look at what he has done.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • renderizaR Offline
              renderiza
              last edited by

              Hi, thanks for the replays

              Chris Fullmer this might be the answer but I need to study how to apply this little more. If I am not mistaken this will get the coordinates of the object that is referenced under the mouse.

              So somehow I need to make a variable that gets the values of does coordinates so I can do what Thomthom said... entities.add_instance

              Dan Rathbun the Compo Spray has the same issue I am having and that is that in other to keep dropping coponent one has to keep clicking the left mouse click.

              It would be ideal to click & hold and components constantly keep dropping.

              I already have web dialog updating 15 frame a second all I need is a way to get rid of the multiple clicks and I am golden.

              Note: Still lack a lot of knowledge in creating geometry with code but little by little I will learn...thank you guys really appreciate it.

              [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

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

                Here is a really quick tool that shows how to "paint" with components. I forget how the "flags" work, but it looks like you get a flag of 1 if the mouse button is down. Isn't there a list somewhere of the flags?

                I wrote this quickly as a test code. I run my code snippets like this in a multi-line code editor in SU (Like Jims, or Alex Schreyers, or Aerilius).

                You must have a component selected before running the snippet. Then just hold the left mouse button down and move the mouse and it will paint the selected instance.

                class Cltool
                
                
                def activate
                @@sel = Sketchup.active_model.selection[0]
                @@ents = Sketchup.active_model.active_entities
                end
                
                def onMouseMove(flags,x,y,view)
                  ip1 = view.inputpoint x,y
                  point = ip1.position
                  if flags == 1
                    add_object(point)
                  end
                end
                
                def add_object(point)
                t = Geom;;Transformation.new(point)
                @@ents.add_instance(@@sel.definition,t)
                end
                
                
                end
                Sketchup.active_model.select_tool Cltool.new
                

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

                1 Reply Last reply Reply Quote 0
                • renderizaR Offline
                  renderiza
                  last edited by

                  Christ Fullmer you are a genius!!!

                  This transform SketchUp into the best painting application in my opinion...I will see If I can expand this & add new features to make it even better.

                  I am so excited!...again thanks!

                  [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                  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