Is there an API or SDK for VisualARQ?

Yes, from 2.4 version VisualARQ has an API accessible from RhinoCommon (C#, VB.NET, Python).

Some of its methods allow to work with:

  • Common Style operations (rename, delete, etc)
  • Parameters
  • Wall and Wall Styles
  • Element and Element Styles
  • Furniture and Furniture Styles
  • Beam and Beam Styles
  • Column and Column Styles
  • Door and Door Styles
  • Window and Window Styles

This API has been created to work with document resident objects (create, edit, modify and delete) using their object ID.

To use the API, reference the VisualARQ.Script.dll assembly that is installed with VisualARQ. You’ll find it next to Rhino.exe, usually in C:\Program Files\Rhino 6\System. Once referenced in your project you can call any of its methods.

If VisualARQ is not yet loaded, the assembly will take care of any initialization needed on the first call to one of its methods.


From a Rhino C# plug-in

Create a Rhino C# plug-in and use the API as RhinoCommon or any other .NET assembly in the project.

Here is a sample code of a command that creates a generic element style, inserts an element with that style, and finally creates a document parameter and sets a value to this parameter on the element.


using System;
using System.Collections.Generic;
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
using Rhino.Input;
using Rhino.Input.Custom;
using va = VisualARQ.Script;

namespace VisualARQ
{
   public class VaScriptSampleCommand : Command
   {
      public VaScriptSampleCommand()
      {
         // Rhino only creates one instance of each command class defined in a
         // plug-in, so it is safe to store a refence in a static property.
         Instance = this;
      }

      ///<summary>The only instance of this command.</summary>
      public static VaScriptSampleCommand Instance
      {
         get; private set;
      }

      ///<returns>The command name as it appears on the Rhino command line.</returns>
      public override string EnglishName
      {
         get { return "ScriptSampleCommand"; }
      }

      protected override Result RunCommand(RhinoDoc doc, RunMode mode)
      {
         // Get units scale factor from meters to document units
         double unitScale = RhinoMath.UnitScale(UnitSystem.Meters, doc.ModelUnitSystem);

         // Create a block with a sphere as model representation
         var sphere = Brep.CreateFromSphere(new Sphere(Point3d.Origin, 1.0 * unitScale));
         doc.InstanceDefinitions.Add("Sphere", string.Empty, Point3d.Origin, new[] { sphere });

         // Create a block with a circle as plan representation
         var circle = new ArcCurve(new Circle(Point3d.Origin, 1.0 * unitScale));
         var idefIndex = doc.InstanceDefinitions.Add("Circle", string.Empty, Point3d.Origin, new[] { circle });

         // Create a VisualARQ Generic Element Style
         var styleId = va.AddGenericElementStyle("Sphere", new List<string>() { "Sphere" }, new List<string>() { "Circle" });

         // Insert VisualARQ Generic Element
         var elementId = va.AddGenericElement(styleId, new Point3d(1.0, 1.0, 1.0), 2.0);

         // Change Element position
         Point3d pos = va.GetGenericElementPosition(elementId);
         va.SetGenericElementPosition(elementId, pos + new Vector3d(2.0, 2.0, -2.0));

         // Create a document parameter "price"
         var priceId = va.AddDocumentParameter("Price", va.ParameterType.Currency, "Costs");

         // Set "Price" value to element
         va.SetParameterValue(priceId, elementId, 100.0);

         return Result.Success;
      }
   }
}


From the RhinoPythonScript Editor

This is an example of how to use it from the integrated Rhino Python Script Editor to create a script that adds a parameter to all the beam styles:


From Grasshopper

If you plan to use the API from any of the Grasshopper scripting components take into account that it is not recommended to use this API in Grasshopper.

The reason is that the VisualARQ Script API is intended to be used with document resident objects, while Grasshopper works with in-memory (temporary) geometry-only objects. This means that if for example you manipulate the geometry of a VisualARQ object, it will create a new object each time you change a value.

Support for Grasshopper scripting may be added in the future.

Note

VisualARQ Script API is still in WIP. Not all features are exposed yet, neither there is documentation.

If you need a method that is missing contact us: visualarq@asuni.com.