Grasshopper

algorithmic modeling for Rhino

Hi all,

How does one find out the parameter ID's in grasshopper? I am writing a simple console program in C# to externally run Grasshopper. I would like to use the AssignDataToParameter() function. Not sure where I find the parameterID.

Thanks,

Don

Views: 1574

Replies to This Discussion

The ParameterID is the InstanceGuid of any instance of IGH_Param. The ID doesn't change unless a parameter is moved into another document (for example during Insert or Paste), so if you're accessing a specific parameter in a known file, you can always use the same ID.

The easiest way to find the ID of a parameter is to copy it into the clipboard, then paste the resulting xml into a text editor and search for this line:

<item name="InstanceGuid" type_name="gh_guid" type_code="9">7d07a00a-382c-457b-abeb-b3ad14acdefe</item>

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks David.

Don

David,

Could you explain how the 'BakeDataInObject(objectID As String)' works? Is the object id a target in Rhino? Also, Is there a way to specify the InstanceGuid in order to select the geometry component your wish to bake?

Thanks,

Don

The objectID is either a parameter or a component InstanceGuid.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

This is a example how to generate a node in grasshopper and put the datastructure into that node. ( a text node) A Grasshopper file has to be opened in this case. This is a starting point for your task to execute grasshopper externaly. Have fun.

namespace RunTimeCompiler
{
    ///<summary>
    /// This is the new scripting enviroment
    /// have fun to use it as you want.....
    ///</summary>
    public class ExecuteClass
    {
        public static void RunScript(ref Rhino.Display.CustomDisplay preview)
        {
            /// code comes here
            /// ----->
 Grasshopper.Kernel.GH_ComponentServer com_serv = Grasshopper.GH_InstanceServer.ComponentServer;
    GH_Document doc = Grasshopper.GH_InstanceServer.ActiveCanvas.Document;
    Grasshopper.GUI.GH_DocumentEditor com_edit = Grasshopper.GH_InstanceServer.DocumentEditor;

    IGH_DocumentObject remoteObject = GH_InstanceServer.ComponentServer.EmitObject(new System.Guid("3EDE854E-C753-40eb-84CB-B48008F14FD4"));
    if (remoteObject == null)
    {
      return;
    }
    remoteObject.CreateAttributes();
    remoteObject.NewInstanceGuid();
    remoteObject.Attributes.Selected = false;
    PointF pivot = new PointF(1f, 1f);
    remoteObject.Attributes.Pivot = pivot;

    remoteObject.NickName = "ICS_generated";
    Grasshopper.Kernel.Parameters.Param_String linear_dim = (Grasshopper.Kernel.Parameters.Param_String)remoteObject;
           // linear_dim.AddPersistentData(new GH_String("hallo"));

    
   doc.AddObject(remoteObject, false, 2147483647);

   
    GH_IO.Serialization.GH_Archive my_archive = new GH_IO.Serialization.GH_Archive();
    my_archive.AppendObject(doc, "Definition");
   // linear_dim.Params.Input[1].AddVolatileData(new GH_Path(), 0,new GH_String(my_archive.Serialize_Xml()));
    linear_dim.AddPersistentData(my_archive.Serialize_Xml());
    linear_dim.ExpireSolution(true);
    linear_dim.ExpirePreview(true);
    doc.ExpirePreview(true);
    doc.NewSolution(true, GH_SolutionMode.Silent);
            /// <-----
            /// code endes here
        }
    }

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service