I have a slider (range .001-1.00) that animates a simulation in GH. I am trying to incorporate a boolean that can stop and play the simulation. ‘Trigger’ is unsuccessful because I need to loop back to .001 to restart once it is complete.
something like this ?
mini_animation_00.gh (16.7 KB)
not sure if there is a great way without scripting. My approach is to use ScheduleSolution - and I am also not sure if this is the best approach.
// ...
GrasshopperDocument.ScheduleSolution(interval, ScheduleSolutionCallback);
// ...
public void ScheduleSolutionCallback(GH_Document doc)
{
Component.ExpireSolution(false);
}
Hi @Samantha_Garza1
script ---Rhino code pluginGH
is new features in Rhino8 (grasshopper)
Maybee you open this in Rhino 7?
For fix error the code must bee make by old C# Component for Rhin7
Hi, can you supply full code? I can’t open this because I have rhino 7.
// Grasshopper Script Instance
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using Rhino;
using Rhino.Geometry;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;
public class Script_Instance : GH_ScriptInstance
{
/*
Members:
RhinoDoc RhinoDocument
GH_Document GrasshopperDocument
IGH_Component Component
int Iteration
Methods (Virtual & overridable):
Print(string text)
Print(string format, params object[] args)
Reflect(object obj)
Reflect(object obj, string method_name)
*/
double count;
double direction = 1.0;
private void RunScript(
bool reset,
bool running,
double start,
double end,
double step,
int interval,
ref object a)
{
// minimal error handling
if (end < start || step < 0.0)
{
a = null;
Component.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "bad value for end, start, step");
return;
}
if (reset)
{
count = start;
direction = 1.0;
} else {
if (running)
{
count += (step * direction);
if (count < start || count > end)
{
direction *= -1.0;
}
GrasshopperDocument.ScheduleSolution(interval, ScheduleSolutionCallback);
}
}
a = count;
}
public void ScheduleSolutionCallback(GH_Document doc)
{
Component.ExpireSolution(false);
}
}
Thank you, I have tried to copy the code into a c# component for rhino 7, however I have been unsuccessful. Any suggestions?
hi @Samantha_Garza1
I Convert it to c# Component for Rhino7
enjoy it
R7–Animation—.gh (12.7 KB)