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

    How do you make plug-ins for sketchup

    Scheduled Pinned Locked Moved Developers' Forum
    103 Posts 25 Posters 9.0k Views 25 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.
    • R Offline
      RickW
      last edited by

      My MacBook has Xcode or something like that (I'm not a "Mac person" - I just got one for self-preservation for dual-platform SU ruby development 😄 ). It's color coded and has auto-completion capabilities as you type.

      RickW
      [www.smustard.com](http://www.smustard.com)

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

        @rickw said:

        My MacBook has Xcode or something like that

        You are a lucky guy RickW, I can't find Xcode on my mac (perhaps I got to check my cd install to find xcode ?)

        I checked out this link and I'm not sure it's free.
        BTW, thanks for the info RickW

        Regards

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

          This is some good info on Mac code editors. I'll include it in whatever little tutorial I get thrown together.

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

          1 Reply Last reply Reply Quote 0
          • B Offline
            BTM
            last edited by

            I have Xcode too, downloaded smultron anyways, they both seem good, Xcode a little more complicated, but does have menus for picking the exact thing you want to make ( like ruby extentions), but I don't know which one's better. 😐
            ...Anyone out there have experience with these sorts of things?

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

              Hey not too bad! Just keep that up and you're well on your way. Once you get the standard flow control methods down (which you have, the if/else/end, until/end, array.each do/end) your set. Then its time to dig into the sketchup API to see what methods/classes/modules that SketchUp has added to Ruby.

              Chris

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

              1 Reply Last reply Reply Quote 0
              • B Offline
                BTM
                last edited by

                Nevermind, Xcode's my pick. I made my first ruby code too (not for sketchup)

                keycode = false
                puts 'INPUT CODE'
                code = gets.chomp
                puts 'CODE RECIEVED'
                while (not keycode)
                	puts 'INPUT CODE TO UNLOCK'
                	if gets.chomp == code
                		keycode = true
                		puts 'ACCESS GRANTED'
                	else
                		puts 'ACCESS DENIED'
                	end
                end
                

                It's a good thing I've used sketchyphysics before, or I would have no idea what I was doing.

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by

                  @unknownuser said:

                  .also, how do you add global variables throughout the script? Is it still setVar("foo",1), getVar("foo"), and getSetVar("foo",0)?

                  These are not part of the Ruby API - they must be part of the SketchyPhysics API (to confuse things even further.)

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    BTM
                    last edited by

                    Just looked it up in that pine-something-or-other tutorial. So it's if you put a @ in front of a variable that makes it global?

                    1 Reply Last reply Reply Quote 0
                    • B Offline
                      BTM
                      last edited by

                      I've been taking a look at the sketchup API, and am currently a bit intimidated. 😲
                      I never realized how many different methods, classes and modules there would be! Up until now, everything I've done has been very simple, but I don't even understand half of what these things mean, and it would take me forever to find anything specific!
                      ...also, how do you add global variables throughout the script? Is it still setVar("foo",1), getVar("foo"), and getSetVar("foo",0), like in sketchyphysics?

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

                        SketchUp has (at least)

                        variable - local variable
                        @variable - Instance variable
                        @@variable - Class Variable
                        $variable - Global Variable

                        local variables are available only within the method in which they are defined.
                        Instance Variables are available through the entire class instance.
                        Class Variables are available for all instances of a class.
                        Global variables are available for all classes. They can be accessed from any ruby script. If you make one called $my_special_global_variable and someone else makes one with the same name, there will be a conflict.

                        I know that doesn't explain instance and class vairables very well. Sorry, I'll have a go at it.

                        In SketchUp, when you make a tool, you make it as a class. So every time the tool gets activated, it creates a new instance of the class. Instance variables are only available within that instance of the class. When the tool is activated again, those old instance variables are not available to the new instance. But Class variables would be available from one activation of the tool (instance of the class) to the next. So lets say that you have a tool that draws a circle and the user can input the size and segments of the circle. If you used an instance variable to hold the user input size and segment count, then the tool keep their values only while it was active. Once they de-activate the tool, then re-activate it, it creates a new instance of the tool, and the instnace variables are lost, so it would return back to whatever defaults the script provides. But if you use Class variables, then those variables stay active from one activation of the tool to the next. They only get reset once SketchUp is closed down and restarted.

                        Thats it to the best of my understanding. I only really understand this within a SketchUp context. So I'm sure there;s more to it than just that. But that is a start on local, instance, class, and global variables.

                        There are also constants, symbols, and maybe more? THey are types of variables I think.

                        Chris

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

                        1 Reply Last reply Reply Quote 0
                        • L Offline
                          l.frisken
                          last edited by

                          I've started trying to learn how to use ruby but I'm having a lot of trouble getting input points to work. U'm what would be the simplest way for me to make a simple tool that tells me the coordinates in 3 dimensions of whatever I'm clicking on?

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

                            That seems to be a popular thing to want to do, but in my mind, its a pretty involved task. In order to get the onlinck function to work, it has to be implemented from within a tool. Have you already got a tool class working correctly?

                            Chris

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

                            1 Reply Last reply Reply Quote 0
                            • L Offline
                              l.frisken
                              last edited by

                              within a tool? (hmm I need to study more! 😒) well I was wanting to make a line drawing ruby that involved two clicks like the example file. But from just trying to examine the file I realized that it was quiet a complicated process, much more than just drawing a line using ruby! I wish that google could have made this function a little simpler, seeing as like 80% of the plugins I have used use something like this. I guess I need to start on some other more simple things. I have read a book on O O programing before but things are a little rusty now! (classes, methods... arrgghh! 😕 😄 )

                              1 Reply Last reply Reply Quote 0
                              • B Offline
                                BTM
                                last edited by

                                Ahh, thanks for the advice on variables Chris! %(#808080)[(and thanks for all the other helpful advice and tips you've posted in this descussion 😆 )]

                                1 Reply Last reply Reply Quote 0
                                • B Offline
                                  BTM
                                  last edited by

                                  I've learned some of the sketchup ruby API, and understand why most codes work how they do, but my problem is making a code that works. I know how something works when I see it, but can't write one myself. 😆 It's like being able to hear or read, but not speak or write 😕

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

                                    I think some of the "easiest" scripts to start writing are ones that begin by iterating through the model and doing something to the geometry. Here's a few variations of some basic examples. Then tweak them and expand on them to make them more and more involved.

                                    pushpull all faces in the model
                                    pushpull selected faces only
                                    select all faces that have a certain surface area.
                                    select all faces that have a surface area within a specified tolerance.
                                    Delete all lines that are not drawn on an axis.
                                    Delete all faces in the model or all faces from a selection, leaving just edges

                                    Anyhow, thats a small start. Those should all be fairly straightforward.

                                    Chris

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

                                    1 Reply Last reply Reply Quote 0
                                    • free agentF Offline
                                      free agent
                                      last edited by

                                      wow im finally interested in learning ruby 😄 it would be awesome to not have to request rubies, just make em urself... and share of course.

                                      http:i167.photobucket.comalbumsu143FreeAgent84bug.gif

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

                                        youve got me tempted now, chris. I'll post my efforts this evening 👍

                                        http://remusrendering.wordpress.com/

                                        1 Reply Last reply Reply Quote 0
                                        • C Offline
                                          Click Draw
                                          last edited by

                                          Is Ruby on Rails the same as Ruby?

                                          Thanks,
                                          Jeff

                                          Have I mentioned how much of a laugh I get out of some of the Signatures on here!

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

                                            Rails is like an extension of regular ruby. So Ruby is the main language, and rails is a "ruby gem". Its still the same language, but it adds more features and functionality especially developed for web developers (I think).

                                            Chris

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

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 3 / 6
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement