.NET

Reply
Active Contributor
NayaraFJ
Posts: 42
Registered: ‎08-11-2011
Message 1 of 2 (259 Views)
Accepted Solution

Creating Dimension Styles

259 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
NayaraFJ
Posts: 42
Registered: ‎08-11-2011
Message 2 of 2 (252 Views)

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 Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!