A method to create a rotated dimension using the AutoCAD .net API
protected void drawDimensions(Point3d dimensionPoint, Point3d point1, Point3d point2, double rotation)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable blockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord modelSpace = tr.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
using (RotatedDimension rotatedDimension = getRotatedDimension(point1, point2, dimensionPoint, rotation))
{
// Add the new object to Model space and the transaction
modelSpace.AppendEntity(rotatedDimension);
tr.AddNewlyCreatedDBObject(rotatedDimension, true);
}
tr.Commit();
}
}
protected RotatedDimension getRotatedDimension(Point3d xLinePoint1, Point3d xLinePoint2, Point3d dimensionPoint, double rotation)
{
RotatedDimension rotatedDimension = new RotatedDimension();
rotatedDimension.XLine1Point = xLinePoint1;
rotatedDimension.XLine2Point = xLinePoint2;
rotatedDimension.Rotation = rotation;
// get point returns in UCS, so we need to transform it into WCS coordinates.
// Editor.CurrentUserCoordinateSystem property which returns the transformation matrix from UCS to WCS
rotatedDimension.DimLinePoint = dimensionPoint;
rotatedDimension.DimensionStyle = db.Dimstyle;
return rotatedDimension;
}Video tutorial: https://vimeo.com/1137983762?share=copy&fl=sv&fe=ci