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

    Programming in C, C++ for Mac and Windows?

    Scheduled Pinned Locked Moved Developers' Forum
    51 Posts 9 Posters 8.2k Views 9 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.
    • thomthomT Offline
      thomthom
      last edited by

      @unknownuser said:

      link updated in my original post to http://github.com/TBD/OpenSUP/tree/master/SUExt/

      cheers.
      Can one download from one branch? I only managed to find a download for the whole lot. (not that it was a big download - just curious)
      Also - is that extension one that integrates with SU such that you can access SU objects from C?

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

      1 Reply Last reply Reply Quote 0
      • tbdT Offline
        tbd
        last edited by

        @thomthom said:

        Can one download from one branch? I only managed to find a download for the whole lot. (not that it was a big download - just curious)

        nope. only if I create the .zip myself and add them to Downloads tabs.

        @thomthom said:

        is that extension one that integrates with SU such that you can access SU objects from C?

        is that extension that only extends Ruby with C code (so the title is a bit misleading for now). you can access SU objects via normal Ruby commands (rb_ functions)

        SketchUp Ruby Consultant | Podium 1.x developer
        http://plugins.ro

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

          Would the code be simpler if it didn't integrate Ruby?
          If it only passed data back and forth? Or is it required to integrate in order to share the various data types?

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

          1 Reply Last reply Reply Quote 0
          • tbdT Offline
            tbd
            last edited by

            @thomthom said:

            Would the code be simpler if it didn't integrate Ruby?

            you dont integrate Ruby, just the needed headers for Ruby types. as you can see the output .so is small, 10kb, without any size optimizations.

            @thomthom said:

            If it only passed data back and forth? Or is it required to integrate in order to share the various data types?

            you only pass data back and forth.

            SketchUp Ruby Consultant | Podium 1.x developer
            http://plugins.ro

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

              And what about Classes defined by SketchUp? How does one handle them?

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

              1 Reply Last reply Reply Quote 0
              • tbdT Offline
                tbd
                last edited by

                you can use rb_funcallX (see Ruby Interpretor Interface) to call methods from the classes or you can use array/hashes to pass data

                SketchUp Ruby Consultant | Podium 1.x developer
                http://plugins.ro

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

                  Say I got a collection of Point3d, Vector3d. Would it be best to convert those to arrays of basic numbers in Ruby and passing onto C? Or would it really not matter?

                  
                  static VALUE test(VALUE vector)
                  {
                    VALUE arr;
                    arr = rb_funcall(vector, rb_intern("to_a"), 0)
                  }
                  
                  

                  This would leave me with arr being an Ruby Array representing the vector, right?
                  I see there are rb_each and rb_iterate - should one use ruby iterators to loop through Ruby Arrays in C? Or can one use regular C loops?

                  Are there further reading than this page: http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html

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

                  1 Reply Last reply Reply Quote 0
                  • tbdT Offline
                    tbd
                    last edited by

                    @thomthom said:

                    This would leave me with arr being an Ruby Array representing the vector, right?

                    right

                    @thomthom said:

                    I see there are rb_each and rb_iterate - should one use ruby iterators to loop through Ruby Arrays in C? Or can one use regular C loops?

                    definitely rb_ functions as you are manipulating an array of pointers (VALUE objects)

                    SketchUp Ruby Consultant | Podium 1.x developer
                    http://plugins.ro

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

                      I am confused again now. I got Pellets. And I did what the article said about generating a makefile. But I'm confused to how I compile it.
                      From what I understand, make is a UNIX command?

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

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

                        Ok, getting close I think, - from the Pelles C Project options I added C:\Ruby\lib\ruby\1.8\i386-mswin32 to the includes path.

                        But now I get:
                        Building helloworld.obj. C:\Ruby\lib\ruby\1.8\i386-mswin32\config.h(2): fatal error #1014: #error: MSC version unmatch. *** Error code: 1 *** Done.

                        ❓

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

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

                          Pelles crashed on me - and I swear I heard Homer Simpson's "doh!" as it crashed... 😲 😆


                          error.png

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

                          1 Reply Last reply Reply Quote 0
                          • tbdT Offline
                            tbd
                            last edited by

                            just double click on suext.ppj and it will open in PellesC IDE and then you can Project | Build and you will get a suext.so ready to use

                            SketchUp Ruby Consultant | Podium 1.x developer
                            http://plugins.ro

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

                              @unknownuser said:

                              just double click on suext.ppj and it will open in PellesC IDE and then you can Project | Build and you will get a suext.so ready to use

                              Tried that - but it complained about the project being in the wrong location. Thereafter I got the error I posted in previous post.


                              location.png

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

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

                                When I google the error - all I find is people suggesting that one remove
                                #if _MSC_VER != 1200 #error MSC version unmatch #endif
                                from config.h.

                                I take it that you found a way around that?

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

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

                                  When I open the .ppj files in a text editor I see some minor differences.
                                  What kind of project template do you use?

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

                                  1 Reply Last reply Reply Quote 0
                                  • tbdT Offline
                                    tbd
                                    last edited by

                                    added suext6.ppj in SUExt dir on github. it should work now. I use PellesC 5 and something was changed in 6 that made that error.

                                    SketchUp Ruby Consultant | Podium 1.x developer
                                    http://plugins.ro

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

                                      Thanks to TBD I manage to make my first Hello World SketchUp Ruby Extension running! 😄
                                      The man deserves a big cookie!


                                      helloworld.png

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

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

                                        Hey Congrats Thom! So when are you moving out of Architecture and into Programmer/Developper full time? 😄

                                        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

                                          when it pays more..? 😄

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

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

                                            Say that I have a module Foo defined in my ruby script containing a method bar.

                                            How can I reference Foo in C so I can for instance call bar?
                                            symbol = rb_intern("bar"); rb_funcall(??? , symbol, 0);

                                            Would I use VALUE rb_define_module(const char *name) ?

                                            module = rb_define_module("Foo"); symbol = rb_intern("bar"); rb_funcall(module , symbol, 0);
                                            ❓

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

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

                                            Advertisement