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

    Example of Compiled Extension with SWIG and CMake

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 6 Posters 3.5k Views 6 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.
    • M Offline
      macumber
      last edited by

      Sounds like there was enough interest in compiled extensions at Basecamp that I whipped up this small example. We have found the recipe of CMake + SWIG to be very useful in making cross-platform extensions (or any C++ project). I have only tested this example on Windows, I may have to update it for Mac, let me know if you have any problems with it. A great idea floated around at Basecamp was to wrap the C++ SDK for file access with Ruby, that way developers could write Ruby scripts to access skp files from within SketchUp or at the command line. I would suggest CMake + SWIG as a route to do that. As a final note, if you really don't like the generated interfaces you can always wrap the generated wrapper code from SWIG with your own pure Ruby to your heart's content.

      The attached file is really a zip file, rename the file extension to .zip and extract.

      Hope this helps,
      Dan


      Rename to .zip and extract

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

        This sounds interesting.

        @unknownuser said:

        A great idea floated around at Basecamp was to wrap the C++ SDK for file access with Ruby, that way developers could write Ruby scripts to access skp files from within SketchUp or at the command line.

        That is very interesting!

        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

          CMAKE Wikipedia

          SWIG

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • M Offline
            macumber
            last edited by

            I started a project to wrap the SDK for Ruby at:

            Link Preview Image
            Google Code Archive - Long-term storage for Google Code Project Hosting.

            favicon

            (code.google.com)

            I am just getting started now and focusing only on Windows but hopefully this could be extended pretty quickly. Let me know if you are interested in helping/using.

            Dan

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

              Hey Dan, it was great to meet you at Basecamp. I do think this is an interesting project. I'm of no use in helping out with project, but I am interested in using it πŸ˜„

              Chris

              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

                I'm also interested in this project - though atm mostly of curiosity without any exact specific usage, yes.

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

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

                  @thomthom said:

                  I'm also interested in this project - though atm mostly of curiosity without any exact specific usage, yes.

                  I think you could, for example, write a .skp converter using ruby that worked on a .skp file instead of needing to run in SketchUp.

                  Batch conversions, thumbnail extraction, add/remove/modify geometry, explode, etc.

                  Hi

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

                    I imagine AdamB said at some point he'd managed to access setter methods for layers and materials via the SDK. Even get layer materials. Now that would be useful!

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

                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      macumber
                      last edited by

                      After working with the SDK for a little while I don't think it can be wrapped as quickly as I first thought. I have to get back to work on my real tasks so the SDK wrap project will have to wait for a while. But I did make another example using SWIG with directors to show how to pass Ruby objects into C++ code. We are looking into this to implement Ruby observers for events that happen in our own C++ code.

                      Hope this helps,
                      Dan


                      Rename to .zip and extract

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

                        (you can upload .zip files here)

                        Hi

                        1 Reply Last reply Reply Quote 0
                        • K Offline
                          KamoStomp
                          last edited by

                          Hi, has anyone tried this on Mac OSX (10.6)?

                          For SWIG I did the standard: ./configure, make, make install.
                          but when i try to CMake your examples above i get this:

                          swig error : Unrecognized option -initname
                          swig error : Unrecognized option Example

                          for -initname "Example" in CMakeList.txt

                          also if i remove that it doesn't get better.

                          I tried SWIG versions 2.0.0 and 1.3.40 with no luck,
                          and I have ruby 1.8.7 (so should be no problems here...).

                          Please help,
                          Thank you.

                          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