sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Code Profiling

    Scheduled Pinned Locked Moved Developers' Forum
    28 Posts 8 Posters 4.3k Views 8 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.
    • AdamBA Offline
      AdamB
      last edited by

      @unknownuser said:

      Embedding C code is practical, and not that difficult. The examples in the Ruby Pragmatic Programmer (pickaxe) book work great. The only downside is the hassle with distributing the binaries and making sure the install process is idiot proof.

      Todd, I think thats a bit misleading. Sure the fundamentals of calling some C API to interface with vanilla Ruby is trivial. However, there are many many problems dealing with SketchUp's underlying C++ based object model, which interfaces to transient Ruby representations which your C Extension then manipulates. GC issues are a nightmare.

      So much so, I've finally given up on using the Ruby<->C interfaces for Extensions. The next version of LightUp is talking directly to the underlying Sketchup object model and is completely stable for the largest of models, uses miles less memory and is around 10x faster.

      Ruby is great for running up a quick GUI, "power short cut" etc but it is just waaay too slow to do any kind of heavy lifting.

      In some sense its no surprise. You can't have your cake and eat it. Simple as that.

      Developer of LightUp Click for website

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

        @adamb said:

        The next version of LightUp is talking directly to the underlying Sketchup object model

        You can get access to the model without going via Ruby?

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

        1 Reply Last reply Reply Quote 0
        • PixeroP Offline
          Pixero
          last edited by

          @adamb said:

          The next version of LightUp is talking directly to the underlying Sketchup object model and is completely stable for the largest of models, uses miles less memory and is around 10x faster.

          Looking forward to it...

          1 Reply Last reply Reply Quote 0
          • W Offline
            Whaat
            last edited by

            @adamb said:

            So much so, I've finally given up on using the Ruby<->C interfaces for Extensions. The next version of LightUp is talking directly to the underlying Sketchup object model and is completely stable for the largest of models, uses miles less memory and is around 10x faster.

            How exactly do you communicate directly with the SketchUp model?

            SketchUp Plugins for Professionals

            1 Reply Last reply Reply Quote 0
            • AdamBA Offline
              AdamB
              last edited by

              @whaat said:

              @adamb said:

              So much so, I've finally given up on using the Ruby<->C interfaces for Extensions. The next version of LightUp is talking directly to the underlying Sketchup object model and is completely stable for the largest of models, uses miles less memory and is around 10x faster.

              How exactly do you communicate directly with the SketchUp model?

              Sorry, I mean using the SketchUp C++ SDK for directly walking their structures rather than having some C that uses rb_funcall() Ruby calls to get a Ruby object that is created by SketchUp as a proxy of the "real" underlying C++ object - and therein is (I believe) the source of many problems when writing C-based Extensions.

              I've avoided it (the C++ SDK) for many years because I detest COM with a burning passion - I dislike COM so much that I find if I meet anyone who has anything positive to say about COM, I immediately dismiss them as idiots.

              And yes, I know my COM-ism is extreme. ๐Ÿ˜„

              Developer of LightUp Click for website

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

                I's always thought that the SketchUp C++ SDK was only allowing other application to read/write .skp files... Never realize it allowed direct access to working model. ...or maybe I've been look at the wrong place...?
                Only thing I find this this: http://code.google.com/intl/nb/apis/sketchup/docs/downloadsdksubmit.html
                Which is refered to as beta and out of date...

                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's always thought that the SketchUp C++ SDK was only allowing other application to read/write .skp files.

                  Me too, but maybe you can save the file, run your code, and reload the file? Does it work like that?

                  Hi

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

                    @unknownuser said:

                    Which is refered to as beta and out of date...

                    yeah, that's the one. there is also the Sketchup.active_model.skpdoc that gives you a bridge to SDK world - it gives back the pointer to the Sketchup document interface. funny thing that it was available in SU5, removed in SU6 (least in 6.0.515 it was not available) and now is back

                    the problem is with not supported thing that worries me - what if it will be removed, again, from next version ?

                    but, as Adam said, it is a big boost in speed and reliability and I think you can create a fallback version in Ruby, just in case ๐Ÿ˜‰

                    also there are a lot more tools for profiling in C++ world than in Ruby.

                    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:

                      yeah, that's the one. there is also the Sketchup.active_model.skpdoc that gives you a bridge to SDK world - it gives back the pointer to the Sketchup document interface.

                      That let you use the SDK on a live model, and not have to save the model to file and have the reader read it?

                      I always thought the SDK would only read s.kp files - had no idea it could tap into a running model...

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

                      1 Reply Last reply Reply Quote 0
                      • W Offline
                        Whaat
                        last edited by

                        Would anyone be willing to provide a code snippet showing a trivial example of using C in combination with Ruby? I am still feeling kind of lost about how I could pass information back and forth between the two languages.

                        SketchUp Plugins for Professionals

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

                          Whaat: a ruby c extension or a SU SDK one ?

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

                          1 Reply Last reply Reply Quote 0
                          • W Offline
                            Whaat
                            last edited by

                            @unknownuser said:

                            Whaat: a ruby c extension or a SU SDK one ?

                            Whatever is the simplest.... ๐Ÿ˜„ Even a 'hello world' example would be a good start.

                            SketchUp Plugins for Professionals

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

                              the simplest is ruby extension and I showed you a link some time ago. didn't worked ?

                              to use SU SDK for a simple .skp page parser I made a small 8kb exe that needed 8.92 MB of .DLL files ๐Ÿ˜ฎ

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

                              1 Reply Last reply Reply Quote 0
                              • W Offline
                                Whaat
                                last edited by

                                @unknownuser said:

                                the simplest is ruby extension and I showed you a link some time ago. didn't worked ?

                                Heh...I never tried it because I got scared of the makefile stuff...

                                What interests me much more is Rubyinline. Look at the comment posted just below the blog post at the link you are referring to.

                                Do you think Rubyinline can be used with SketchUp? I see that it requires rubygems so this (and Rubyinline) would have to be distributed with the plugin as I see it.

                                SketchUp Plugins for Professionals

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

                                  @whaat said:

                                  Do you think Rubyinline can be used with SketchUp? I see that it requires rubygems so this (and Rubyinline) would have to be distributed with the plugin as I see it.

                                  no. RubyInline is just a shortcut for building extensions - you still need to have a compiler on that machine to make it work.

                                  I also had problems make it run on my Windows machine as it doesn't like paths with spaces (v 3.6.3) and also it uses deprecated options for VC.

                                  get started with that link, makefiles are peanuts compared with COM and finding problems in RubyInline ๐Ÿ˜‰

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

                                  1 Reply Last reply Reply Quote 0
                                  • W Offline
                                    Whaat
                                    last edited by

                                    @unknownuser said:

                                    get started with that link, makefiles are peanuts compared with COM and finding problems in RubyInline ๐Ÿ˜‰

                                    Thanks! I will definitely try this at some point.

                                    So, other than having full Ruby installed and a development environment such as PellesC, is there anything that needs to be done for this to work?

                                    I would still love to see an actual SketchUp related example where you pass values from Ruby to the C extension and then back again.

                                    SketchUp Plugins for Professionals

                                    1 Reply Last reply Reply Quote 0
                                    • T Offline
                                      todd burch
                                      last edited by

                                      If you ever saw SimuTerra, that was an an app that was made into a C extension from Ruby. As far as I am aware, it suffered from none of the issues mentioned by Adam. It was blazingly fast to manipulate terrains with SimuTerra. (sp?)

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

                                        Whaat: I created a simple extension that creates a class SUExt with method add which adds 1 to the input at http://bitbucket.org/tbd/suext/src/

                                        there are no error checking and it is a minimal example that compiles with PellesC (free C compiler) and it can be used in SketchUp

                                        have fun

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

                                        1 Reply Last reply Reply Quote 0
                                        • W Offline
                                          Whaat
                                          last edited by

                                          @unknownuser said:

                                          Whaat: I created a simple extension that creates a class SUExt with method add which adds 1 to the input at http://bitbucket.org/tbd/suext/src/

                                          there are no error checking and it is a minimal example that compiles with PellesC (free C compiler) and it can be used in SketchUp

                                          have fun

                                          Thanks so much for taking the time to do this!

                                          SketchUp Plugins for Professionals

                                          1 Reply Last reply Reply Quote 0
                                          • T Offline
                                            tomasz
                                            last edited by

                                            @whaat said:

                                            Thanks so much for taking the time to do this!

                                            +1!

                                            Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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

                                            Advertisement