Esempio n. 1
0
        /// <summary>
        /// Transform the object by a 4x4 transform matrix and change text height
        /// override to accommodate scaling in the transform if necessary
        /// </summary>
        /// <param name="transform">
        /// An Transform with the transformation information
        /// </param>
        /// <param name="style">
        /// </param>
        /// <returns>
        /// Returns true on success otherwise returns false.
        /// </returns>
        /// <since>6.0</since>
        public bool Transform(Transform transform, DimensionStyle style)
        {
            var style_pointer = style?.ConstPointer() ?? IntPtr.Zero;
            var pointer       = NonConstPointer();
            var success       = UnsafeNativeMethods.ON_V6_TextObject_Transform(pointer, ref transform, style_pointer);

            return(success);
        }
Esempio n. 2
0
        public Transform GetTextTransform(double textscale, DimensionStyle dimstyle)
        {
            Transform xform              = new Transform();
            IntPtr    const_ptr_this     = ConstPointer();
            IntPtr    const_ptr_dimstyle = dimstyle.ConstPointer();

            UnsafeNativeMethods.ON_V6_TextObject_GetTextXform(const_ptr_this, const_ptr_dimstyle, textscale, ref xform);
            return(xform);
        }
Esempio n. 3
0
        internal IntPtr ConstParentDimStylePointer()
        {
            SetupParentDimStyleField();
            if (m_parent_dimstyle != null)
            {
                return(m_parent_dimstyle.ConstPointer());
            }

            return(IntPtr.Zero);
        }
Esempio n. 4
0
        /// <summary>
        /// Get view dependent dimension scale
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="dimstyle"></param>
        /// <param name="vport"></param>
        /// <returns></returns>
        /// <since>6.0</since>
        public static double GetDimensionScale(RhinoDoc doc, DimensionStyle dimstyle, Rhino.Display.RhinoViewport vport)
        {
            uint   docsn     = doc.RuntimeSerialNumber;
            IntPtr pvport    = vport.ConstPointer();
            IntPtr pdimstyle = dimstyle.ConstPointer();
            double scale     = UnsafeNativeMethods.ON_V6_Annotation_GetDimScale(docsn, pdimstyle, pvport);

            GC.KeepAlive(vport);    // GC_KeepAlive: Nov. 1, 2018
            GC.KeepAlive(dimstyle); // GC_KeepAlive: Nov. 1, 2018
            return(scale);
        }
Esempio n. 5
0
        /// <summary>
        ///  Creates a Leader geometry object
        /// </summary>
        /// <param name="richText"></param>
        /// <param name="plane"></param>
        /// <param name="dimstyle"></param>
        /// <param name="points"></param>
        /// <returns></returns>
        public static Leader CreateWithRichText(string richText, Plane plane, DimensionStyle dimstyle, Point3d[] points)
        {
            IntPtr const_ptr_dimstyle = dimstyle.ConstPointer();
            IntPtr ptr_leader         = UnsafeNativeMethods.ON_V6_Leader_Create(richText, ref plane, points.Length, points, const_ptr_dimstyle);

            if (IntPtr.Zero == ptr_leader)
            {
                return(null);
            }
            var rc = new Leader(ptr_leader, null);

            rc.ParentDimensionStyle = dimstyle;
            return(rc);
        }
Esempio n. 6
0
        /// <summary> Create RichText geometry or null if input is invalid </summary>
        /// <param name="richTextString"></param>
        /// <param name="plane"></param>
        /// <param name="style"></param>
        /// <param name="wrapped"></param>
        /// <param name="rectWidth"></param>
        /// <param name="rotationRadians"></param>
        /// <returns></returns>
        /// <since>6.0</since>
        public static TextEntity CreateWithRichText(string richTextString, Plane plane, DimensionStyle style, bool wrapped, double rectWidth, double rotationRadians)
        {
            var    const_ptr_dimstyle = style.ConstPointer();
            IntPtr ptr_text           = UnsafeNativeMethods.ON_V6_TextObject_Create(richTextString, plane, const_ptr_dimstyle, wrapped, rectWidth, rotationRadians);

            if (IntPtr.Zero == ptr_text)
            {
                return(null);
            }
            var rc = new TextEntity(ptr_text, null);

            rc.ParentDimensionStyle = style;
            return(rc);
        }
Esempio n. 7
0
        public DimensionStyle GetDimensionStyle(DimensionStyle parentDimStyle)
        {
            IntPtr const_ptr_this            = ConstPointer();
            IntPtr const_ptr_parentdimsytyle = parentDimStyle != null?parentDimStyle.ConstPointer() : IntPtr.Zero;

            // TODO: We should look at the pointer returned from ON_Annotation_DimensionStyle and make a light copy
            // when it is the same as parentDimStyle's. This is the typical case. I'm leaving this alone for the
            // moment to minimze change.
            IntPtr ptr_new_dimstyle =
                UnsafeNativeMethods.ON_V6_Annotation_DimensionStyle(const_ptr_this, const_ptr_parentdimsytyle);

            GC.KeepAlive(m_parent_dimstyle); // GC_KeepAlive: Nov. 1, 2018
            GC.KeepAlive(this);              // GC_KeepAlive: Nov. 1, 2018
            if (IntPtr.Zero == ptr_new_dimstyle)
            {
                return(null);
            }
            return(new DimensionStyle(ptr_new_dimstyle));
        }
Esempio n. 8
0
        internal BoundingBox InternalGetBoundingBox()
        {
            BoundingBox    bbox            = BoundingBox.Empty;
            IntPtr         const_ptr_this  = ConstPointer();
            IntPtr         parent_dimstyle = ConstParentDimStylePointer();
            DimensionStyle dimstyle        = null;

            if (parent_dimstyle == IntPtr.Zero)
            {
                dimstyle = DimensionStyle;
                if (dimstyle != null)
                {
                    parent_dimstyle = dimstyle.ConstPointer();
                }
            }
            BoundingBox b = UnsafeNativeMethods.ON_Annotation_GetAnnotationBoundingBox(const_ptr_this, parent_dimstyle, ref bbox) ? bbox : BoundingBox.Empty;

            GC.KeepAlive(dimstyle);
            return(b);
        }
Esempio n. 9
0
        public Curve[] CreateCurves(DimensionStyle dimstyle, bool bAllowOpen, double smallCapsScale = 1.0, double spacing = 0.0)
        {
            IntPtr const_ptr_parent = IntPtr.Zero;
            IntPtr const_ptr_this   = IntPtr.Zero;

            TextObject parent = _GetConstObjectParent() as TextObject;

            if (null != parent)
            {
                const_ptr_parent = parent.ConstPointer();
            }
            else
            {
                const_ptr_this = ConstPointer();
            }

            Runtime.InteropWrappers.SimpleArrayCurvePointer curves = new Runtime.InteropWrappers.SimpleArrayCurvePointer();
            IntPtr ptr_curves         = curves.NonConstPointer();
            var    const_ptr_dimstyle = dimstyle.ConstPointer();

            UnsafeNativeMethods.RHC_RhinoGetPlanarCurvesFromText(const_ptr_parent, const_ptr_this, const_ptr_dimstyle, !bAllowOpen, smallCapsScale, spacing, ptr_curves);
            return(curves.ToNonConstArray());
        }
Esempio n. 10
0
        public Extrusion[] CreateExtrusions(DimensionStyle dimstyle, double height, double smallCapsScale = 1.0, double spacing = 0.0)
        {
            IntPtr const_ptr_parent = IntPtr.Zero;
            IntPtr const_ptr_this   = IntPtr.Zero;

            TextObject parent = _GetConstObjectParent() as TextObject;

            if (null != parent)
            {
                const_ptr_parent = parent.ConstPointer();
            }
            else
            {
                const_ptr_this = ConstPointer();
            }

            Runtime.InteropWrappers.SimpleArrayExtrusionPointer extrusions = new Runtime.InteropWrappers.SimpleArrayExtrusionPointer();
            IntPtr ptr_extrusions     = extrusions.NonConstPointer();
            var    const_ptr_dimstyle = dimstyle.ConstPointer();

            UnsafeNativeMethods.RHC_RhinoGetExtrusionsFromText(const_ptr_parent, const_ptr_this, const_ptr_dimstyle, smallCapsScale, height, spacing, ptr_extrusions);
            return(extrusions.ToNonConstArray());
        }
Esempio n. 11
0
        public Brep[] CreateSurfaces(DimensionStyle dimstyle, double smallCapsScale = 1.0, double spacing = 0.0)
        {
            IntPtr const_ptr_parent = IntPtr.Zero;
            IntPtr const_ptr_this   = IntPtr.Zero;

            TextObject parent = _GetConstObjectParent() as TextObject;

            if (null != parent)
            {
                const_ptr_parent = parent.ConstPointer();
            }
            else
            {
                const_ptr_this = ConstPointer();
            }

            Runtime.InteropWrappers.SimpleArrayBrepPointer breps = new Runtime.InteropWrappers.SimpleArrayBrepPointer();
            IntPtr ptr_breps          = breps.NonConstPointer();
            var    const_ptr_dimstyle = dimstyle.ConstPointer();

            UnsafeNativeMethods.RHC_RhinoGetPlanarBrepsFromText(const_ptr_parent, const_ptr_this, const_ptr_dimstyle, smallCapsScale, spacing, ptr_breps);
            return(breps.ToNonConstArray());
        }
Esempio n. 12
0
 /// <summary>
 /// Get a DimensionStyle with the specified characteristics
 /// </summary>
 /// <param name="face"></param>
 /// <param name="bold"></param>
 /// <param name="italic"></param>
 /// <param name="template_style">
 /// the settings other than face, bold and italic are copied from the template_style
 /// </param>
 /// <returns></returns>
 /// <since>6.0</since>
 public int FindOrCreate(string face, bool bold, bool italic, DimensionStyle template_style)
 {
     return(UnsafeNativeMethods.CRhinoDimStyleTable_FindOrCreate(Document.RuntimeSerialNumber, face, bold, italic, template_style.ConstPointer()));
 }