Ejemplo n.º 1
0
        public static void TextAndTextNode(string unparsed)
        {
            Application app                         = Utilities.ComApp;
            double      savedTextHeight             = app.ActiveSettings.TextStyle.Height;
            double      savedTextWidth              = app.ActiveSettings.TextStyle.Width;
            Font        savedFont                   = app.ActiveSettings.TextStyle.Font;
            bool        savedAnnotationScaleEnabled = app.ActiveSettings.AnnotationScaleEnabled;

            app.ActiveSettings.TextStyle.Height = 0.7;
            app.ActiveSettings.TextStyle.Width  = 0.6;
            app.ActiveSettings.TextStyle.Font   =
                app.ActiveDesignFile.Fonts.Find(MsdFontType.WindowsTrueType, "Arial");
            app.ActiveSettings.AnnotationScaleEnabled = false;
            Point3d     origin  = app.Point3dFromXY(0, -7.5);
            Matrix3d    rMatrix = app.Matrix3dIdentity();
            TextElement oText   = app.CreateTextElement1(null, "Text String", ref origin, ref rMatrix);

            oText.Color = 0;
            app.ActiveModelReference.AddElement(oText);
            origin = app.Point3dFromXY(2, -9);
            TextNodeElement oTN = app.CreateTextNodeElement1(null, ref origin, ref rMatrix);

            oTN.AddTextLine("Text Node Line 1");
            oTN.AddTextLine("Text Node Line 2");
            oTN.Color = 1;
            app.ActiveModelReference.AddElement(oTN);
            app.ActiveSettings.TextStyle.Height =
                savedTextHeight;
            app.ActiveSettings.TextStyle.Width        = savedTextWidth;
            app.ActiveSettings.TextStyle.Font         = savedFont;
            app.ActiveSettings.AnnotationScaleEnabled = savedAnnotationScaleEnabled;
        }
Ejemplo n.º 2
0
        public Element create_rebar_label(string text)
        {
            //string[] lines = text.Split("\r\n");
            //TextElement label = app.CreateTextElement1(null, text, app.Point3dZero(), app.Matrix3dZero());
            //TextStyle ts = app.ActiveDesignFile.TextStyles["宋体"];
            //label.TextStyle = ts;
            //TextNodeElement node = app.CreateTextNodeElement1(null, app.Point3dZero(), app.Matrix3dZero());
            //node.AddTextLine();
            //return label;
            string[]        lines = text.Split("\r\n".ToCharArray());
            TextNodeElement node  = app.CreateTextNodeElement1(null, app.Point3dZero(), app.Matrix3dFromRotationBetweenVectors(app.Point3dFromXYZ(0, 1, 0), app.Point3dFromXYZ(0, 1, 0)));

            foreach (string line in lines)
            {
                node.AddTextLine(line);
            }
            return(node);
        }
Ejemplo n.º 3
0
        public void Accept(Element Element, ref Point3d Point, View View)
        {
            app.ShowCommand("");
            CellElement     cell       = Element.AsCellElement();
            TextNodeElement ctextnode  = null;
            int             nest_level = 0;

            while (cell.MoveToNextElement(false, ref nest_level))
            {
                Element current = cell.CopyCurrentElement();
                if (current.IsTextNodeElement())
                {
                    ctextnode = current.AsTextNodeElement();
                    int    line_count = ctextnode.TextLinesCount;
                    string text       = "";
                    for (int i = 1; i <= line_count; i++)
                    {
                        text += ctextnode.get_TextLine(i);
                        text += "\r\n";
                    }
                    text = text.Substring(0, text.Length - 2);
                    LabelModifyForm lmf = new LabelModifyForm(text);
                    if (lmf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        System.Windows.Forms.TextBox textBox = (System.Windows.Forms.TextBox)lmf.Controls.Find("content_textBox", false)[0];
                        text = textBox.Text;

                        TextNodeElement new_text_element = app.CreateTextNodeElement1(null, ctextnode.Origin, ctextnode.Rotation);
                        string[]        lines            = text.Split("\r\n".ToCharArray());
                        foreach (string line in lines)
                        {
                            new_text_element.AddTextLine(line);
                        }
                        cell.ReplaceCurrentElement(new_text_element);
                    }
                    break;
                }
            }
            cell.Rewrite();
            app.ShowPrompt("修改标注");
        }
 public TextNodeElementMicrostation(TextNodeElement textNodeElement, IOwnerMicrostation ownerContainerMicrostation,
                                    bool isNeedCompress)
     : base((Element)textNodeElement, ownerContainerMicrostation, isNeedCompress)
 {
     _textNodeElement = textNodeElement ?? throw new ArgumentNullException(nameof(textNodeElement));
 }
 public TextNodeElementMicrostation(TextNodeElement textNodeElement, IOwnerMicrostation ownerContainerMicrostation)
     : this(textNodeElement, ownerContainerMicrostation, true)
 {
 }
Ejemplo n.º 6
0
        public static void Test(Element element)
        {
            if (element == null)
            {
                return;
            }

            // !проверка, что элемент добавлен в модель
            if (element.DgnModel == null || element.ElementId == null)
            {
                throw new ArgumentException(string.Format(
                                                "Couldn't read EC-properties from non-model element"));
            }



            TextNodeElement txtEl = element as TextNodeElement;

            if (txtEl != null)
            {
                foreach (var id in txtEl.GetTextPartIds(new TextQueryOptions()))
                {
                    var txtPart = txtEl.GetTextPart(id);
                    TextBlockProperties props = txtPart.GetProperties();
                    //txtPart.GetRunPropertiesForAdd()
                }
            }


            DgnECInstanceCollection ecInstances = DgnECManager.Manager.
                                                  GetElementProperties(element, ECQueryProcessFlags.SearchAllClasses);

            //foreach(var linkId in element.GetLinkageIds())
            //{
            //    var link = element.GetLinkage(linkId);
            //    link = link;

            //    for (int i = 0; i < link.Size; ++i)
            //    {
            //        try
            //        {
            //            string str = link.ReadString();
            //        }
            //        catch (Exception)
            //        {
            //        }
            //    }

            //}


            System.Text.StringBuilder bldr = new System.Text.StringBuilder();

            foreach (IDgnECInstance inst in ecInstances)
            {
                bldr.AppendLine(string.Format("Inst: <{0}> ID=<{1}>",
                                              inst.ClassDefinition.Name, inst.InstanceId));
                foreach (IECPropertyValue propVal in inst)
                {
                    if (propVal.Property.Name == "Links")
                    {
                    }

                    if (propVal.Type is ECArrayType)
                    {
                        try
                        {
                            foreach (var item in propVal as ECDArrayValue)
                            {
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }


                    try
                    {
                        object value = "ERROR";
                        propVal.TryGetNativeValue(out value);

                        bldr.AppendLine(string.Format(
                                            "\tProp: <{0}>, Type=<{1}>, StringValue=<{2}>",
                                            propVal.Property.Name, propVal.Type, value.ToString()));
                    }
                    catch (Exception)
                    {
                    }
                }
                bldr.AppendLine();
            }
        }