Grasshopper

algorithmic modeling for Rhino

MRhinoScriptCommand command; //unassugend ?
command.RunCommand(???); //command context ?

or use

public IRhinoCommand::result RunCommand(ref IRhinoCommandContext context);

How can I assign or call command from C# script in Grasshopper?

Any idea how can I create for each Rhino polyline a separate dxf file?

Thanks.

Views: 4619

Replies to This Discussion

easy..
app.RunScript("_loft");
For exporting to DXF, simply select the geometry you want to export and run a command like:

"-_Export ""C:\BlahBlahBlah\MehMehMeh\YadaYadaYada\file.dxf"" _Enter"

Many export flavours have additional options which you should also include in the command string.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Yes, that's it, thanks! It's funny use "string""in side""string" :) Meh Meh ;)

But I have a problem with select object geometry in Rhino.

I have a List of many curves in grasshopper and I want to select different curves in Rhino.
like: App.SellObj(listOfCurves[i])
But first I must Bake it to the Rhino and after select it.

Must you bake and select object to export it? How? :)
Thanks a lot.
Yes, Rhino can only export geometry it is aware of, thus you do need to bake it first. Then you need to make sure the curves are selected (and nothing else is) and finally, after exporting, you should delete the curves again.

You can add curves with doc.AddCurveObject(), inside a VB component. See the following snippet:

Dim crv_obj As MRhinoCurveObject = doc.AddCurveObject(x)
crv_obj.Select(True, True, True)

app.RunScript("-_Export ""C:\output.dxf"" _Enter")
doc.DeleteObject(New MRhinoObjRef(crv_obj))

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Great, Thanks! :) Easy and nice.

Here is my test script..
Attachments:
Hi Kurilla,

I could´t open your definition, something seems to be wrong. Could you please post the code to try it out?

Thanks.
Sorry.
I wrote it in 6.0049 , now I save it to 6.0055 version of grasshopper file.

Here is a part of code in C#:

//filePath external input string
if(filePath == null || filePath == String.Empty)
{
//Save to the curent document location
filePath = doc.GetPathName();

//If document is not saved
if(filePath == String.Empty)
{
//Save to the desktop
filePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
}
}
//export external input bool
if(export)
{
for(int i = 0; i < curves.Count;i++)
{
string savedLocation = filePath + "\\ file_" + i + ".dxf";
doc.UnselectAll();
MRhinoCurveObject crv_obj = doc.AddCurveObject(curves[i]);
crv_obj.Select(true, true, true);
app.RunScript("-_Export \n\"" + savedLocation + "\"\n _Enter", 0);
}
}

I hope it'll work and help you.
Attachments:

But How Can I find the decleare of the parameter "doc"?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service