.NET

.NET

Reply
Active Contributor
dancalgary
Posts: 46
Registered: ‎05-18-2007
Message 1 of 2 (207 Views)

how can i read rotation of a dbtext in the ucs?

207 Views, 1 Replies
08-25-2013 06:10 PM

DB text has a property called rotation

but the rotation is the rotation from WCS x axis ( vector3d. Xaxis)

how can i get the rotation from the ucs x axis?

Dim Xaxis_UCS As Vector3d = Curent_UCS.CoordinateSystem3d.Xaxis
   Dim x_ucs_wcs As Double = Xaxis_UCS.AngleOnPlane(New Plane(Point3d.Origin, Vector3d.ZAxis))

then i substract from rotation the ucs-wcs angle

but it is not goog

Do I miss something?

 

Thanks

 

*Expert Elite*
_gile
Posts: 2,082
Registered: ‎04-29-2006
Message 2 of 2 (178 Views)

Re : how can i read rotation of a dbtext in the ucs?

08-26-2013 01:02 AM in reply to: dancalgary

Hi,

 

The Rotation property of 2d entities (Text, BlockReference, ...) is the angle in radians measured CCW from the X axis of the entity Object Coordinate System (OCS). The origin of OCS is always the same the WCS origin.

If the entity construction plane is parallel to the WCS XY plane, the OCS is equal to WCS.

To learn more about OCS, have a look at the Developer Documentation in AutoCAD Help > DXF References > Advanced DXF Issues > Object Coordinates System (OCS).

 

So, to get the rotation of a Text (or MText, BlockReference, ...) about the UCS (assuming the current UCS plane is parallel to the entity construction plane), you have to substract the angle between the OCS X axis and the UCS X axis from the Rotation property.

 

If the UCS plane is parallel to the WCS plane, you can simply get the UCS rotation this way:

 

CoordinateSystem3d UCS = ed.CurrentUserCoordinateSystem.CoordinateSystem3d;
double ucsRotation = Vector3d.XAxis.GetAngleTo(UCS.Xaxis, Vector3d.ZAxis);

 If the UCS plane is not parallel to the WCS plane, you have to get the OCS corresponding to the current UCS first. As said upper te OCS origin is always Point3d.Origin and the OCS Z axis parallel to th UCS Z axis.

 

CoordinateSystem3d UCS = ed.CurrentUserCoordinateSystem.CoordinateSystem3d;
Plane OcsPlane = new Plane(Point3d.Origin, UCS.Zaxis);
CoordinateSystem3d OCS = Matrix3d.PlaneToWorld(OcsPlane).CoordinateSystem3d;
double ucsRotation = OCS.Xaxis.GetAngleTo(UCS.Xaxis, UCS.Zaxis);

 

Gilles Chanteau
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.