Read Serial port or USB interface
-
Hello there,
How can I communicate Sketchup to read serial port, HID USB device, a Joystick, game controller or any HID input device. I want data to move objects or do whatever I program. Maybe libraries or plugins let me read input port (serial/USB)? ANy sugested documentation to study? thanx.
RodSTAR -
on windows at least two ways to do this:
- use the ruby "Win32api.so" library to read data from a dll exposing public methods of these input devices. You can build this dll quite quickly with visual studio for example.
- "communicate" your input devices to an internet explorer page and then use Sketchup 6 new web-dialog functionality.
http://sketchupapi.blogspot.com/2008/02/sharing-data-between-sketchup-ruby-and.html
Moris
-
Hello morisdov,
@unknownuser said:
- "communicate" your input devices to an internet explorer page and then use Sketchup 6 new web-dialog functionality
I have been tried your sugestion, but it's not clearly enough. I had created serial port appplication in VB6. I want to send string data "motor_on", then the motor starts running in sketchyphysics. Could you explain step by step please ?
Regards
alapalap -
Could somebody help me please ?
-
@alapalap said:
Could somebody help me please ?
Could you just use Ruby to write to a text file, and the have the VB app, poll and read the value from the text file and then do the communication to the port?
Kind of a non-direct route...but should get you going.
Joe
-
To Joe : I am still confuse what you are saying. I am still beginner on it. May I know the detail ? or may be, where I can find the article of it in web ?
-
Highly likely that you can kludge something together and highly unlikely that the result will survive the next release of Windows or SketchUp. Can you solve the problem with a WebDialog? (The user clicks a "motor on" checkbox and you send "motor on" to sketchyphysics.)
-
@alapalap said:
I [have] created [a] serial port application in VB6. I want to send string data "motor_on", then the motor starts running in sketchyphysics. Could you explain step by step please ?
(1) get TBD's SketchUp Bridge ( sub.exe ) utility and install as he explains.
-
Download SUBridge v1.1 from http://labs.plugins.ro
(2) write small ruby snippets, in a subfolder of Plugins, ie: -
.../Plugins/alap/motor_on.rb* .../Plugins/alap/motor_off.rb
(3) from your VB6 application, call the Ruby snippets, using Shell( ) -
[url=http://msdn.microsoft.com/en-us/library/xe736fyk(VS.71).aspx:1u4emsd7]VB Shell function (click to read reference at MSDN.)[/url:1u4emsd7]* motor_on (VisualBasic)
Sub motor_on() Dim pID As Integer pID = Shell("""C;\Program Files\Google\Sketchup 7\Plugins\sub.exe"" alap\motor_on.rb", AppWinStyle.MinimizedNoFocus) End Sub- motor_off (VisualBasic)
Sub motor_off() Dim pID As Integer pID = Shell("""C;\Program Files\Google\Sketchup 7\Plugins\sub.exe"" alap\motor_off.rb", AppWinStyle.MinimizedNoFocus) End Sub- ...etc,.. etc. [There are only 2 lines in the code blocks above; the forum may wrap the long Shell line in a strange way, but it's all 1 line.]
P.S.: You may also want to have a look at TBD's SUDLL
- example (MS VC++6) on how to create a DLL and communicate with Sketchup Ruby
- [url=http://plugins.ro/labs/SUDLL.zip:1u4emsd7]Download SUDLL.zip[/url:1u4emsd7] from http://labs.plugins.ro
-
-
I think I made an error.. and meant to have the 2nd argument in the Shell calls be a Ruby statement, like: "load 'alap\motor_on.rb'" instead of just the rubyscriptname.
@TBD ??
-
it was ok, the command line needs the .rb file that needs to be executed in the Sketchup context.
-
Hi! I am a student of electrotechnical engineering and i'm doing a project. I need a little help! How i get values from serial port to sketchyphysics?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement