.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AlignedDimension with Autocad API .net reverse how to fix it

2 REPLIES 2
Reply
Message 1 of 3
p_k_duy
143 Views, 2 Replies

AlignedDimension with Autocad API .net reverse how to fix it

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

Labels (1)
2 REPLIES 2
Message 2 of 3
c_n_trung
in reply to: p_k_duy

I have same the problem ! :tired_face:

Message 3 of 3
essam-salah
in reply to: p_k_duy

hi @p_k_duy 

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report