AlignedDimension with Autocad API .net reverse how to fix it

AlignedDimension with Autocad API .net reverse how to fix it

p_k_duy
Explorer Explorer
277 Views
2 Replies
Message 1 of 3

AlignedDimension with Autocad API .net reverse how to fix it

p_k_duy
Explorer
Explorer

p_k_duy_0-1734690017685.png

 

but with UCS new was create im dim it is correct so where is miss set poperty ??

p_k_duy_1-1734690207971.png

 


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

0 Likes
278 Views
2 Replies
Replies (2)
Message 2 of 3

c_n_trung
Observer
Observer

I have same the problem ! 😫

0 Likes
Message 3 of 3

essam-salah
Collaborator
Collaborator

hi @p_k_duy 

haven't you tried to set AlignedDimension.TextRotation to 180 degrees (3.14 in rad)?

0 Likes