VisualARQ API

Hi @lando.schumpich,

We’re currently working on the documentation and samples for the new VisualARQ Script API, but nothing is public yet.

VisualARQ Script API is currently only accessible from RhinoCommon (C#, VB.NET, Python), but new version will allow to access this API from C++ and RhinoScript.

VisualARQ Script API is still in WIP, and not all features are still exposed in the API. VisualARQ 2.4 has methods to work with:

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

VisualARQ 2.5 will include more objects in the API. If you need any method in particular, just ask for it and I’ll try to include it in the next release. I’m currently working in all Beam/Column/Door/Window methods.

To use the API, just 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. This API has been created to work with document resident objects (create, edit, modify and delete) using their object ID. All methods are members of an static class VisualARQ.Script. In order to use the API, you don’t need to do anything in particular, just call any method. If VisualARQ is not yet loaded, the assembly will take care of any initialization needed on the first VisualARQ Script call.

Here is a sample code using the API:

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 3D sphere as mnodel 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 2D rectangle as plan representation
            var retangle = new ArcCurve(new Circle(Point3d.Origin, 1.0 * unitScale));
            var idefIndex = doc.InstanceDefinitions.Add("Circle", string.Empty, Point3d.Origin, new[] { retangle });
            
            // 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;
        }
    }
}

Let me know if you have any doubts or issues using the API.

Regards,

Enric

4 Likes