Read in real time data in Rhino 8 ( via Python)

Hello community! Trying to make myself a dream come true, I created a tactile probing arm ( CMM; Faro - Arm; ) style - like device with 6 encoders for scanning items. For the read out of the serial protocol ( via USB). I use python 3.x scripting, ( incuding Serial.Py module) which in stand alone mode - and after some struggeling with the USB hardware - works fine. I tried to install the serial module for Python3 version on the preinstalled/ Rhino implemented Python3 and then started my script, but Rhino immediately stalled. Would there be any recommendation, how to get a constant read of the probed data into Rhino environment, to proceed with the system related transforamations and set the allocated point in space in the Rhino working space. Alternatively if not possible … would there be sceario to run Python seprartely/ in parallel and have a commonly used memory area (? framework?) to write in / read from.

Thank you in advance!
Hansjoerg

You’ll have to ensure your script does its work in a thread and doesn’t block Rhino. Regular script execution will block Rhino, which is what you are seeing.

Not sure how easy this is to do with a Python script, I would personally go for a C# plug-in to do the reading and data updating.

Or use something like Firefly (not sure if that works in Rhino 8). See for instance this post: Grasshopper and Arduino real-time communication

2 Likes

Hi @hansjoerg.berroth,

You might consider creating a 3d Digitizing plug-in, which are designed to interfaces with digitizing devices, such as those made by Faro, and Romer.

– Dale

2 Likes

Thanks to both of you!
From hardware side I collect 6 subprotocols from 6x Arduino Nano boards via i2C, accumulate the results to a single string, which I send via USB to the laptop.
Transformations and math is then done on the laptop and the 3D coordinate is printed in the command window (X;Y;Z).
I know a little about C#, but I’m not an experienced programmer when it comes to windows specific things. ( I’m more a mechanics guy). So although the math behind the plugin is not that complex, I understand that I would need the Rhino Developers tools set and the MS Visual Studio ( preferably the pfessional version to have full support with the USB libraries) - currently I just have the community version installed.-Or I would have to write a 3 D visualization ( OPEN GL ) separately from Rhino and afterwards just trasfer the dataset as a point cloud or structured point cloud . Just to dig a little deeper into that topic - would there be a kind of example of a typical plugin source code available to lean on an existing sructure?

Thank you in advance!

Hansjoerg

It works with Rhino 8, but we’ll need to set the .NET runtime to .NETFramework using the SetDotNetRuntime command.