Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
Hi there,
I have a .dwg file with circle objects I created. When I extract the Center X,Y,Z (using dataextraction wizard) they reset back to the WCS (World Coordinate Sytem), when in fact I want their relative positions to a UCS origin (user Coordinate System) that I have defined on the drawing.
Any help with this would be much appreciated! Thanks!
(P.s.: First-time user of AUTOCAD)
Solved! Go to Solution.
Solved by leeminardi. Go to Solution.
Sebastian
Hereās a clumsy but valid method to convert WCS coordinates to the coordinates of a named ucs by using only AutoCAD commands and Excel. It was fun using Excel to manipulate the data. No vlisp required.
In addition to the list of points in WCS coordinates you will need the matrix of the UCS. To get the UCS matrix do the following (note, Iām sure there is an easier method with VLISP):
Make the desired UCS current.
Name the current ucs with:
UCS NA S (Iāve given it the name ucs1 in my example).
Make the WCS current with
UCS [Enter] [Enter]
Get the matrix of ucs1:
UCS NA ? ucs1
The matrix has 4 rows and 3 columns. Enter these values into Excel via copy and paste with the x axis as the FIRST row and the origin as the FOURTH row.
The UCS matrix is used to convert UCS coordinates To WCS coordinates. We want to do the opposite so we need to invert the UCS matrix. To invert a matrix it must have the same number of rows and columns. Iāve added a fourth column to the matrix (0 0 0 1) to make it a square matrix (cells B2:E5). Cells F2:I5 use the Excel MINVERSE function to invert the matrix.
Finally, all we need to do to convert extracted x,y,z WCS coordinates to UCS coordinates is to multiply the WCS coordinates and the inverted UCS matrix. Note that a 1 is included as a fourth coordinate for the WCS point. This is required because the UCS matrix has 4 rows.
Donāt worry if you do not follow all of the math outlined above. All you need to do is to list the WCS coordinates in cells B9, C9, and D9 down. Fill down cells F9:H9 as far down as needed for the number of points you have. Since these cells make use of an Excel array functions you must select all three cells when doing the fill-down.
In my example I had a point at x=1, y=2, z=3 in UCS coordinates (10.5946, 4.3371, 6.2618 WCS coordinates). You can see that the conversion from WCS is not exact. This is due to the 4 decimal place rounding I used for the point and the matrix. For better results, set the precision higher with LUPREC.
This process could be done with a VLISP program that makes use of functions to do the conversions but I thought it an interesting challenge to do it with Excel alone.
Thank you Lee Minardi, that was indeed a novel way to go about it š
For others looking for a simpler route, Alfred has suggested another solution to copy the rotated base with UCS to a new drawing centered at WCS here:
https://forums.autodesk.com/t5/autocad-forum/data-extraction-in-ucs-x-y-z/m-p/8265320#M948823
Thanks again everyone for your help.
Kind Regards
Ian
Can't find what you're looking for? Ask the community or share your knowledge.