SketchUp’s Ruby API is designed to be used from within SketchUp. Ruby commands (and thus actions in SketchUp) can be triggered at load time, from the Ruby Console, from UI callbacks (menu items, toolbar buttons), from htmldialog callbacks, from (entity) observers but not from another application.
SketchUp can trigger actions, but actions in SketchUp cannot be triggered from outside (you would need to build a mechanism to make SketchUp listen to incoming messages).
- If your extension is supposed to be used with a dialog anyways, you could make use of the HtmlDialog’s networking (ajax calls, websockets) to connect to your application in a completely cross-platform way, and then forward the incoming messages to Ruby callbacks.
- As far as I remember, Ruby sockets may not properly work. You could use the Sketchup::Http methods to send requests. With long-running requests you can listen to events from outside (the external application does not immediately send a response but waits until it wants to trigger an action in SketchUp).
- By writing a Ruby C extension (platform-specific) you can establish communication with outside. That’s what custom drivers do (SpaceNavigator). I think @thomthom connected to external sensors (Arduino/Raspberry?), but I could not find such code in his Github projects.
Important is that Ruby runs single-threaded within SketchUp’s single application thread. That means whatever solution you find must be non-blocking.