I am new to Rhino and am interested in producing a Macro/Script/Addin for the export of a complete model or individually selected sketches to a 3rd party Cam product for the production of cnc (G-Code) programs. Ideally it would be preferable to pass filenames (.STEP type for 3d model and .xml type for sketches) as command line parameters to the Cam software but if this is not possible the files could be written to a central location for reading by Cam on launch. I am a programmer of 40+ years experience and feel confident in use of scripting or API tools.
Any hints or pointers on the easiest/smartest method of achieving the above would be appreciated.
i recommend c# plug-in for the workflow you describe.
note that not all file formats can be exported by pure API-Commands.
but you can do everything that is possible in the rhino-command-line (âmacroâ) by using a script-runner commandâŚ
Not really sure what you want to do, but if you just want to export .step files and call an executable with a given set of parameters, you should also be able to to that in python using the pythonscripteditor in rhino.
pseudocode would be something like this
import rhinoscriptsyntax as rs
import os
objs = rs.GetObjects()
for obj in objs:
name = rs.ObjectName(obj)
rs.UnselectObjects(objs)
rs.SelectObject(obj)
rs.RunCommand("-export -name - further options etc")
os.system("C:\LocationofCAM\cam.exe -command line parameters")
In addition to all resources suggested by others:
Do not hesitate to keep asking questions on this forum when you get stuck. This is a community generous with help.
Thanks to all for your contributions, I think I have got myself a starting point.
Initially my objective is to be able to select an object and export it as a Step/Iges file then pass the filename as a command line argument to our Cam package with a view to producing a CNC (G-Code) program for subsequent machining. In the longer term the aim is to extract 2D sectional contours in addition to full 3d models for subsequent machining.
I have been able to build a plugin and execute it from the Command prompt. Now I am look at writing the files for the model to be exported. I have found Rhino.FileIO.FileStp which I am guessing will write STEP files, is there an equivalent object which covers Iges files.
Iâd love to see your workflow somehow and see what you are doing - if you could take screen shots or something⌠Iâm curious if I could use what youâre doing in my practice. Thanks,
I am a partner in a small independent Cad Cam (mainly Cam) software company, I have been in the business since 1977 and a partner in Dolphin Cad Cam systems Ltd (www.dolphincadcam.com) since 1989, we are a small team and have worked together since 1980. We have many loyal Clients worldwide and focus on software for production of CNC (G-code) programs for machining purposes (Mill/Turn/EDM applications). For many years we have been asked to provide quick links from 3D Cad such as Rhino. Our two main Cam platforms can currently import Iges & STEP files with my current task being to develop a Rhino plugin which will export a file in the selected format and execute our Cam software while passing the name of the exported file as a execution command line argument. The plugin is now basically functional (see image below of dialogue box), what I now need to do as add the code which will export the file and execute the cam software when the Client selects the âExport Modelâ button.
So far building the basic plugin (.Net with RhinoCommon) has been straightforward and my next step is to locate the methods for exporting the current model in the desired format.
Almost within touching distance, I think I am invoking the RhinoApp.RunScript(script,boolean) method but have got the following issues -
If I set the boolean = True the command line flashes on screen but it is to fast to be able to read it.
I cannot find any definitions of the script string format for VB, see snippet from screen where I am echoing the value of script string to the screen (using RhinoApp.WriteLine(script) -
Is there any documentation available showing examples of script string contents for vb.
vb code to invoke RunScript and echo script string to screen -
The contents of script are being echoed to the screen via RhinoApp.Writeline -
See code of call to RunScript -
'
' Write script string to app info
RhinoApp.WriteLine(str_script, EnglishName)
' execute script
exp_result = RhinoApp.RunScript(str_script, True)
' check if .igs file exists
Dim b_exists As Boolean = File.Exists(str_docfile)
MsgBox("Script returned result :- " & exp_result.ToString & vbCrLf & "Does .igs exist :- " & b_exists)
'
'
See results from plugin after execution -
(The result of plugin is false and .igs file is shown not to exist)
If I cut/paste the Script string into the command line the file name is rejected but the export op commences -
(see 'Unknown command message)
What I wish to do is to export the total current object as a .igs file (without User intervention by way of selection) and then invoke a 3rd program with the file name embedded in the command line.