However, how do I get anything useful from that code? I found several samples showing basically only accessing plug-ins, but I need to know something useful, like points, layers, windows, etc.
I was hoping to be “using Rhino” via the RhinoCommon, but I can’t seem to recast the Rhino5x64Application into a usable RhinoApp.
So, my questions are, can I recast Rhino5x64Application to RhinoApp (or equivalent) and if yes, how?
If not, how can I make a C# console app (or script from any external program) that will find/create a session of Rhino and allow me access to the RhinoApp functionality?
(Side note: I can’t make another plug-in that will be installed in Rhino, then run that from my Rhino5x64Application, because I can’t rely on my clients to ensure they will install that plug-in prior to running my exe.)
You can create an installer (for example using MSI) that will install your executable, but also create registry entries for one or more plug-ins. The next time when Rhino starts, the plug-in will be loaded, even if Rhino is started using COM interop. So, it should be possible to have 1) your executable and 2) a plug-in in Rhino that is loaded when your executable is installed.
“…it should be possible to have … 2) a plug-in in Rhino that is loaded when your executable is installed.”
“Rhino should subsequently load the plug-in.”
Just a reminder, I’m not trying to develop a Rhino plug-in. Ultimately, the goal is to run this from a different application (CATIA) but I’m just using a console app to simplify and separate the coding.
I think it comes down to what you want to do. If you could give some more info on that it can help.
For example, part of Rhino’s functionality is available as open source (based on OpenNURBS). If this functionality is sufficient, you could just use the NuGet package of Rhino3dmIO and don’t bother about COM or RhinoCommon at all. https://www.nuget.org/packages?q=3dm
On the other hand, using COM you can send any scripted command to Rhino. As virtually all commands are scriptable, Rhino functionality is exposed in that way. And, again, using a plug-in on Rhino side to accept one command, or plugin object, through COM from CATIA seems like a possible solution to me.
I’m trying to take an exported folder of IGS files, Import them one at at time in Rhino, search thru the geometry in Rhino, delete any surfaces that fall into a series of conditions I have, then export the remaining geometry into a SAT file format.
For the time being, I’m parallel coding my CATIA stuff in C# in a different VS2010 session. That’s going fine. But the Rhino development is new-ish to me (I used to use Rhino all the time years and years ago). I assumed COM access to RhinoApp would be easy, but I’m finding it hard to do. I’ve been able to open Rhino easily, but then using that for something isn’t working. I noticed that when i load the RhinoCommon reference and set up the “using” declaration, it formats fine. But whenever I code a line, it always says that I can’t use RhinoApp types as a static variable, which is fine, but if I can’t create an instance of Rhino, then what can I do with it?
Have you considered not doing this from CATIA, but just letting the user open Rhino, load the files, then run some commands from a Rhino plug-in that you make to identify the required IGES geometry, then save the that to Acis SAT files?
These actions could, at a later stage, be automated from CATIA over COM using SendScript functionality. But that is purely optional - not a design choice made at the start.
I honestly don’t want the client to even know Rhino is running. I plan to comment out the visibility function once I’m done with this.
I’ve found a workaround that should be ok for now, which uses the Rhino5x64Application method named “RunScript.” It’s basically the RVB equivalent of StartCommand (I think that’s Rhino’s method for sending text to the command line, from memory.)
I’ll just translate the IGS in via a transparent Import string via the command line in Rhino, then translate it immediately back out into SAT. I’ll have to do the conditionals on the geometry in CATIA prior to the IGS export, but it’s slower than Rhino, so I’m bummed out.
But this looks like a quick way to make this work. I assume I can still send strings to the command line via the method RunScript with the application visibility set to false, right?
I’d love to access the RhinoScript library, but when I include it with my references, I’m unable to create an instance of anything in the RhinoScript namespace.
Do you have a code that transfers the newly opened Rhino application via System.Activator.CreateInstance(type) into something that will create an instance of something from the RhinoScript library?
You cannot use System.Activator.CreateInstance to create an instance of the RhinoScript object but the object is dependent on Rhino. Thus, Rhino is the only thing that can create an instance of this object.
I figured. But hey, the RunScript thing worked well. It’s not a permanent solution, but with a small 1 second pause between commands, it converted the SAT files from the IGS directory without issue. It worked on even crazy surfaces, and it was run from CATIA. woohoo.
The rhino session stayed invisible, so the user won’t even know what is happening.
One thing though, I couldn’t figure out how to make the “-Exit” command transparent. It always wanted to ask me if I wanted to save changes. I got around it by making two preceding steps (deleting all, then savingAs dummy.3dm), then it would exit without issue. But that was the only real hiccup.
thanks for all your help. Good to know in the future that Rhino5x64Application can only use RunScript, and accessing RhinoApp or RhinoScript is only possible thru the application. Kind of a bummer though. Revit is doing the same thing with their program. Seems like COM functionality is gradually being phased out… at least CATIA is holding on to it for now.
Thanks, I knew about DocumentModified, but I couldn’t access it from the Rhino5x64Application type. Is there an equivalent to DocumentModified that could be typed into the command line in Rhino?