Hi guys,
I have a BackgroundWorker where I want for example save a Surface. Because it’s running in a second thread I have to define the “saving-process” in the main-thread and there is my problem. I want to pass a Surface as a Parameter to the Invoke-method, but I’m totally stuck.
Have someone an idea, how I have to do it?
Thanks in advance!!
fred
here is a snippet of my script:
//Parameter
Surface ExportA;
//defining a new Action<T>-Delagate
Action<Surface> action = new Action<Surface>(ExportDialog);
//puting the method in the main thread
RhinoApp.MainApplicationWindow.Invoke(action(ExportA));
//Method to Export the Geometry in .sat
public static void ExportDialog(Surface ExportA)
{
//-------------------------------
//Export Surface in .sat-format
string filePathSat = "M:\\...";
Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes();
att.ColorSource = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
att.ObjectColor = Color.Blue;
att.LayerIndex = Rhino.RhinoDoc.ActiveDoc.Layers.Find("myLayer", false);
Rhino.RhinoDoc.ActiveDoc.Objects.AddSurface(ExportA, att);
string xy = "Default";
Rhino.DocObjects.RhinoObject[] rhobjs = Rhino.RhinoDoc.ActiveDoc.Objects.FindByLayer(xy);
for (int l = 0; l < rhobjs.Length; l++)
rhobjs[l].Select(true);
string savedLocationSat = filePathSat;
Rhino.RhinoApp.RunScript("-_Export \n\"" + savedLocationSat + "\"\n _Enter", true);
System.Threading.Thread.Sleep(1000);
//Delete Baked Geometry
for(int l = 0; l < rhobjs.Length; l++)
{
Rhino.RhinoDoc.ActiveDoc.Objects.Delete(rhobjs[l], false);
}