Esempio n. 1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // this doesn't work - check hot to cast to GUID and find dot by id
            // but keep the possibility that input is of type TextDot
            IGH_Goo dotInput = null;
            TextDot dot      = null;
            GH_Guid dotGuid;

            if (!DA.GetData(0, ref dotInput))
            {
                return;
            }

            //dotInput.CastTo(out dot);

            if (!dotInput.CastTo(out dot))
            {
                dotGuid = dotInput as GH_Guid;
                Guid dg     = dotGuid.Value;
                var  dotDoc = RhinoDoc.ActiveDoc.Objects.FindId(dg);
                dot = dotDoc.Geometry as TextDot;
            }

            DA.SetData(0, dot.Point);
            DA.SetData(1, dot.Text);
            DA.SetData(2, dot.SecondaryText);
            DA.SetData(3, dot.FontHeight);
            DA.SetData(4, dot.FontFace);
        }
Esempio n. 2
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            UsefulFunctions.XSelectPoints("Seleect points for enumeration", out Point3dList points);

            var format = string.Format("F{0}", doc.ModelDistanceDisplayPrecision);

            for (var i = 0; i < points.Count; i++)
            {
                var str = string.Format("Point {0} X:{1},Y:{2},Z:{3}",
                                        i.ToString(),
                                        points[i].X.ToString(format),
                                        points[i].Y.ToString(format),
                                        points[i].Z.ToString(format));
                if (i == 0)
                {
                    str = "First Point";
                }
                else if (i == points.Count - 1)
                {
                    str = "Last Point";
                }

                var dot = new TextDot(str, points[i]);

                doc.Objects.AddTextDot(dot);
            }

            doc.Views.Redraw();

            return(Result.Success);
        }
        public static object ToNative(this SpeckleAnnotation annot)
        {
            if (annot.Plane != null)
            {
                // TEXT ENTITIY
                var textEntity = new TextEntity()
                {
                    Text       = annot.Text,
                    Plane      = annot.Plane.ToNative(),
                    FontIndex  = Rhino.RhinoDoc.ActiveDoc.Fonts.FindOrCreate(annot.FontName, ( bool )annot.Bold, ( bool )annot.Italic),
                    TextHeight = ( double )annot.TextHeight
                };
#if R6
                var dimStyleIndex = Rhino.RhinoDoc.ActiveDoc.DimStyles.Add("Speckle");
                var dimStyle      = new Rhino.DocObjects.DimensionStyle
                {
                    TextHeight = ( double )annot.TextHeight,
                    Font       = new Rhino.DocObjects.Font(annot.FontName, Rhino.DocObjects.Font.FontWeight.Bold, Rhino.DocObjects.Font.FontStyle.Italic, false, false)
                };
                Rhino.RhinoDoc.ActiveDoc.DimStyles.Modify(dimStyle, dimStyleIndex, true);

                textEntity.DimensionStyleId = Rhino.RhinoDoc.ActiveDoc.DimStyles[dimStyleIndex].Id;
#endif

                return(textEntity);
            }
            else
            {
                // TEXT DOT!
                var myTextdot = new TextDot(annot.Text, annot.Location.ToNative().Location);
                myTextdot.UserDictionary.ReplaceContentsWith(annot.Properties.ToNative());
                return(myTextdot);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string ID = null;

            if (!DA.GetData(0, ref ID))
            {
                return;
            }
            Guid gd = new Guid(ID);

            if (Rhino.RhinoDoc.ActiveDoc.Objects.Find(gd) is Rhino.DocObjects.TextObject)
            {
                Rhino.DocObjects.TextObject obj = Rhino.RhinoDoc.ActiveDoc.Objects.Find(gd) as Rhino.DocObjects.TextObject;
                TextEntity tx  = obj.TextGeometry;
                Plane      pln = tx.Plane;
                string     mm  = obj.DisplayText;
                DA.SetData(0, mm);
                DA.SetData(1, pln);
                DA.SetData(2, tx.TextHeight);
                DA.SetDataList(3, tx.Explode());
            }
            else if (Rhino.RhinoDoc.ActiveDoc.Objects.Find(gd) is Rhino.DocObjects.TextDotObject)
            {
                Rhino.DocObjects.TextDotObject obj = Rhino.RhinoDoc.ActiveDoc.Objects.Find(gd) as Rhino.DocObjects.TextDotObject;
                TextDot td = (TextDot)obj.Geometry;
                DA.SetData(0, td.Text);
                DA.SetData(1, td.Point);
            }
        }
Esempio n. 5
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var count = 0;

            var gp = new GetPoint();

            gp.AcceptNothing(true);
            for (; ;)
            {
                gp.SetCommandPrompt(0 == count ? "Location of text dot" : "Location of text dot. Press Enter when done");

                var res = gp.Get();

                if (res == GetResult.Point)
                {
                    var point = gp.Point();
                    var str   = count.ToString(CultureInfo.InvariantCulture);
                    var dot   = new TextDot(str, point);
                    doc.Objects.Add(dot);
                    doc.Views.Redraw();
                    count++;
                    continue;
                }

                break;
            }

            return(Result.Success);
        }
Esempio n. 6
0
        public Guid AddFaceName(string name, BrepFace face, Color color = default(Color))
        {
            if (!IS_ENABLED)
            {
                return(Guid.Empty);
            }

            if (color == default(Color))
            {
                color = Color.White;
            }

            color = DefColor(color);
            var textDot = new TextDot(name, face._GetCentroid())
            {
                FontHeight = 10,
                FontFace   = "Tahoma",
            };

            Guid id = Doc.Objects.AddTextDot(textDot, new ObjectAttributes
            {
                LayerIndex = LayerIndex,
                Name       = name,
                //Mode = ObjectMode.Locked,
                ColorSource = ObjectColorSource.ColorFromObject,
                ObjectColor = color,
                Visible     = true,
            }, null, true);

            return(id);
        }
        public static SpeckleAnnotation ToSpeckle(this TextDot textdot)
        {
            var myAnnotation = new SpeckleAnnotation();

            myAnnotation.Text     = textdot.Text;
            myAnnotation.Location = textdot.Point.ToSpeckle();
            myAnnotation.GenerateHash();

            return(myAnnotation);
        }
Esempio n. 8
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Point3d Location = default(Point3d);
            string  Text     = default(string);

            if (!DA.GetData(0, ref Location))
            {
                return;
            }
            if (!DA.GetData(1, ref Text))
            {
                return;
            }
            if (!DA.GetData(2, ref FillColor))
            {
                return;
            }

            this.Dot = new Rhino.Geometry.TextDot(Text, Location);
            DA.SetData(0, Dot);
        }
Esempio n. 9
0
        public Guid AddTextPoint(string text, Point3d point, Color color = default(Color))
        {
            if (!IS_ENABLED)
            {
                return(Guid.Empty);
            }
            color = DefColor(color);
            var textDot = new TextDot(text, point)
            {
                //FontHeight = 10
            };

            Guid id = Doc.Objects.AddTextDot(textDot, new ObjectAttributes
            {
                LayerIndex = LayerIndex,
                Name       = text,
                //Mode = ObjectMode.Locked,
                ColorSource = ObjectColorSource.ColorFromObject,
                ObjectColor = color,
                Visible     = true,
            }, null, true);

            return(id);
        }
Esempio n. 10
0
 public bool Replace(Guid guid, TextDot dot)
 {
     throw NotSupportedExceptionHelp();
 }
Esempio n. 11
0
 public Guid AddTextDot(TextDot dot, ObjectAttributes attributes)
 {
     throw NotSupportedExceptionHelp();
 }
Esempio n. 12
0
 public Guid AddTextDot(TextDot dot)
 {
     throw NotSupportedExceptionHelp();
 }
Esempio n. 13
0
 protected override void BeforeSolveInstance()
 {
     this.Dot = null;
 }
Esempio n. 14
0
 public void SetDotName(TextDot newdotname)
 {
     dotname = newdotname;
 }