Grasshopper

algorithmic modeling for Rhino

I want to display some text or the value of a variable with a panel during the runtime of a script, just to check if my script is correct.

I tried Console.WriteLine("some text") and connected a panel to the out-parameter but it's not working.

BTW If someone knows some C# tutorials for grasshopper!!! it would be nice, because all I could find are tutorials for compiler.

Views: 3945

Replies to This Discussion

try Print("some string"); to write to the "out" parameter.

"...during the runtime of a script..."


That's a bad idea. While the script is running the Rhino and Grasshopper interfaces are not updating. If you start updating the interface not only will that massively slow down the process, it will also result in all kinds of weird visuals as a lot of data is 'in limbo'.


If you must display something while the script is running, I recommend creating a new window and updating that. I can't actually type C# code now because I've broken the script editor, but try something like the following:


Form feedbackForm = new Form();
feedbackForm.FormBorderStyle = FormBorderStyle.FixedToolWindow;
feedbackForm.Width = 300;
feedbackForm.Height = 150;
feedbackForm.TopMost = true;

Label feedbackLabel = new Label();
feedbackLabel.AutoSize = false;
feedbackLabel.Dock = DockStyle.Fill;
feedbackLabel.Text = "<feedback>";

feedbackForm.Controls.Add(feedbackLabel);
feedbackForm.Show();

//Perform script code, this should take a long time.
{
  feedbackLabel.Text = "new feedback";
  feedbackLabel.Refresh();
}

//When you're done with the script, destroy the feedbackform
feedbackForm.Hide();
feedbackForm.Dispose();

Does that approach work?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service