algorithmic modeling for Rhino
Hi everyone,
Lets say i have 3 lines in grasshopper, and i want to export these lines sequentially as a .ai file type, does anyone have any idea how to go about writing a C# script that will write a file to a folder?
Really what i need to firgure out is how to directly save a line (in this example) to a file without having to bake it to rhino first.
what im trying to do is write a code that will save a series of lines (more than 3, in reality more like 300) in order. normally i would just bake the lines and use export selected directly from rhino, but in this instance the order in witch they are saved is important. Im trying to avoid having to manually export them one by one from rhino.
Thanks in adavance
M
Tags:
Unless you have code that can write AI files, you'll have to bake the geometry first and then invoke the Rhino exporter. This can however all be automated via C#, though it isn't pretty. Still interested?
if you've got the time, Ive got the patience. Honestly i only said ".ai" to drive the point across that im not trying to save a .3dm file. Honestly i need to save as a file type that will load vector data in to processing.
In that case may I suggest using a Text Panel and simply streaming a text file? You can format your data any way you want using regular Grasshopper components, then plug the text into a panel and stream it to some file.
If you want to automate the filename, then it's trivial to make a small C# component which writes files.
Here's a small example of what david suggested:
private void RunScript(Line ln, ref object A)
{
A = String.Format("{0},{1},{2},{3}", ln.From.X, ln.From.Y, ln.To.X, ln.To.Y);
}
If you stream the contents to e.g. d:\test.csv
To draw in processing should be something like this (untested code, I don't have processing at this moment):
Table table = loadTable("D:\test.csv");
println(table.getRowCount() + " total rows in table");
for (TableRow row : table.rows()) {
line(row.GetFloat(0),row.GetFloat(1),row.GetFloat(2),row.GetFloat(3));
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by