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

    SketchupExtension in a single file

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 3 Posters 2.1k Views 3 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

      @dan rathbun said:

      Add to that the Sketchup.register_extension method code was changed on the C side for 8.0M2 ...

      What was that?

      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:

        Add to that the Sketchup.register_extension method code was changed on the C side for 8.0M2 ...

        What was that?

        To much to explain.. you'll need to read the comments in the code. Scott marks what were the private callbacks from the C side.

        But basically calling the method more than once in previous version has no benefit, screwed up the extension list in the dialog.
        Now 8.0M2+, the method was changed to expect to be called more than once, and to do things, based upon the change in arg 2.

        I'm not here much anymore.

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

          One reason I am a bit adverse to this idea is, that I was hoping for a day when plugins resided within their author's filespaces, and the plugins directory had nothing but extension registration scripts. All code for actual functionality, would be in subfolders.

          I like the idea, of being able, to switch off whole groups of plugins, by author is one way.

          I'm not here much anymore.

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

            The @extension_registered variable is always false when SketchUp starts, so the menus will never be created after the first time the extension is enabled.

            Hi

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

              @jim said:

              The @extension_registered variable is always false when SketchUp starts, so the menus will never be created after the first time the extension is enabled.

              😞

              Thought I'd fixed that... 😳

              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

                Oh, I was just reading your blog and copy/pasted the code, but I never got the menu to appear. But then later I thought the code should work because SketchUp should go ahead and reload the file as an extension after initially registering. So not sure what's going on.

                Hi

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

                  Re-read my earlier post: http://forums.sketchucation.com/viewtopic.php?f=180&t=43200&#p384925

                  Your setting up a vicious circle.

                  I'm not here much anymore.

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

                    What about using a begin ... rescue ... end block to "fool" SketchUp.

                    Meaning set the path to a file that does NOT exist, which will raise a LoadError Exception.
                    (EDIT: ..and I think you can just use an empty string for path, in this case.)

                    begin
                      # set up here
                      plugin = SketchupExtension.new('Nifty Plugin','dummy')
                      # set other attributes
                      Sketchup.register_extension(plugin,true)
                      # if it attempts to load, the rescue block fires
                    rescue LoadError
                      #
                      # A little code for a "quickie" Plugin here.
                      #
                    end
                    

                    I'm not here much anymore.

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

                      NO (the above,) will not work because Sketchup::require() and Sketchup::load() do not raise LoadError. They just return false on failure, and 0 on success.
                      (I do have a API bug report filed on this.)

                      I'm not here much anymore.

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

                        @dan rathbun said:

                        NO (the above,) will not work because Sketchup::require() and Sketchup::load() do not raise LoadError. They just return false on failure, and 0 on success.
                        (I do have a API bug report filed on this.)

                        They don't raise LoadError ...? That's interesting.

                        My mistake was that I tested the whole thing by loading manually from an external location instead of placing the file in the Plugins folder and having it load at startup. My "simulation" was incorrect.

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

                        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