Exemple #1
0
        public static AcDb.ObjectId CreateFontStyle(String textStyleName, AcGi.FontDescriptor font)
        {
            AcDb.ObjectId txtStyleId = AcDb.ObjectId.Null;

            using (AcDb.Transaction tr = doc.Database.TransactionManager.StartTransaction())
            {
                AcDb.TextStyleTable newTextStyleTable = tr.GetObject(doc.Database.TextStyleTableId, AcDb.OpenMode.ForRead) as AcDb.TextStyleTable;

                if (!newTextStyleTable.Has(textStyleName))
                {
                    newTextStyleTable.UpgradeOpen();
                    AcDb.TextStyleTableRecord newTextStyleTableRecord = new AcDb.TextStyleTableRecord();
                    //newTextStyleTableRecord.FileName = "romans.shx";
                    newTextStyleTableRecord.Name = textStyleName;
                    newTextStyleTableRecord.Font = font;
                    newTextStyleTable.Add(newTextStyleTableRecord);
                    tr.AddNewlyCreatedDBObject(newTextStyleTableRecord, true);

                    txtStyleId = newTextStyleTable[textStyleName];
                }
                tr.Commit();
            }

            return(txtStyleId);
        }
        private void leaderStyleHandler(string styleName, int scale)
        {
            _Db.DBDictionary   mleaderStyleTable = _c.trans.GetObject(_c.db.MLeaderStyleDictionaryId, _Db.OpenMode.ForWrite) as _Db.DBDictionary;
            _Db.TextStyleTable txtStyleTable     = _c.trans.GetObject(_c.db.TextStyleTableId, _Db.OpenMode.ForWrite) as _Db.TextStyleTable;

            if (!mleaderStyleTable.Contains(styleName))
            {
                _Db.MLeaderStyle newStyle = new _Db.MLeaderStyle();

                newStyle.Annotative    = _Db.AnnotativeStates.False;
                newStyle.ArrowSize     = 3.0;
                newStyle.ArrowSymbolId = _c.blockTable["_NONE"];
                //newStyle.BlockColor=; //BYBLOCK
                newStyle.BlockConnectionType         = _Db.BlockConnectionType.ConnectExtents;
                newStyle.BlockId                     = _Db.ObjectId.Null;
                newStyle.BlockRotation               = 0;
                newStyle.BlockScale                  = new _Ge.Scale3d(1, 1, 1);
                newStyle.BreakSize                   = 0;
                newStyle.ContentType                 = _Db.ContentType.MTextContent;
                newStyle.DefaultMText                = new _Db.MText();
                newStyle.DoglegLength                = 8;
                newStyle.DrawLeaderOrderType         = _Db.DrawLeaderOrderType.DrawLeaderHeadFirst;
                newStyle.DrawMLeaderOrderType        = _Db.DrawMLeaderOrderType.DrawLeaderFirst;
                newStyle.EnableBlockRotation         = true;
                newStyle.EnableBlockScale            = true;
                newStyle.EnableDogleg                = false;
                newStyle.EnableFrameText             = false;
                newStyle.EnableLanding               = true;
                newStyle.FirstSegmentAngleConstraint = _Db.AngleConstraint.DegreesAny;
                newStyle.LandingGap                  = 1;
                newStyle.LeaderLineColor             = _Cm.Color.FromColorIndex(_Cm.ColorMethod.None, 142);
                newStyle.LeaderLineType              = _Db.LeaderType.StraightLeader;
                //newStyle.LeaderLineTypeId=; //BYBLOCK
                //newStyle.LeaderLineWeight=; //BYBLOCK
                newStyle.MaxLeaderSegmentsPoints = 2;
                newStyle.Scale = scale;
                newStyle.SecondSegmentAngleConstraint = _Db.AngleConstraint.DegreesAny;
                newStyle.TextAlignAlwaysLeft          = false;
                newStyle.TextAlignmentType            = _Db.TextAlignmentType.LeftAlignment;
                newStyle.TextAngleType = _Db.TextAngleType.HorizontalAngle;
                //newStyle.TextColor=; //BYBLOCK
                newStyle.TextHeight  = 2.5;
                newStyle.TextStyleId = txtStyleTable["Stommest"];

                newStyle.SetTextAttachmentType(_Db.TextAttachmentType.AttachmentBottomOfTopLine, _Db.LeaderDirectionType.LeftLeader);  // Left attachment
                newStyle.SetTextAttachmentType(_Db.TextAttachmentType.AttachmentBottomOfTopLine, _Db.LeaderDirectionType.RightLeader); // Right attachment

                newStyle.PostMLeaderStyleToDb(_c.db, styleName);
                _c.trans.AddNewlyCreatedDBObject(newStyle, true);
                write("[OUTPUT] MLeader style '" + styleName + "' created");
            }
        }
        private void textStyleHandler()
        {
            _Db.TextStyleTable txtStyleTable = _c.trans.GetObject(_c.db.TextStyleTableId, _Db.OpenMode.ForWrite) as _Db.TextStyleTable;

            if (!txtStyleTable.Has("Stommest"))
            {
                _Db.TextStyleTableRecord newStyle = new _Db.TextStyleTableRecord();
                newStyle.Name = "Stommest";

                newStyle.FileName       = "ARIALN.TTF";
                newStyle.FlagBits       = 0;
                newStyle.Font           = new _Gi.FontDescriptor("Arial Narrow", false, false, 0, 34);
                newStyle.IsVertical     = false;
                newStyle.ObliquingAngle = 0;
                newStyle.TextSize       = 0;
                newStyle.XScale         = 1;

                txtStyleTable.Add(newStyle);
                _c.trans.AddNewlyCreatedDBObject(newStyle, true);
                write("[OUTPUT] TextStyle 'Stommest' created");
            }
        }