Message 1 of 3
AlignedDimension with Autocad API .net reverse how to fix it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
but with UCS new was create im dim it is correct so where is miss set poperty ??
below is code:
public static Dimension? AlignDimension3D(Document doc, Transaction tran, Point3d? point1Origin, Point3d? point2ToAxis,Point3d? pointLiner, ObjectId? styleId = null, bool isCreateInstanceModel = true)
{
if ( point1Origin ==null || point2ToAxis ==null || pointLiner ==null ) {
LoggerCit.Instance.LogError( null, string.Empty ,"Error: Input dimension invalid");
return null ;
}
var plan = new Plane( point1Origin.Value, point2ToAxis.Value, pointLiner.Value ) ;
var normalPlane = plan.Normal ;
var vectorX = point2ToAxis.Value - point1Origin.Value ;
if ( normalPlane.Z < 0 ) {
normalPlane = - normalPlane;
}
if ( vectorX.X < 0) vectorX = - vectorX;
var vectorY = vectorX.CrossProduct( normalPlane ) ;
if ( vectorY.Y < 0 ) vectorY = -vectorY ;
var newUcs = Matrix3d.AlignCoordinateSystem( Point3d.Origin,
Vector3d.XAxis,
Vector3d.YAxis,
Vector3d.ZAxis,
point1Origin.Value,
vectorX,
vectorY,
normalPlane ) ;
doc.Editor.CurrentUserCoordinateSystem = newUcs ;
var newMatrix = doc.Editor.CurrentUserCoordinateSystem.Inverse() ;
var point1Align = point1Origin.Value.TransformBy( newMatrix ) ;
var point2Align = point2ToAxis.Value.TransformBy( newMatrix ) ;
var pointLinerAlign = pointLiner.Value.TransformBy( newMatrix ) ;
Dimension? dimOut = null ;
try {
var style = styleId ?? doc.Database.Dimstyle ;
var dimAlign = new AlignedDimension(point2Align,point1Align,pointLinerAlign,null,style) ;
dimAlign.TransformBy(doc.Editor.CurrentUserCoordinateSystem);
dimOut = dimAlign ;
if ( ! isCreateInstanceModel ) return null ;
dimAlign.AddToModelSpace( doc.Database,tran );
}
catch ( System.Exception e ) {
LoggerCit.Instance.LogError( e ) ;
}
return dimOut ;
}
Plese help me