本帖最后由 a393006410 于 2021-7-20 12:59 编辑
记录平时开发过程中遇到的问题,希望可以帮助到大家
1、镜像标注时,标注文字方向是反的
解决方法:
[CommandMethod("Test_MirrorDimDemo")] public void MirrorDimTest() {
var line = new Line(new Point3d(0, 0, 0), new Point3d(100, 0, 0)); var rotateds = new RotatedDimension { XLine1Point = line.StartPoint, XLine2Point = line.EndPoint, Rotation = line.Angle, DimLinePoint = line.StartPoint.GetOffsetPoint(0, 100) }; var oNormal = rotateds.Normal;//关键属性
Matrix3d mt = Matrix3d.Mirroring(new Line3d(line.EndPoint, new Point3d(100, 100, 0))); var newRotateds = rotateds.GetTransformedCopy(mt) as RotatedDimension; newRotateds.Normal = oNormal;//关键属性
Database db = HostApplicationServices.WorkingDatabase; db.AddEnityToModelspace(rotateds, newRotateds);//添加图形到模型空间
} 2、镜像多段线的Normal属性与手动镜像不同解决办法使用镜像平面
Plane pl = new Plane(new Point3d(0, 10, 0), Vector3d.YAxis);
var ids = selectionResult.Value.GetObjectIds();
var matrix = Matrix3d.Mirroring(pl);
foreach (var id in ids)
{
var ent = (Entity)id.GetObject(OpenMode.ForWrite);
ent.TransformBy(matrix);
tr.ModelSpace().AddEntity(ent);
}
3.使用镜像平面镜像标注时遇到新问题,更改标注的Normal属性,标注的文字还是反的,这时候需要更改标注的观察方向
将标注的属性设置为:dimension.Dimtxtdirection = true;//从右往左
4.第三条是错误的,在镜像块并炸开时标注文字有时是反的有时是正的经过测试对比发现Dimension.Horizo​​ntalRotation这个属性至关重要,水平方向的标注将属性值设置为Math.PI*0.5就解决了标注文字方向错误的问题,垂直方向的标注没有测试过
|