algorithmic modeling for Rhino
See attached!
You can take as a reference!
Works fine here!
No any error were found!
Sorry for insisting, but i just tried it again and dont know what is going wrong.
i just dont get any output it seems the views were imported well, there is just no image in the specified folder.
Did you get an image saved?
Thanks!
thanks! i think i got it. i think my confused came from the missing step to restore the view, i thought it already would hapen, so thats t¡why it worked just for the first when and just when it was selected.
Many thanks for all you help!
Hi Chapulin,
Add a variable x as string for the view name and try the following code:
if (!run) return;
Rhino.DocObjects.Tables.NamedViewTable viewTable = doc.NamedViews;
List<Rhino.DocObjects.ViewInfo> viewList = viewTable.ToList();for (int i = 0; i < viewList.Count; i++)
{string vn = x;
Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
Rhino.Display.RhinoView view = RhinoDocument.Views.Find(vn, false);if (view == null)
{
Print("you are not pointing to the right view");
return;
}string fileName = string.Format("{0}\\{1}." + format, filePath, vn);
Rhino.Display.DisplayModeDescription displaymode = Rhino.Display.DisplayModeDescription.FindByName(displayMode);
Bitmap image = view.CaptureToBitmap(new Size(width, height), displaymode);
if (image == null)
return;
image.Save(fileName);
image.Dispose();
}
A = viewTable;
The view variable returns a null if you don't have this view as current in your rhino document.
Hope this makes sense.
Best
M
hi, thanks Marios!
this helps me to know that vn returns null. But how to fix this? I dont really understand the problem still.when it says:"you are not pointing to the right view"
you mean i need to set the viewport by hand?As in myprevious post, for example vn is recognized but there is no output.
I thought cause i have in my viewList various items i can iterate over setting it active and saving it.
Maybe you are so kind to help me explaining how do i need to setup the rhino or better how to fix the script?
thanks!
Hi Chapulin,
The following should work
private void RunScript(string folder, int imagecount, string view, bool export, ref object A)
{
if (!export)
{
imageNumber = 0;
return;
}
else
{
if( imageNumber < imagecount)
capture_frame(folder, imageNumber, view);
imageNumber++;
}
}// <Custom additional code>
private int imageNumber = 0;
private void capture_frame(string _folder, int imageNumber, string v)
{
//redraw
Rhino.RhinoDoc.ActiveDoc.Views.Redraw();//get the index of the named view
int view0 = Rhino.RhinoDoc.ActiveDoc.NamedViews.FindByName(v);//get the active view
Rhino.Display.RhinoView view = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView;
//restore your named view to the active view
Rhino.RhinoDoc.ActiveDoc.NamedViews.Restore(view0, view, false);//double check that it works properly
if (view == null)
{
Print("You are not pointing to the selected view");
return;
}//exp[ort the current view
string fileName = string.Format("{0}\\{1}.png", _folder, imageNumber);
imageNumber++;
Bitmap image = view.CaptureToBitmap();
if (image == null)
{
Print("NO Image was created");
return;
}
image.Save(fileName);
image.Dispose();
}
Best,
M
Hey Marios,
thanks a lot costs me an hour more to make it work,your help is really appreciated!
You showed me exactly what i needed, so weekend can begin,hehe!
regards!
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by