RhinoScriptSyntax Vs rhinocommon

Can someone validate that I am correct in saying that RhinoScriptSyntax is a subset of rhinocommon ?

Thanks

Paul

Sort of, rhinoscriptsyntax is an IronPython module that implements/wraps parts of the .NET RhinoCommon API (and is intended for use with the Rhino document, and hence largely operates on GUIDs).

Oh I see. So all those functions are just some cherry picked methods from the rhinocommon geometry classes ?

Hi @cottonbale,

The rhinoscriptsyntax library, which is written in Python, is meant to provide the same funcationality as RhinoScript (VB) , so as to ease the transition from one scripting language to to the other.

– Dale

1 Like

Hi Dale,

That makes sense but why is it all just function calls? It seems odd that you are prevented from seeing the whole class. Was that just how scripting was done back in the day?

RhinoScript is just a bunch of functions - no class hierarchy.

– Dale

Ok, thanks Dale.

Given that I’m ultimately going to have to write c# or python scripts within grasshopper should I dispense with this foray into scripting and address the grasshopper channel instead ? Also, since GH is a rhinocommon application I suppose it’s likely that everything pertaining to GH scripting or plugins is going to be rhinocommon centric ?

Yes to both your questions/comments.

– Dale

Hi Dale

Is there a difference in processing time when working with rhinoscript or rhinocommom?

Pasini

Hello,

Well-written rhinocommon code will almost always be faster computationally. Whether that difference is significant for your use case is another matter and depends very much on what functions you are using on how many of what type of objects. The ease of writing, debugging and updating rhinoscriptsyntax may be much more valuable to you than computation time.

Rhinoscriptsyntax is all written in rhinocommon and if you are chaining multiple operations together then each rhinoscriptsyntax function may repeat some operations, getting a guid identifier for the object, doing some checks, carrying out the operation and then applying the identifier to the new or modified object where in rhinocommon you could just do the operations you want, possibly carrying out the checks once rather than multiple times.

This tool will help you find the underlying source code for a rhinoscriptsyntax function :snake:

-Graham

1 Like

I need to know which triangles are neighbors of the sample triangle. The mesh in question has 300,000 faces.
I’m currently using:
rs.MeshFaceVertices / rs.MeshVertexFaces
I wonder if there is a method to make this faster.

import rhinoscriptsyntax as rs
import Rhino
import time


meshID = rs.GetObject()
ini = time.time()
mesh = rs.coercemesh(meshID)
lst = []
for i in range(0, 99000):
	lst.append(mesh.Faces.AdjacentFaces(i))

print lst
print time.time() - ini

Very fast !!!

Just so you know, it is also possible to use Python with C++. In C++ you have access to the Rhino C++ SDK which provides most of the capability of Rhinocommon. I do this when I need better performance. The meshes I deal with have 100,000,000 faces and what takes minutes with Rhinocommon in Python is done in seconds in my Python/C++ scripts. It is much more difficult to program in C++ so what I typically do is get everything working in Python and then move the time critical portions to procedures in C++.

My hybrid Python/C++ scripts let me rip thru data at like 3GB/sec so I can do things like color a 227Mpts pointcloud in 0.25 sec. The cloud contains 13.5 GB of data in total of which 908MB is color data. So the colors are added at 3.6GB/sec. Unfortunately another 9 sec is needed before Rhino will show the change in the view. It makes me wonder if the multi-dimensional parallelism I am using in the cloud could be applied to the display pipeline for this simple case? Is that code available?

Building a Python/C++ script uses the same basic steps as creating a Rhino Plugin. I can provide more details if you are interested.

These days I am in 7th heaven developing Python/C++ scripts for working with my meshes and pointclouds. So much fun and so fast. The biggest limitation is Rhino’s display capabilities; 100M faces meshes and 227 Mpts pointclouds are slow to update in the view and slow to rotate once visible. I wonder if there are optimization I could apply to these steps.

In any case, do not limit your thinking to tiny 0.3M faces meshes when writing scripts. If you want to go 100X bigger, you can.

Regards,
Terry.

3 Likes

Yes, I’m interested. If you can guide me in that direction I would be very grateful.

Thank you

My Python/C++ scripts run on a computer using Windows 10. I do not know how to build the equivalent to a DLL for an Apple Mac. Do you have a windows machine?

Regards,
Terry.

My plugins run on a windows machine.

Thanks

I installed Visual Studio but was unable to use it.
I have no knowledge of C ++.
I have some knowledge in JAVA.

You are at a good starting point. I will now go collect my notes on how I got this to work 3 years ago and make sure I can get it to work on a new project in Visual Studio 2017 (recommended version for plugin development.

How do you currently make plugins?

In Python Rhino Editor
Then I compile with RhinoScript Compiler.
Everything is very basic.
I wanted to migrate to a better editor, like Atom. But I’m also not sure if it works.

Possible, probably, but really, really, neckbeard-ishly difficult. :wink:
I wish I’d have the time and intellect to understand how to do this. :smiley:

Isn’t Java really similar to C++? Or are you talking about Javascript?

PyCharm is really neat for Python - probably as good as it gets -, but it’s not free.