This version fixes a UCS bug arising when the UCS origin is not equal to the WCS origin. 2 nd October 2013. I am pleased to list Paul Stafford's blog: CADsmarter as an affiliate site of Lee Mac Programming. Paul's blog is relatively new, but already contains many useful tips & tricks to help you get the most out of AutoCAD.
The TransformBy method can translate a point or a displacement from one coordinate system to another. You use the AlignCoordinateSystem method to specify which coordinate system you are translating from and which coordinate system you are going to. The AlignCoordinateSystem method requires the following:
- Origin point of the coordinate system you are translating from
- Three 3D vectors that represent the X, Y and X axes of the coordinate system you are translating from
- Origin point of the coordinate system you are translating to
- Three 3D vectors that represent the X, Y and X axes of the coordinate system you are translating to
World coordinate system: The reference coordinate system. All other coordinate systems are defined relative to the WCS, which never changes. Values measured relative to the WCS are stable across changes to other coordinate systems. All points passed in and out of the methods and properties in the .NET API are expressed in the WCS unless otherwise specified.
User coordinate system (UCS): The working coordinate system. The user specifies a UCS to make drawing tasks easier. All points passed to AutoCAD commands, including those returned from AutoLISP routines and external functions, are points in the current UCS (unless the user precedes them with an * at the Command prompt). If you want your application to send coordinates in the WCS, OCS, or DCS to AutoCAD commands, you must first convert them to the UCS by calling the translating them and then transforming the Point3d or Point 2d object with the TransformBy method that represents the coordinate value.
Object coordinate system (also known as Entity coordinate system or ECS): Point values specified by certain methods and properties for the Polyline2d and Polyline objects are expressed in this coordinate system, relative to the object. These points are usually converted into the WCS, current UCS, or current DCS, according to the intended use of the object. Conversely, points in WCS, UCS, or DCS must be translated into an OCS before they are written to the database by means of the same properties.
When converting coordinates to or from the OCS you must consider the normal of the OCS.
Display coordinate system: The coordinate system where objects are transformed before they are displayed. The origin of the DCS is the point stored in the AutoCAD system variable TARGET, and its Z axis is the viewing direction. In other words, a viewport is always a plan view of its DCS. These coordinates can be used to determine where something will be displayed to the user.
Paper space DCS: This coordinate system can be transformed only to or from the DCS of a Model space viewport. This is essentially a 2D transformation, where the X and Y coordinates are always scaled. Therefore, it can be used to find the scale factor between the two coordinate systems. The PSDCS can be transformed only into a Model space viewport.
Every point in an AutoCAD drawing file can be identified by its X,Y,Z coordinates. (In most 2D drawings, the Z-coordinate value is 0.0.) This system of coordinates is referred to in AutoCAD as the world coordinate system, or WCS.
Coordinate input
The most direct way to enter points precisely is to type numbers with the keyboard. AutoCAD uses these keyboard coordinate entry formats:
- Absolute Cartesian (X,Y) coordinates in the form X,Y (for example, 7,4)
- Relative X,Y coordinates in the form @X,Y (for example, @3,2): Defines a new point that is X units horizontally and Y units vertically away from the current point.
- Relative polar coordinates in the form @distance<angle (for example, @6<45): Defines a new point that is the specified distance units away from the current point at the specified angle from the origin.
User coordinate systems
Many times, you can conveniently define an additional coordinate system to more easily create drawings. This non–world coordinate system, known as a user coordinate system, is so widely used that UCS now refers to every coordinate system in AutoCAD.
Why would you want to diverge from the standard WCS? Well, the most common reason is that it’s much easier to calculate and enter coordinates if they’re based on the plane you want to work on in 3D.
Suppose that you’re modeling an old-fashioned, wedge-shaped rubber doorstop and you want to add the manufacturer’s logo to the sloping surface of the wedge. It isn’t easy if you stay in the WCS, but AutoCAD lets you set a new UCS based on that sloping surface. After the UCS is made current, you draw in it just as you draw in the WCS.
Although originally intended for 3D work, a UCS can be useful on either two dimensions or three. The WCS assumes that the north direction is straight up, but you may be working on a building layout where one wing is at a 37.8 degree angle to the other.
No problem: Simply create a UCS that’s aligned appropriately. You can look up this process in the online help system, but here’s a quick hint: Click the UCS icon in the lower-left corner of the screen to make “grips” appear at the origin and the ends of the axis indicators. Then drag the icon by its grips to set a new UCS.
Draw by numbers
AutoCAD locates absolute X,Y coordinates with respect to the 0,0 point of the drawing — usually, its lower-left corner. AutoCAD locates relative X,Y coordinates and relative polar coordinates with respect to the previous point you picked or typed.
You will see how AutoCAD uses all three coordinate formats to draw a pair of line segments that start at the absolute coordinates 2,1, and then move to the right 2 units and up 1 unit (@2,1) relative to the first point, and then (relative to that point) move 2 units at an angle of 60 degrees (@2<60).
Note in particular how the first two coordinate pairs use the same numbers (2,1) but the second pair defines a different point because of the leading @ symbol.
You can find out the X,Y location of the crosshairs by moving them around in the drawing area and reading the coordinate values at the left end of the status bar. The X,Y coordinates should change as you move the crosshairs. If the coordinates don’t change, click the drawing coordinates area until you see Coords on in the command line.
If you’re using the full version of AutoCAD, you may have noticed that three numbers are at the left end of the status bar. AutoCAD is showing you the X,Y coordinates of the crosshairs and the current elevation. However, in 2D drafting, the Z value is 0, so you can continue calling them X,Y coordinates.
Although it isn’t apparent at first, AutoCAD has, in fact, four coordinate display modes. Clicking the coordinates readout cycles through these modes:
- Off (<Coords off>): The status bar coordinate readout is dimmed, and the coordinate values don’t update until you pick a point.
- On, showing X,Y coordinates (<Coords on>): The coordinate readout appears black, and the absolute X,Y coordinates update continuously as you move the crosshairs. If no command is active, clicking the coordinates readout alternates between this mode and <Coords off>.
- On, showing polar coordinates (<Coords on>): This mode, which displays distance and angle relative to the last point picked rather than absolute X,Y values, appears if a command is active and AutoCAD is waiting for you to pick a point.
- On, showing geographic coordinates (<Coords on>): This mode displays coordinates as latitude and longitude values, but it can be used only after you set the drawing’s geographic location with the GeographicLocation command.
If you start a command such as Line, pick a point, and then click the Coordinates area a few times, the display changes from coordinates Off to live absolute coordinates to live polar coordinates. Displaying live polar coordinates is the most informative mode most of the time.
If you’re working in AutoCAD’s architectural or engineering units, the default unit of entry is inches, not feet. Here are some guidelines for entering numeric values when you work with feet and inches:
- To specify feet, you must enter the apostrophe (′) symbol for feet after the number:6′ is 6 feet.
- To separate feet from inches, enter a dash:6′-6″ is 6 feet, 6 inches.
- When you enter coordinates and distances, both the dash and the inch mark are optional:6′6″ and 6′6 are the same as 6′-6″.
- To type a coordinate or distance that contains fractional inches, you must enter a dash — not a space — between the whole number of inches and the fraction:6′6-1/2 (or 6′-6-1/2) represents 6 feet, 6-1/2 inches.
- To enter partial inches, use decimals instead:6′6.5 is the same as 6′6-1/2″ to AutoCAD, whether you’re working in architectural or engineering units.