by Anton_S » Sun Nov 17, 2013 9:29 am
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 RubyDocCompatibility
- 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 ExtensionStoreAMS 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.
Last edited by Anton_S on Sun May 30, 2021 1:57 am, edited 41 times in total.
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by wangyang0716 » Sat Jun 14, 2014 1:37 pm
that is very good
-
wangyang0716
-
- Posts: 1
- Joined: Sat May 17, 2014 11:28 am
- Name: wangyang
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
by pcberdwin » Mon Aug 11, 2014 11:15 pm
Where can I find 1.1.0?
-

pcberdwin
-
- Posts: 11
- Joined: Thu Jul 09, 2009 10:52 pm
by Anton_S » Mon Aug 11, 2014 11:42 pm
pcberdwin wrote: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.
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by pcberdwin » Tue Aug 12, 2014 10:56 pm
Ok thank you.
-

pcberdwin
-
- Posts: 11
- Joined: Thu Jul 09, 2009 10:52 pm
by Pherim » Wed Nov 05, 2014 2:15 pm
Doesn't seem to work with SU2015 64bit. Hope that will be fixed soon!
-
Pherim
-
- Posts: 173
- Joined: Sat Jun 12, 2010 8:40 am
- Location: Germany
- Name: Pherim
- Operating system: Windows
- SketchUp version: 2016
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Advanced
by scissors1121 » Wed Nov 05, 2014 9:01 pm
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,
-
scissors1121
-
- Posts: 1
- Joined: Fri Aug 24, 2012 12:00 am
by Anton_S » Thu Nov 06, 2014 9:41 pm
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\PluginsFrom there, delete the following: - ams_Lib.rb and amsLib folder.
- 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.
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by lionk » Sat Nov 08, 2014 3:32 pm
uninitialized constant Win32::API::Callback hope the issue can be resolved! thank you!
-
lionk
-
- Posts: 22
- Joined: Tue Dec 04, 2007 7:50 am
- Location: Beijing
- Operating system: Windows
- SketchUp version: pre-2013
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by davidheritier » Tue Dec 02, 2014 12:32 pm
hello thanks for this plugin! but when your are full screen with nothing else how can you come back to toolbar? thx again
-
davidheritier
-
- Posts: 4
- Joined: Mon Oct 07, 2013 5:20 pm
- Name: heritier
- Operating system: Windows
- SketchUp version: 2020
- License type: Pro
- SketchUp use: urban planning
- Level of SketchUp: Advanced
by ying2014 » Sun Feb 15, 2015 9:17 am
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?
-
ying2014
-
- Posts: 13
- Joined: Sun Jul 27, 2014 3:32 am
- Name: zyq
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
by Anton_S » Tue Feb 17, 2015 11:41 pm
Ying2014, here is a code snippet which allows you to remove borders from the dialog: - Code: Select all
# 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: - Code: Select all
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: - Code: Select all
@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.
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by ying2014 » Wed Feb 25, 2015 4:32 am
thanks!!It is very helpful to me
-
ying2014
-
- Posts: 13
- Joined: Sun Jul 27, 2014 3:32 am
- Name: zyq
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
by wikii » Tue Sep 15, 2015 4:44 am
Anton_S wrote:DescriptionAMS 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
UsageDownload
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
-
wikii
- PluginStore Author

-
- Posts: 151
- Joined: Mon Jan 28, 2008 1:13 am
- Name: wikii
by Anton_S » Tue Sep 15, 2015 6:51 am
That's a good idea. I will add swo_on_post_[event] methods in the upcoming version.
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by Anton_S » Wed Sep 16, 2015 12:06 pm
Hi Wikii. I added the post-events. You should try out this example in Ruby console: - Code: Select all
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/AntonSyn ... ANGELOG.md
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by wikii » Thu Sep 17, 2015 9:36 am
Anton_S wrote:Hi Wikii. I added the post-events. You should try out this example in Ruby console: - Code: Select all
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/AntonSyn ... ANGELOG.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
-
wikii
- PluginStore Author

-
- Posts: 151
- Joined: Mon Jan 28, 2008 1:13 am
- Name: wikii
by Anton_S » Thu Sep 17, 2015 2:59 pm
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/AntonSyn ... upObserver
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by Pherim » Sat Sep 19, 2015 9:17 am
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.
-
Pherim
-
- Posts: 173
- Joined: Sat Jun 12, 2010 8:40 am
- Location: Germany
- Name: Pherim
- Operating system: Windows
- SketchUp version: 2016
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Advanced
by Pherim » Mon Oct 05, 2015 12:20 pm
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).
-
Pherim
-
- Posts: 173
- Joined: Sat Jun 12, 2010 8:40 am
- Location: Germany
- Name: Pherim
- Operating system: Windows
- SketchUp version: 2016
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Advanced
by Anton_S » Mon Oct 05, 2015 2:53 pm
Thanks for your feedback Pherim. It would be nice to know more details about the crash, so that I could fix it in case it came from that plugin: - What Windows version and SU version were you using?
- Were you using AMS Library 3.0.1 and AMS Window Settings 4.2.0 - the latest versions of these plugins?
- When did the crash occur? Did it occur right away or after some time of using SU?
- What were you doing at the time the crash occurred? Like, what tool were you using or what command were you accessing?
- What is the list of other plugins you have installed?
Your response would be greatly appreciated, Anton
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by Pherim » Mon Oct 05, 2015 6:34 pm
Hello, 1. I'm using Windows 7 Professional 64bit and the newest version of Sketchup Make 2015 64bit. 2. Yes, both plugins were up to date. I am completely sure about this as I had to uninstall both and then reinstall them via the plugin store to make it work at all... just updating both plugins somehow did not work, as I wrote in the post before. I also updated it to 3.0.1 after I wrote this post. 3. I am not entirely sure, and right now I am unable to reproduce the crash... it's just that I noticed suddenly that when I changed the tool the cursor would not change as it was supposed to, and also the old tool would still be highlighted in the toolbar. And then, as soon as I right-clicked on a component (well, at least it was a component or group at least some of the times it happened), Sketchup crashed instantly. Well, at the moment it doesn't seem to happen even with your plugins active, but I'll be on guard about it. 4. Quite a lot I'm afraid... Though so far, they all worked fine together, and so did the old versions of your plugins.
At the moment everything seems to be fine. If this changes, I'll get in touch again.
-
Pherim
-
- Posts: 173
- Joined: Sat Jun 12, 2010 8:40 am
- Location: Germany
- Name: Pherim
- Operating system: Windows
- SketchUp version: 2016
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Advanced
by Anton_S » Mon Oct 05, 2015 8:21 pm
Thank you for your response, Pherim. I, too, came across cursor changing issues, but didn't consider it was related to my library. For AMS Library 3.x.y, the main difference between prior versions, is that I modified it to be Unicode rather than Ascii. That said, I probably implemented something improperly. I will look into that issue.
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by Anton_S » Tue Oct 06, 2015 8:50 am
Hello Pherim. I tried to reproduce the crash or inconsistent cursor changing behavior with AMS Library 3.0.1, but, similarly to your trial, I couldn't. It is very likely that such bug persisted in version 3.0.0, but not in the current version, 3.0.1. But to be sure, I'll keep an eye on the library.
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by wikii » Sun Nov 22, 2015 3:59 am
AMS::Window.send_message can sent something to a sketchup window, but,how to get message in sketchup by ruby?
thank you.
-
wikii
- PluginStore Author

-
- Posts: 151
- Joined: Mon Jan 28, 2008 1:13 am
- Name: wikii
by Anton_S » Sun Nov 22, 2015 6:24 am
Are you asking for a windows function, like GetMessage or PeekMessage? Current version of AMS Library, doesn't have these functions implemented. However, you can implement a Windows function manually, using Win32::API that is shipped with AMS::Library. Here is an example: - Code: Select all
module MyDesiredNamespace
GetMessageA = AMS::Win32::API.new('GetMessageA', 'PLLL', 'I', 'User32') GetMessageW = AMS::Win32::API.new('GetMessageW', 'PLLL', 'I', 'User32')
class << self
# Get windows message ANSI. # @note GetMessage waits until the message is received. This means this # function will freeze the computer until the message is triggered. # @param [Fixnum] filter_min Value of the lowest message value to be retrieved. # @param [Fixnum] filter_max Value of the highest message value to be retrieved. # @param [Fixnum] handle A handle to the window whose messages are to be retrieved. # @return [Array] Message inforamtion: # [handle, message, wParam, lParam, time, x, y] # @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms644936(v=vs.85).aspx def get_messageA(filter_min, filter_max, handle = AMS::Sketchup.get_main_window) buffer = "\0" * (4 * 7) # See https://github.com/djberg96/win32-api for Win32::API usage res = GetMessageA.call(buffer, handle, filter_min, filter_max) return buffer.unpack('lLlllll') end
# Get windows message Unicode. # @note GetMessage waits until the message is received. This means this # function will freeze the computer until the message is triggered. # @param [Fixnum] filter_min Value of the lowest message value to be retrieved. # @param [Fixnum] filter_max Value of the highest message value to be retrieved. # @param [Fixnum] handle A handle to the window whose messages are to be retrieved. # @return [Array] Message inforamtion: # [handle, message, wParam, lParam, time, x, y] # @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms644936(v=vs.85).aspx def get_messageW(filter_min, filter_max, handle = AMS::Sketchup.get_main_window) buffer = "\0" * (8 * 4) * (4 * 3) # See https://github.com/djberg96/win32-api for Win32::API usage res = GetMessageW.call(buffer, handle, filter_min, filter_max) return buffer.unpack('qLqqqll') end
end # class << self end # module MyDesiredNamespace
# In the following case, the function will return when left or right mouse # buttons are click caption or non-client area of any window. res = MyDesiredNamespace.get_messageW(0x0A1, 0x0A6, 0)
However, if you're aiming to monitor Sketchup action commands, which come when different tools are activated, then you'll probably want to use AMS::SketchupObserver with swp_on_command(id): - Code: Select all
class MyObserver
def swp_on_command(id) # Process command here p id # Return 1 to block this command; 0 to pass this command 0 end
end
my_observer = MyObserver.new AMS::Sketchup.add_observer(my_observer)
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by wikii » Sun Nov 22, 2015 7:49 am
Hi Anton_S
Thank you for you reply! If I want send a message from Sketchup window A to Sketchup window B, I can use AMS::Window.send_message.
But ,how can Sketchup window B get to know there is a message come from window A?
I think , Window B must have an observer to get message when message come.
I want to konw , can window B respond message sent from A immediately?
Thank you for you great lib!
wikii
-
wikii
- PluginStore Author

-
- Posts: 151
- Joined: Mon Jan 28, 2008 1:13 am
- Name: wikii
by Anton_S » Sun Nov 22, 2015 10:20 am
Hmm, communication between windows? That's interesting! I will look into that.
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by Jim » Sun Nov 22, 2015 11:14 pm
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by Anton_S » Mon Nov 23, 2015 12:39 am
Thanks for the head start, Jim! That, SendMessageCallback, should do it. I will implement it into my library for an easy way to use. This is what I'm thinking to add in the future release: A function to communicate to another window. # Transmit information to another window. # @param [Fixnum] dest_handle A handle to a destination window. # @param [Fixnum] id A unique message identifier, a value b/w 0 and 4016. # ID allows users to filter their messages from messages of other users. # However, there is a downside, as some plugin developers might use # same ID, but it's very unlikely. # @param [String] data Message information. AMS::Sketchup.send_message_to_window(dest_handle, id, data)An observer that receives transmitted messages. # Called when user sent message arrives to its destination window. # @param [Fixnum] sender_handle A handle to a window that sent a message. # @param [Fixnum] id Message id. # @param [Fixnum] data Message information. AMS::SketchupObsever.swo_on_message_received(sender_handle, id, data)A bonus function that allows users to get handles to all Sketchup Windows. # Get all SU windows # @return [Array<Fixnum>] An array of all SketchUp main windows except this one. AMS.get_all_sketchup_windowsAn example, where this window communicates to all other SU windows: - Code: Select all
class MyDataTransferClass
MY_PORT = 123
# @param [String] Data in string form. def send_data_to_all_windows(data) su_windows = AMS.get_all_sketchup_windows su_windows.each { |dest_handle| AMS::Sketchup.send_message_to_window(dest_handle, MY_PORT, data) } end
# Implement one of the SketchUp Window Observer callback methods. def swo_on_message_received(sender_handle, id, data) # Return if id is not yours if id != MY_PORT # Otherwise, do anything with data. # In our case, we'll evaluate it. eval(data) end
end # class MyDataTransferClass
# Create an instance of our communication class my_data_transfer = MyDataTransferClass.new
# Register your class to SketchUp observers as it contains one of the SU observer methods. AMS::Sketchup.add_observer(my_data_transfer)
# Send a message to all other SU windows. my_data_transfer.send_data_to_all_windows("puts 'Hi, this is a message from another window!'")
Well, you have an insigt of how I'm planning to implement it. Once I'll add these functions into my library, I will notify you, wikii. If anyone has any suggestions on improvement of this plan, please inform.
-
Anton_S
- PluginStore Author

-
- Posts: 1256
- Joined: Tue Nov 23, 2010 9:15 pm
- Name: Anton
- Operating system: Windows
- SketchUp version: 2018
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Advanced
by Ad Machine » 5 minutes ago
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Plugins
|