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

    [Plugin] AMS Library 3.7.1b (29 May 2021)

    Scheduled Pinned Locked Moved Plugins
    107 Posts 38 Posters 615.5k Views 38 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.
    • A Offline
      Anton_S
      last edited by Anton_S

      Description


      AMS Library is a helper extension that provides functions and utilities for interacting with SketchUp window and its input procedures, via the Microsoft Windows API. Features include switching SketchUp fullscreen, monitoring window state changes, monitoring keyboard and mouse events, and preventing the interference of SketchUp keyboard and mouse shortcut accelerators. Such features provide extension developers with additional control over their tool. In addition to utilizing Sketchup::Tool events, a developer can utilize AMS Library's keyboard and mouse callback functions to receive input of all the messages, including the mouse wheel. AMS Library's callback events are registered in form of observers (although they are also modifiers), meaning a tool does not necessarily have to be an active tool in order to receive input events. This allows for operating extensions while other extensions are operating. In addition to the observer and modifier procedures, AMS Library provides Windows API functionality for tweaking dialogs to a next level, including removing the surrounding window frame and applying window transparency. Furthermore, AMS Library comes with various geometry and entity hierarchy manipulation functions. In a way, AMS Library provides developers with functionality not achievable with SketchUp Ruby API.

      Usage


      AMS Library is intended to be used as a dependency extension by other extensions. Currently, AMS Library is used by MSPhysics extension.

      Usage documentation can be found at RubyDoc

      Compatibility


      • Microsoft Windows XP, Vista, 7, 8, 10; 32/64 bit
      • Mac OS X 10.9+ 64 bit only
      • SketchUp 6 or later

      Download


      AMS Library is available at SketchUcation ExtensionStore

      AMS Library can be installed through SketchUcation ExtensionStore, provided that SketchUcation Tools are installed.

      To install manually, download the RBZ file and use the native Sketchup Extension Manager to install

      To uninstall, navigate to plugins folder and delete ams_Lib folder and ams_Lib.rb file.

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

        that is very good

        1 Reply Last reply Reply Quote 0
        • pcberdwinP Offline
          pcberdwin
          last edited by

          Where can I find 1.1.0?

          1 Reply Last reply Reply Quote 0
          • A Offline
            Anton_S
            last edited by

            @pcberdwin said:

            Where can I find 1.1.0?

            Are you asking this because you downloaded MSPhysics from Gitchub, which requires AMS Library 1.1.0? Well, if that's the purpose, you'll have wait until its finished.

            1 Reply Last reply Reply Quote 0
            • pcberdwinP Offline
              pcberdwin
              last edited by

              Ok thank you.

              1 Reply Last reply Reply Quote 0
              • P Offline
                Pherim
                last edited by

                Doesn't seem to work with SU2015 64bit. Hope that will be fixed soon!

                1 Reply Last reply Reply Quote 0
                • S Offline
                  scissors1121
                  last edited by

                  I don't want SU Viewer installed, but I keep getting the following error whenever I start up 2015:
                  "SU Window Settings extension requires AMS Library! Download AMS Library, extract it into the Plugins folder, and then restart SketchUp. Click OK to proceed to the library's homepage."
                  There is no Plugins folder for 2015, and I have uninstalled SU Viewer from the extension warehouse.

                  How do I get rid of this error message?

                  Thank you,

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    Anton_S
                    last edited by

                    Since SU2014 the plugins folder was changed to AppData location. To get rid of the plugin, copy this path to your explorer:
                    %appdata%\SketchUp\SketchUp 2015\SketchUp\Plugins

                    From there, delete the following:

                    1. ams_Lib.rb and amsLib folder.
                    2. ams_WindowSettings.rb and ams_WindowSettigns folder.

                    I will get this thing compatible with SU2015 and prevent the message from showing up each time...
                    Sorry for inconvenience.

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

                      uninitialized constant
                      Win32::API::Callback
                      hope the issue can be resolved! thank you!

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        davidheritier
                        last edited by

                        hello thanks for this plugin!
                        but when your are full screen with nothing else how can you come back to toolbar?
                        thx again

                        1 Reply Last reply Reply Quote 0
                        • Y Offline
                          ying2014
                          last edited by

                          Can I ask you a question?How do you make a *.html files does not display a dialog box in SketchUp ?just like the ams_WindowSettings.I think it is very cool.So ,if possible ,can you give a simple example?

                          1 Reply Last reply Reply Quote 0
                          • A Offline
                            Anton_S
                            last edited by

                            Ying2014, here is a code snippet which allows you to remove borders from the dialog:

                            
                            # Create a web dialog
                            @title = 'MyDialog'
                            @dialog = UI;;WebDialog.new(@title, false, 'MyDialog', width, height, ix, iy, true)
                            # Add Callbacks
                            @dialog.set_on_close(){
                              @dialog = nil
                              @handle = nil
                            }
                            # Set file
                            @dialog.set_file(html_path)
                            # Show dialog
                            RUBY_PLATFORM =~ /mswin|mingw/i ? @dialog.show ; @dialog.show_modal
                            # Find dialog handle
                            @handle = AMS;;Sketchup.find_window_by_caption(@title)
                            # Remove dialog caption and borders
                            if @handle
                              layered = AMS;;System.get_windows_version < 6.0 ? 0 ; 0x00080000
                              style_ex = 0x00010000 | layered # WS_EX_CONTROLPARENT | WS_EX_LAYERED
                              style = 0x94000000 # WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS
                              AMS;;Window.lock_update(@handle)
                              AMS;;Window.set_long(@handle, -20, style_ex)
                              AMS;;Window.set_long(@handle, -16, style)
                              AMS;;Window.lock_update(nil)
                              AMS;;Window.set_pos(@handle, 0, 0, 0, 0, 0, 0x0267)
                            end
                            
                            

                            Basically, what it does is creates a webdialog, finds its handle, and removes its borders. Along with removing borders it adds a layered style, which allows it to be made transparent.

                            To make the dialog draggable, you'd have to implement a few callbacks in your javascript file that would respond to mouse click and mouse move. Here is a snippet:

                            
                            function callback(name, data) {
                              if (!data) data = "";
                              window.location.href = "skp;" + name + "@" + data;
                            }
                            $(document).ready( function() {
                            
                              var md = false;
                              var pos = [0,0];
                              var dragged = false;
                              
                              // Detect Drag.
                              $( "#some_id" ).mousedown(function(e) {
                                md = true;
                                var x = e.clientX;
                                var y = e.clientY;
                                pos = [x,y];
                                callback("drag_start", null);
                                dragged = false;
                                return false;
                              });
                              $( document ).mousemove(function(e) {
                                if (!md) return;
                                var x = e.clientX;
                                var y = e.clientY;
                                var dx = x-pos[0];
                                var dy = y-pos[1];
                                if ((dx == 0) && (dy == 0)) return;
                                dragged = true;
                                callback("drag", "["+dx+","+dy+"]");
                            	return false;
                              });
                              $( document ).mouseup(function(e) {
                                if (md) {
                                  md = false;
                                  callback("drag_end", null);
                            	  return false;
                                }
                              });
                            });
                            
                            

                            In the code above, "#some_id" has to be changed to any id of an element in your HTML. It can also be changed to document to respond to drag anywhere in HTML.

                            Then have these callbacks implemented in SketchUp:

                            
                            @offset = [0,0]
                            @dialog.add_action_callback('drag_start'){ |dlg, params|
                              c = AMS;;Cursor.get_pos
                              d = AMS;;Window.get_origin(@handle)
                              @offset = [c.x - d.x, c.y - d.y]
                            }
                            @dialog.add_action_callback('drag'){ |dlg, params|
                              c = AMS;;Cursor.get_pos
                              x,y = [c.x - @offset.x, c.y - @offset.y]
                              AMS;;Window.set_origin(@handle, x, y, false)
                            }
                            @dialog.add_action_callback('drag_end'){ |dlg, params|
                              @offset = [0,0]
                            }
                            
                            

                            To change dialog opacity, use this function:
                            AMS::Window.set_layered_attributes(@handle, 0, opacity, 2)

                            To make the dialog clip to screen and snap to viewport, you'd have to add more ruby functionality and modify dialog position in the 'drag' callback. I would advice looking into ams_WindowSettings/main.rb for source.

                            1 Reply Last reply Reply Quote 0
                            • Y Offline
                              ying2014
                              last edited by

                              thanks!!It is very helpful to me

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

                                @anton_s said:

                                Description

                                AMS Library is a collection of tools and functions used to interact with SketchUp window and its sub-windows using Microsoft Windows API. It's capable to switch SketchUp full screen, show/hide toolbar containers, status bar, scenes bar, and more elements of the window. It's also capable to observe and make decisions to various events of the window procedure. In many ways, this library is written to achieve things that cannot be done with standard SketchUp API.

                                This library includes Ruby FFI and and Win32 API extensions as part of the utility. Both of these gems are recompiled under my own name-space for compatibility with other extensions. I do not take ownership of such gems, nor I claim any credit for them. I just happen to rely on them so much that it was essential to include them in the library.

                                Requirements

                                • Microsoft Windows XP, Vista, 7, or 8
                                • SketchUp 6 or later
                                  Usage

                                Yardoc Documentation

                                Download

                                • Available at PluginStore
                                • ams_Lib_2.2.0.zip
                                  Extract content into the Plugins folder!

                                It is a great lib!

                                one question:

                                when i use swo_on_maximize ,like this
                                class MySketchupObserver
                                def swo_on_maximize
                                r=AMS::C.get_viewport_rect()
                                p r
                                end
                                end
                                AMS::Sketchup.add_observer($o=MySketchupObserver.new)

                                I found get_viewport_rect returns the value of viewport before maximized.

                                So, can you provide a method like swo_on_maximized, will be called when maximize complete?

                                thank you for the great lib!

                                wikii

                                1 Reply Last reply Reply Quote 0
                                • A Offline
                                  Anton_S
                                  last edited by

                                  That's a good idea. I will add swo_on_post_[event] methods in the upcoming version.

                                  1 Reply Last reply Reply Quote 0
                                  • A Offline
                                    Anton_S
                                    last edited by

                                    Hi Wikii. I added the post-events.
                                    You should try out this example in Ruby console:

                                    class MySUWindowObserver
                                      def swo_on_maximize
                                        puts 'swo_on_maximize'
                                        p AMS;;Sketchup.get_viewport_rect()
                                      end
                                    
                                      def swo_on_post_maximize
                                        puts 'swo_on_post_maximize'
                                        p AMS;;Sketchup.get_viewport_rect()
                                      end
                                    
                                    end # class MySUWindowObserver
                                    
                                    my_obs = MySUWindowObserver.new
                                    AMS;;Sketchup.add_observer(my_obs)
                                    

                                    AMS Library 3 ChangeLog: http://www.rubydoc.info/github/AntonSynytsia/AMS-Library/master/file/CHANGELOG.md

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

                                      @anton_s said:

                                      Hi Wikii. I added the post-events.
                                      You should try out this example in Ruby console:

                                      class MySUWindowObserver
                                      >   def swo_on_maximize
                                      >     puts 'swo_on_maximize'
                                      >     p AMS;;Sketchup.get_viewport_rect()
                                      >   end
                                      > 
                                      >   def swo_on_post_maximize
                                      >     puts 'swo_on_post_maximize'
                                      >     p AMS;;Sketchup.get_viewport_rect()
                                      >   end
                                      > 
                                      > end # class MySUWindowObserver
                                      > 
                                      > my_obs = MySUWindowObserver.new
                                      > AMS;;Sketchup.add_observer(my_obs)
                                      

                                      AMS Library 3 ChangeLog: http://www.rubydoc.info/github/AntonSynytsia/AMS-Library/master/file/CHANGELOG.md

                                      Hi Anton_S !

                                      It works well in my pc.
                                      It is really cool!

                                      Thank you for your working.

                                      But I have one question more:

                                      When I use win+left or win+right to fill Sketchup to half the size of the screen, which observer call catch this operation?

                                      Thank you!

                                      wikii

                                      1 Reply Last reply Reply Quote 0
                                      • A Offline
                                        Anton_S
                                        last edited by

                                        Currently, no observer catches such operation, but if you want to track window moving and resizing, you can always use swo_on_enter_size_move, swo_on_size_move, swo_on_exit_size_move, or/and swo_on_viewport_size. Check out available observers here: http://www.rubydoc.info/github/AntonSynytsia/AMS-Library/master/AMS/SketchupObserver

                                        1 Reply Last reply Reply Quote 0
                                        • P Offline
                                          Pherim
                                          last edited by

                                          Hello, when I updated to 3.0.0 WindowsSettings didn't work any more, I had to delete both AMS Lib and WindowSettings and reinstall them to make it work again. Just thought I'd mention it in case anyone else has this problem.

                                          1 Reply Last reply Reply Quote 0
                                          • P Offline
                                            Pherim
                                            last edited by

                                            I am not entirely sure, because I have not used SketchUp very much recently, but this plugin could be causing crashes for me, since I only noticed this happening after I installed the new version and it seems to have stopped since I deactivated it (and the Windows Settings plugin with it).

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

                                            Advertisement