public static Rhino.Commands.Result BlockInsertionPoint(Rhino.RhinoDoc doc)
    {
        Rhino.DocObjects.ObjRef objref;
        Result rc = Rhino.Input.RhinoGet.GetOneObject("Select instance", true, Rhino.DocObjects.ObjectType.InstanceReference, out objref);

        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }
        Rhino.DocObjects.InstanceObject instance = objref.Object() as Rhino.DocObjects.InstanceObject;
        if (instance != null)
        {
            Rhino.Geometry.Point3d pt = instance.InsertionPoint;
            doc.Objects.AddPoint(pt);
            doc.Views.Redraw();
        }
        return(Rhino.Commands.Result.Success);
    }
Beispiel #2
0
        /// <summary>
        /// Gets a list of the CRhinoInstanceObjects (inserts) that contains
        /// a reference this instance definition.
        /// </summary>
        /// <param name="wheretoLook">
        /// <para>0 = get top level references in active document.</para>
        /// <para>1 = get top level and nested references in active document.</para>
        /// <para>2 = check for references from other instance definitions.</para>
        /// </param>
        /// <returns>An array of instance objects. The returned array can be empty, but not null.</returns>
        public InstanceObject[] GetReferences(int wheretoLook)
        {
            int refCount = UnsafeNativeMethods.CRhinoInstanceDefintition_GetReferences1(m_doc.m_docId, m_index, wheretoLook);

            if (refCount < 1)
            {
                return(new InstanceObject[0]);
            }
            InstanceObject[] rc = new InstanceObject[refCount];
            for (int i = 0; i < refCount; i++)
            {
                IntPtr ptr = UnsafeNativeMethods.CRhinoInstanceDefinition_GetReferences2(i);
                if (ptr != IntPtr.Zero)
                {
                    uint sn = UnsafeNativeMethods.CRhinoObject_RuntimeSN(ptr);
                    rc[i] = new InstanceObject(sn);
                }
            }
            UnsafeNativeMethods.CRhinoInstanceDefinition_GetReferences3();
            return(rc);
        }
Beispiel #3
0
        // Rhino convention seems to order the origin of the vector space last instead of first
        // This results in a transposed transformation matrix - may need to be addressed later
        public BlockInstance BlockInstanceToSpeckle(RH.InstanceObject instance)
        {
            var t = instance.InstanceXform;
            var transformArray = new double[] {
                t.M00, t.M01, t.M02, t.M03,
                t.M10, t.M11, t.M12, t.M13,
                t.M20, t.M21, t.M22, t.M23,
                t.M30, t.M31, t.M32, t.M33
            };

            var def = BlockDefinitionToSpeckle(instance.InstanceDefinition);

            var _instance = new BlockInstance()
            {
                insertionPoint  = PointToSpeckle(instance.InsertionPoint),
                transform       = transformArray,
                blockDefinition = def,
                units           = ModelUnits
            };

            return(_instance);
        }