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

    WxWindows for SketchUp Dialogs

    Scheduled Pinned Locked Moved Developers' Forum
    45 Posts 17 Posters 7.0k Views 17 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.
    • T Offline
      tomasz
      last edited by

      I have done some progress using WxSU. Thank you Peter!

      Is there a way to hide a WxSU Frame when SU program is minimized?
      I cannot achieve it (Vista). I thought it should work when SU frame is specified as a parent window (WxSU.app.sketchup_frame).

      I have checked that even all examples always stay visible when SU is being minimized.

      Tomasz

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

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

        @billw said:

        ... Personally, I would much rather use WxSU than Webdialogs, much more flexible and entirely in Ruby and cross platform.

        Have you used the WxFormBuilder? It would be nice to have a straight output compatible with WxSU! There is a beta which works with Python.

        Tomasz

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

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

          I have found that WxSU won't close a Dialog on SU exit. It closes Frames without a problem.

          I haven't figured it out how to fix it yet.

          Tomasz

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

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

            I would appreciate any help with solving this strange bugsplat which appears instead of a simple ruby error message in the console.
            It happens after triggering an 'evt_button'.

            require("wxSU/lib/Startup")
            
            module Test
            
            	class MainMenu < Wx;;Frame
            
            		def initialize()
            			super(WxSU.app.sketchup_frame, -1, "Test", Wx;;DEFAULT_POSITION, Wx;;Size.new(440,260), WxSU;;CHILD_FRAME_STYLE | Wx;;FRAME_FLOAT_ON_PARENT | Wx;;FRAME_NO_TASKBAR )
            			main_panel = Wx;;Panel.new(self, -1)
            
            			button = Wx;;Button.new(main_panel, -1, "Action!", Wx;;DEFAULT_POSITION, Wx;;DEFAULT_SIZE)
            
            			evt_button(button.get_id) {|event| button_click(event) }
            
            		end
            
            		def button_click(event)
            			xx44 ## HERE COMES INNOCENT RUBY ERROR
            		end
            
            	end
            
            	main_menu=MainMenu.new
            	main_menu.show
            
            end
            

            event_bugsplat.rb

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

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

              Hi,
              Has someone succeed to run wxSU on MAC SnowLeopard? I have received a report that wxSU 3.0 failed to start on that system.

              It looks like it has to be compiled for SmowL in a special way.
              EDIT: PC version from the ZIP file doesn't run well on MAC 👊 😳

              I would love to see more people involved in moving this library into a decent stage of development, because I find that it is very easy to build even complicated interfaces and WxWidgets can be used when writing programs in C++, so the lessons learned in Ruby can be used in programming SU C++ extensions.

              Tomasz

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

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

                PROBLEM:
                Windows: The SketchUp main window is not recognised correctly when an SKP file is being opened by double-click.

                FIX:
                MsWindowsFrame.rb
                line 60 should read:

                model_name=File.basename(model_path,".skp")
                

                was model_name=File.basename(model_path) which was including extension of a SU file.

                BTW. Why Sketchup.active_model.name returns always an empty string. Shouldn't it refer to the file name??


                The rb file with the fix

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

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

                  @unknownuser said:

                  BTW. Why Sketchup.active_model.name returns always an empty string. Shouldn't it refer to the file name??

                  No - form the manual: http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/model.html#name

                  
                  The name method retrieves the string name of the model.
                  
                  

                  Does not refer to filename. But I think it's similar to definition.name. When you import one model into another it comes in as a component - and I think this property refers to what the definition name will be.

                  But you have model.path instead:
                  http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/model.html#path

                  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

                    @unknownuser said:

                    model_name=File.basename(model_path,".skp")
                    

                    was model_name=File.basename(model_path) which was including extension of a SU file.

                    The Model.title method returns the basename (ie filename,) minus the file extension.

                    Note comparison:

                    
                    model_name=File.basename(model_path,".skp")
                    Sketchup.active_model.title == model_name
                    # would return true
                    
                    

                    I'm not here much anymore.

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

                      @dan rathbun said:

                      The Model.title method returns the basename (ie filename,) minus the file extension.

                      Uh? is that something SU implements? don't see it in the manual...

                      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

                        @thomthom said:

                        @dan rathbun said:

                        The Model.title method returns the basename (ie filename,) minus the file extension.

                        Uh? is that something SU implements? don't see it in the manual...

                        Woops.. sorry omitted the link. Here is is:
                        http://code.google.com/apis/sketchup/docs/ourdoc/model.html#title

                        I'm not here much anymore.

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

                          I'm going crosseyed. didn't see that. think I looked at Sketchup class when I looked... 😳

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

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

                            @dan rathbun said:

                            The Model.title method returns the basename (ie filename,) minus the file extension.

                            Thanks. I wasn't aware of the method.

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

                            1 Reply Last reply Reply Quote 0
                            • Dan RathbunD Offline
                              Dan Rathbun
                              last edited by

                              @unknownuser said:

                              Why Sketchup.active_model.name returns always an empty string.

                              ANSWER: It doesn't ALWAYS return an empty String, it always returns the value of the name attribute (which is class String.)

                              But IF you never set the value of the name attribute, then of course it will 'seem' to always be an empty value, because it is.

                              The value can be set easily using the Model.name= method.

                              Example Code:

                              
                              n = Sketchup.active_model.name
                              n.inspect
                              #>> ""
                              Sketchup.active_model.name="A newly set name for my model."
                              n.inspect
                              #>> "A newly set name for my model."
                              
                              

                              IF you are writing plugins for other users, you should not expect the name attribute to always be empty, and should (in your code,) allow for those times when the model has been assigned a name value (by the user or another plugin.)

                              ALSO, in the Outliner Window, the model will be listed by .title value, NOT by the .name attribute.

                              P.S.: I can't find a edit control, anywhere in the UI that allows setting the .name (or the .tags) attribute. They SHOULD be on the 'File' page of the Model Info ToolDialog, but are not. (This forces us to use the Console to set the name or write a lil' script to make an inputbox.)

                              Edited: meant to say ' .tags' attribute instead of '.note'; a note is just a Text class object, and not a attribute of the Model.

                              I'm not here much anymore.

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

                                @unknownuser said:

                                Have you used the WxFormBuilder? It would be nice to have a straight output compatible with WxSU! There is a beta which works with Python.

                                Tomasz

                                or you can export your design to a xrc file (xml style) and load it with xml methods from the Wx module.

                                xml = Wx::XmlResource.get
                                xml.load(your_file.xrc)

                                (google for "xrcise", this utility write for you the code needed to load your xrc)

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

                                  @unknownuser said:

                                  I would appreciate any help with solving this strange bugsplat which appears instead of a simple ruby error message in the console.
                                  It happens after triggering an 'evt_button'.

                                  It looks like WxSU doesn't handle errors communication between WxRuby and Sketchup.

                                  The best way to get rid of bugsplats is to handle exceptions by yourself, at the end of each method that uses WxSU:
                                  That way, you display the call stack, letting you know where the bug is.

                                  
                                  rescue => detail
                                     puts detail.message
                                     puts detail.backtrace.join("\n")
                                  
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    tomasz
                                    last edited by

                                    @malkomitch said:

                                    The best way to get rid of bugsplats is to handle exceptions by yourself, at the end of each method that uses WxSU:
                                    That way, you display the call stack, letting you know where the bug is.

                                    Thanks a lot for your help.
                                    I get a bugsplat when closing SU, but it is definitely better this way.
                                    I though that begin ... rescue ... end is required, but I am glad to hear that rescue alone is sufficient.

                                    Writing about xml loading I must say that I prefer to write my own Ruby code based on 'initial' FormBuilder layout, as it helps me better understand WxRuby. Thanks for hint anyway!

                                    Tomasz

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

                                    1 Reply Last reply Reply Quote 0
                                    • Dan RathbunD Offline
                                      Dan Rathbun
                                      last edited by

                                      @unknownuser said:

                                      I thought that begin ... rescue ... end is required, but I am glad to hear that rescue alone is sufficient.

                                      That is because in module definitions, the module statement is a block statement so the word module works the same as begin (after all, the module does need an end.)

                                      
                                      module My_Module
                                        # method defs
                                        # code goes here
                                      rescue
                                        # error handling code
                                      else
                                        # only do code if no exceptions
                                      ensure
                                        # always do this code on exit
                                      end # the end of the method def
                                      
                                      

                                      The same is true for method definitions, where the def keyword 'begins' the block.

                                      
                                      def my_method
                                        # code goes here
                                      rescue
                                        # error handling code
                                      else
                                        # only do code if no exceptions
                                      ensure
                                        # always do this code
                                      end # the end of the module
                                      
                                      

                                      I'm not here much anymore.

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

                                        @dan rathbun said:

                                        That is because in module definitions, the module statement is a block statement so the word module works the same as begin (after all, the module does need an end.)

                                        Thanks for the explanation.

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

                                        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