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

    Webdialogs for SketchUp ......RIP!

    Scheduled Pinned Locked Moved Developers' Forum
    55 Posts 15 Posters 3.2k Views 15 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.
    • icehuliI Offline
      icehuli
      last edited by

      @jolran said:

      Oh, I wish I'd taken up on C or C++...

      Anyway, I gather Windows only ?

      Both plattforms ought to be provided to keep people happy.

      I think the same method can be applied for c++ gui, e.g. qt, as well. A new thread need to start for the GUI to avoid it being frozen while ruby scripts are being evaluated.

      1 Reply Last reply Reply Quote 0
      • jolranJ Offline
        jolran
        last edited by

        @unknownuser said:

        I think the same method can be applied for c++ gui, e.g. qt, as well. A new thread need to start for the GUI to avoid it being frozen while ruby scripts are being evaluated.

        Great! It's just the small detail of learning c++ then ๐Ÿ˜„

        Seriously though, I was under the impression these kinds of 2 way Communication was not possible outside webdialog-World.

        I would really like to know more.

        1 Reply Last reply Reply Quote 0
        • jolranJ Offline
          jolran
          last edited by

          JSmaker is not an option I think.

          I use JsPlumb. It's depended of Jquery UI, which is a bit sketchy when dealing with CSS3 transforms. It does not recognize them ๐Ÿ˜ฒ So zooming is very fun to deal with ๐Ÿ˜‰
          Anyway one have to write nodecreation functions oneself and where endpoints should be added. Jsplumb is only a view technology. Does not do any type of layout (yet).

          I've been looking into D3, and it's an awsome framework! But also very low-level so it would take ages to come up with something that's even close to where Jsplumb is now.
          But still very interesting...

          edit: Removed some off topic ramblings..

          1 Reply Last reply Reply Quote 0
          • jolranJ Offline
            jolran
            last edited by

            @unknownuser said:

            A new thread need to start for the GUI to avoid it being frozen while ruby scripts are being evaluated

            So, the dialog does not freeze during Ruby operations ?

            How about window modal behavior. I mean how do one activate a dialog through Ruby plugin, must the C# program or whatever being used already be up and running?
            I assume you already have tried this in practice.

            Sorry bout the noob questions ๐Ÿ˜ณ

            1 Reply Last reply Reply Quote 0
            • icehuliI Offline
              icehuli
              last edited by

              @jolran said:

              @unknownuser said:

              A new thread need to start for the GUI to avoid it being frozen while ruby scripts are being evaluated

              So, the dialog does not freeze during Ruby operations ?

              How about window modal behavior. I mean how do one activate a dialog through Ruby plugin, must the C# program or whatever being used already be up and running?
              I assume you already have tried this in practice.

              Sorry bout the noob questions ๐Ÿ˜ณ

              Yes, one can activate a dialog through ruby plugin. The c# thread is started within the plugin. I have tried something already. check out https://github.com/icehuli/suWpfExt.
              Although it is a alpha version, it should give you a hint how to do the trick. It currently uses swig, which is not necessary. I am working on a version without swig. The plugin is separated in several dlls.

              1. myExtMain.dll is the main dll in c++, compiled with /clr, so it can load .net dlls.
              2. suWpfUI.dll is the UI dll in c#, witch implements the WPF GUI.
              3. suExtMainWrapper.dll is the wapper linked by the GUI to call c++ functions in myExtMain.dll. (This one seems not necessary, the reason to have it is that c# can not be linked to with myExtMain directly. However one can use P/Invoke in c# code
                using VALUE = System.Int32; using ID = System.Int32; [DllImport("msvcrt-ruby18", CallingConvention = CallingConvention.Cdecl)] private static extern VALUE rb_funcall_(VALUE recv, ID mid, int argc, __arglist);
                to directly call ruby functions, thus the suExtMainWrapper is not necessary.)
                Another issue is that suWpfUI and suExtMainWrapper are not explicitly loaded by ruby require so it needs to be placed inside Sketchup.exe directory. I haven't figure out how to avoid this.
              1 Reply Last reply Reply Quote 0
              • icehuliI Offline
                icehuli
                last edited by

                @jolran said:

                @unknownuser said:

                I think the same method can be applied for c++ gui, e.g. qt, as well. A new thread need to start for the GUI to avoid it being frozen while ruby scripts are being evaluated.

                Great! It's just the small detail of learning c++ then ๐Ÿ˜„

                Seriously though, I was under the impression these kinds of 2 way Communication was not possible outside webdialog-World.

                I would really like to know more.

                In windows C++ should be not much more difficult thanks to visual studio and .net. However in mac os it is more difficult since the default system gui library is cocoa, which require object-c. Once upon a time, one can use carbon to build cocoa GUI, but it is deprecated since OS X 10.8. Automatic Reference Counting, or ARC makes things more complicated. I am not familiar with other c++ or c libraries. If one does, one can try to use multithreadingโ€Ž tech. I tried qt yesterday. It is just not straight forward, since in qt every gui needs to be created and maintained in the main thread. And only one QApplication is allowed, thus multiple plugins using qt may cause problems.

                1 Reply Last reply Reply Quote 0
                • jolranJ Offline
                  jolran
                  last edited by

                  Many thanks for the valuable information, really ๐Ÿ‘
                  And the link too, much appreciated.

                  Looks like you know what youre talking about.

                  I'm probably not gonna dig into this just yet. Maybe if I reach a dead end with the Webdialog class.

                  I wan't to build an opinion if it's worth the effort first.

                  1 Reply Last reply Reply Quote 0
                  • icehuliI Offline
                    icehuli
                    last edited by

                    @jolran said:

                    Many thanks for the valuable information, really ๐Ÿ‘
                    And the link too, much appreciated.

                    Looks like you know what youre talking about.

                    I'm probably not gonna dig into this just yet. Maybe if I reach a dead end with the Webdialog class.

                    I wan't to build an opinion if it's worth the effort first.

                    ๐Ÿ˜„
                    I reached the dead end a year ago, when I implemented heavy optimization operations. I tried ruby thread, which is a fake in ruby 1.8. It did not solve my problem so I looked into c++ and than realize the extension can be compiled with /clr that opens the door to the wide .NET world.

                    1 Reply Last reply Reply Quote 0
                    • jolranJ Offline
                      jolran
                      last edited by

                      Aha, interesting. Will chew on it a little..

                      My brother is a .net developper with quite a bit of knowledge of C++, so I could probably get a big kickstart and set up. Otherwise I woulden't even consider trying..

                      Anyway, thanks again! I'll keep an eye on you projects ๐Ÿ˜‰

                      1 Reply Last reply Reply Quote 0
                      • icehuliI Offline
                        icehuli
                        last edited by

                        @jolran said:

                        Aha, interesting. Will chew on it a little..

                        My brother is a .net developper with quite a bit of knowledge of C++, so I could probably get a big kickstart and set up. Otherwise I woulden't even consider trying..

                        Anyway, thanks again! I'll keep an eye on you projects ๐Ÿ˜‰

                        Actually you can still use WebDialog without being frozen by heavy operations. The way is similar. Just put all the heavy operations to a new thread that started in the c++ code. The trick part is communication between threads (that's the point I started to look into .net, since it is much easier to handle multithreadingโ€Ž thing with .net libraries ).

                        1 Reply Last reply Reply Quote 0
                        • jolranJ Offline
                          jolran
                          last edited by

                          That doesent confuse me less ๐Ÿ˜„

                          About threads, I was under the impression Sketchup threads was a bit shaky ? Although I can't really tell the outcome from this topic.

                          http://sketchucation.com/forums/viewtopic.php?f=180&t=51701&p=467287&hilit=threads#p467287

                          1 Reply Last reply Reply Quote 0
                          • icehuliI Offline
                            icehuli
                            last edited by

                            @jolran said:

                            That doesent confuse me less ๐Ÿ˜„

                            About threads, I was under the impression Sketchup threads was a bit shaky ? Although I can't really tell the outcome from this topic.

                            http://sketchucation.com/forums/viewtopic.php?f=180&t=51701&p=467287&hilit=threads#p467287

                            Sorry, I can not see the post:
                            "The requested topic does not exist."

                            The issue for thread is that, Sketchup uses ruby version 1.8.6 (1.8.5 on mac), which does not implement native threads. It means they are not actually "parallel", only one thread is actually running at once, ruby controls the switch. I once tried to open a new thread in ruby to do the operation and check if the operation has finished within a loop in another thread. However the result is not reliable. One can not tell when it does the checks.

                            In my case my operations are independent from Sketchup. So when open it in another thread in c/c++ it does not freeze the webdialog. If the operations are Sketchup things, e.g. drawing, modification, etc. it will not help. In that case it's better to have the GUI in a new thread different from the ruby thread.

                            1 Reply Last reply Reply Quote 0
                            • jolranJ Offline
                              jolran
                              last edited by

                              Strange I don't seam to be able to paste the link properly. Never mind. The topic was called UI.timer or something like that.

                              From what I understand the outcome from that topic was about the same as you says.

                              I think I misstook c++ threads for Ruby threads. You could probably say anything regarding C code, and I believe it..

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

                                @icehuli said:

                                I think the same method can be applied for c++ gui, e.g. qt, as well. A new thread need to start for the GUI to avoid it being frozen while ruby scripts are being evaluated.

                                Isn't the work being done in the work being done in the new thread while the main thread remains control over the UI?

                                (Though this would not work in SU if the "work" is manipulating entities.)

                                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

                                  @jolran said:

                                  Strange I don't seam to be able to paste the link properly. Never mind. The topic was called UI.timer or something like that.

                                  From what I understand the outcome from that topic was about the same as you says.

                                  http://sketchucation.com/forums/viewtopic.php?f=180&t=51701

                                  People has been using timers to manually slicing up work that interact with the SketchUp Ruby API. It makes the total process take longer, but you can cancel the operation IF you manage the slice it down small enough.

                                  Though I'm not so sure how much gain you'll get in the long run.

                                  If it's calculations being done then I'd recommend you do that in C threads if you are able to. Though, it might run so fast in C that you might need to fiddle with threads and the possible horrors of deadlocks and race conditions. When I ported Vertex Tools' soft-selection calculations to C it ran hundreds of times faster than the ruby version - no need for threading.

                                  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

                                    Note that is is possible some times to get big improvements in just pure Ruby by doing a thing differently. I've found some tasks to take seconds instead of minutes just by working my way around Ruby's bottleneck. (Often it's reusing objects and cache calculations/results with Hashes.)

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

                                    1 Reply Last reply Reply Quote 0
                                    • icehuliI Offline
                                      icehuli
                                      last edited by

                                      @thomthom said:

                                      @icehuli said:

                                      I think the same method can be applied for c++ gui, e.g. qt, as well. A new thread need to start for the GUI to avoid it being frozen while ruby scripts are being evaluated.

                                      Isn't the work being done in the work being done in the new thread while the main thread remains control over the UI?

                                      (Though this would not work in SU if the "work" is manipulating entities.)

                                      The idea is to control the UI in a separate thread, so no matter what operation is being processed in the main thread or another thread the UI will not be frozen.

                                      1 Reply Last reply Reply Quote 0
                                      • L Offline
                                        leonTech
                                        last edited by

                                        I checked your extensions to invoker c#from ruby at https://github.com/icehuli/suWpfExt.
                                        I used to use win32ole to invoke my c# extensions. But since SU2014 and ruby 2.0I could not get anything up and running yet, either icehuli extension or my win32ole calls...

                                        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