Rhino.Inside Revit

Hi @d.c.segraves,

Wee need to update that section, EnqueueAction is no more available.
Here an updated sample

using System;
using System.Collections;
using System.Collections.Generic;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

using RhinoInside.Revit;
using RhinoInside.Revit.Convert.Geometry;
using DB = Autodesk.Revit.DB;

/// <summary>
/// This class will be instantiated on demand by the Script component.
/// </summary>
public class Script_Instance : GH_ScriptInstance
{
  /// <summary>
  /// This procedure contains the user code. Input parameters are provided as regular arguments,
  /// Output parameters as ref arguments. You don't have to assign output parameters,
  /// they will have a default value.
  /// </summary>
  private void RunScript(bool Trigger, double Radius, ref object Sphere)
  {
    if(Trigger == false) return;
    if(Radius < Revit.VertexTolerance * 10.0) return;

    var doc = Revit.ActiveDBDocument;
    using(var tx = new DB.Transaction(doc, Component.NickName))
    {
      tx.Start();
      Sphere = CreateSphere(doc, Radius);
      tx.Commit();
    }
  }

  // <Custom additional code> 
  private DB.DirectShape CreateSphere(DB.Document doc, double radius)
  {
    var sphere = new Rhino.Geometry.Sphere(Rhino.Geometry.Point3d.Origin, radius);
    var brep = sphere.ToBrep();

    var revitCategory = new DB.ElementId((int) DB.BuiltInCategory.OST_GenericModel);

    var ds = DB.DirectShape.CreateElement(doc, revitCategory);
    var shapeList = new List<DB.GeometryObject>() { brep.ToSolid() };
    ds.AppendShape(shapeList);
    return ds;
  }
  // </Custom additional code> 
}
2 Likes