Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi! this might be pretty basic but I just can't find the way to do it. I'm trying to modify the text height of an AlignedDimension via C#.
In AutoCAD, I can modify it in the properties panel:
below is my code for aligned dimension creation :
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
ObjectId drawAlignedDimension(Point3d line1Point, Point3d line2Point, Point3d dimLinePoint, string text)
{
Document document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor editor = document.Editor;
Database database = document.Database;
ObjectId dimensionObjId = ObjectId.Null;
using (var tr = database.TransactionManager.StartTransaction())
{
DimStyleTable dimStyleTbl = database.DimStyleTableId.GetObject(OpenMode.ForRead) as DimStyleTable;
DimStyleTableRecord targetDimStyle = null;
const string targetDimStyleName = "ISO-25";
//find dimStyle
foreach (ObjectId objId in dimStyleTbl)
{
DimStyleTableRecord dimStyleRec = objId.GetObject(OpenMode.ForRead) as DimStyleTableRecord;
if (dimStyleRec.Name == targetDimStyleName)
{
targetDimStyle = dimStyleRec;
break;
}
}
//create dimension
using (var dimension = new AlignedDimension(line1Point, line2Point, dimLinePoint, text, targetDimStyle.Id))
{
var blkTbl = database.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable;
var modelSpace = blkTbl[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite) as BlockTableRecord;
dimensionObjId = modelSpace.AppendEntity(dimension);
tr.AddNewlyCreatedDBObject(dimension, true);
}
tr.Commit();
}
return dimensionObjId;
}
ObjectId dimId = drawAlignedDimension(new Point3d(0, 0, 0), new Point3d(30, 0, 0), new Point3d(5, 5, 0), "test text");
I've been searching and reading the document for several days but seem not able to find relative source or property. Can someone give me some suggestions? Any help is really appreciated!
Solved! Go to Solution.