.NET

Reply
Active Contributor
42 Posts
0 Kudos
Registered: ‎08-11-2011
Post 1 of 2
Accepted Solution

Creating Dimension Styles

269 Views, 1 Replies
09-03-2012 04:42 AM

I'm not able to create a "DIMSTYLE" with Dimblk1 different Dimblk2.

 

 

        public static ObjectId CreateDimstyle(DimStyleTableRecord dim, string name, string seta1, string seta2)
        {
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                DimStyleTable dimStyleTable = (DimStyleTable)acTrans.GetObject(acCurDb.DimStyleTableId, OpenMode.ForWrite);
                DimStyleTableRecord dimStyleTableRecord = null;
                if (dimStyleTable.Has(name) == false)
                {

                    if (dimStyleTable.IsWriteEnabled == false)
                        dimStyleTable.UpgradeOpen();
                    dimStyleTableRecord = new DimStyleTableRecord();
                    dimStyleTableRecord.Name = name;
                    dimStyleTable.Add(dimStyleTableRecord);
                    acTrans.AddNewlyCreatedDBObject(dimStyleTableRecord, true);
                }
                else
                {
                    dimStyleTableRecord = acTrans.GetObject(dimStyleTable[name],
                        OpenMode.ForWrite) as DimStyleTableRecord;
                }

                dimStyleTableRecord.Dimtxsty = dim.Dimtxsty;

                dimStyleTableRecord.Dimtxt = dim.Dimtxt;
                dimStyleTableRecord.Dimscale = dim.Dimscale;
                dimStyleTableRecord.Dimdec = dim.Dimdec; 
                dimStyleTableRecord.Dimadec = dim.Dimadec;
                dimStyleTableRecord.Dimlunit = dim.Dimlunit; 
                dimStyleTableRecord.Dimaunit = dim.Dimaunit; 
                dimStyleTableRecord.Dimtad = dim.Dimtad; 
                dimStyleTableRecord.Dimtih = dim.Dimtih; 
                dimStyleTableRecord.Dimtix = dim.Dimtix; 
                dimStyleTableRecord.Dimtofl = dim.Dimtofl;
                dimStyleTableRecord.Dimblk = ConvertToLayer.GetArrowObjectId(seta1);
                dimStyleTableRecord.Dimblk1 = ConvertToLayer.GetArrowObjectId(seta1);
                dimStyleTableRecord.Dimblk2 = ConvertToLayer.GetArrowObjectId(seta2);
                dimStyleTableRecord.Dimasz = dim.Dimasz;
                dimStyleTableRecord.Dimgap = dim.Dimgap;
                dimStyleTableRecord.Dimclrt = dim.Dimclrt;
                dimStyleTableRecord.Dimclre = dim.Dimclre;
                dimStyleTableRecord.Dimclrd = dim.Dimclrd;
                dimStyleTableRecord.Dimexo = dim.Dimexo;
                dimStyleTableRecord.Dimtmove = dim.Dimtmove;
                dimStyleTableRecord.Dimtoh = dim.Dimtoh;
                dimStyleTableRecord.Dimexe = dim.Dimexe;
                acCurDb.SetDimstyleData(dimStyleTableRecord);
                acTrans.Commit();
                return dimStyleTableRecord.ObjectId;
            }
        }

 What am I doing wrong.
Please help me out!

 

I managed.
I also had to configure: acDimStyleTblRec.Dimsah = true;

 

Active Contributor
42 Posts
0 Kudos
Registered: ‎08-11-2011
Post 2 of 2

Re: Creating Dimension Styles

09-03-2012 05:41 AM in reply to: NayaraFJ

I managed.
I also had to configure: acDimStyleTblRec.Dimsah = true;

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!