using(Transactiontransaction=ActiveUtil.TransactionManager.StartTransaction()){// Open the current space for writeBlockTableRecordcurrentSpaceBlockTableRecord=(BlockTableRecord)transaction.GetObject(ActiveUtil.Database.CurrentSpaceId,OpenMode.ForWrite);// Create a new dimension entityRotatedDimensiondimensionline=newRotatedDimension{XLine1Point=newPoint3d(0,0,0),XLine2Point=newPoint3d(5000,0,0),TextPosition=newPoint3d(2500,500,0),Rotation=0,DimensionStyle=ActiveUtil.Database.Dimstyle};// Add the dimension to the block table record and the transactioncurrentSpaceBlockTableRecord.AppendEntity(dimensionline);transaction.AddNewlyCreatedDBObject(dimensionline,true);// Commit the transactiontransaction.Commit();}
Code to Add Align Dimension
[CommandMethod("Test")]publicvoidTest(){using(Transactiontransaction=ActiveUtil.TransactionManager.StartTransaction()){// Open the current space for writeBlockTableRecordcurrentSpaceBlockTableRecord=(BlockTableRecord)transaction.GetObject(ActiveUtil.Database.CurrentSpaceId,OpenMode.ForWrite);// Create a new dimension entityAlignedDimensiondimensionline=newAlignedDimension{XLine1Point=newPoint3d(0,0,0),XLine2Point=newPoint3d(5000,0,0),DimLinePoint=newPoint3d(2500,250,0),TextPosition=newPoint3d(2500,500,0)};// Add the dimension to the block table record and the transactioncurrentSpaceBlockTableRecord.AppendEntity(dimensionline);transaction.AddNewlyCreatedDBObject(dimensionline,true);// Commit the transactiontransaction.Commit();}}