Hi,
I'm having a lot of trouble converting a set of points I have calculated relative to a line object, that is the line start point is 0,0 and 4 points may be (5,5,5) (5,5,-5)(-5,5,5)(-5,-5,-5). The start point in the World could be say (1000,1000,1000). I need to calculate these 4 points relatve to the WCS.
I have tried (TRANS PT-LIST (CDR (ASSOC -1 LINE-ENT)) 0) but this returns the original point list... I can create a 3dpoly, get its points which are in the WCS, but if I want to convert to another UCS I cant.
Any help appreciated.
Greg
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Greg,
if you have the following point list in some UCS then you could
transfer them to WCS this way:
(setq ent (car (entsel "\nSelect reference line in UCS: ")))
(setq PT-LIST (list '(5.0 5.0 5.0) '(5.0 5.0 -5.0) '(-5.0 5.0 5.0) '(-5.0 -5.0 -5.0)
(mapcar '(lambda (pt)
(trans pt ent 0)
)
PT-LIST
)
Cheers
Moshe
Or
if you have the following point list in WCS then you could
transfer them to current UCS this way:
(setq ent (car (entsel))) ; object in WCS
(setq PT-LIST (list '(5.0 5.0 5.0) '(5.0 5.0 -5.0) '(-5.0 5.0 5.0) '(-5.0 -5.0 -5.0)))
(mapcar '(lambda (pt)
(trans pt ent 1)
)
PT-LIST
)
Cheers
Moshe
maybe you are missing something?
i draw a 3dpoly exctly as you specified then i got it's ename
_$ (setq ent (entlast))
_$
_$ (setq PT-LIST (list '(5.0 5.0 5.0) '(5.0 5.0 -5.0) '(-5.0 5.0 5.0) '(-5.0 -5.0 -5.0)))
((5.0 5.0 5.0) (5.0 5.0 -5.0) (-5.0 5.0 5.0) (-5.0 -5.0 -5.0))
_$
i rotate my ucs (from wcs) about X axis 45 degree
_$ (mapcar '(lambda (pt)
(trans pt ent 1)
)
PT-LIST
)
((5.0 7.07107 -4.44089e-016) (5.0 -4.44089e-016 -7.07107) (-5.0 7.07107 -4.44089e-016) (-5.0 -7.07107 4.44089e-016))
_$
and this is the responds
Moshe,
Thanks, but I think you missed my original Intent.
The Entity I am selecting is a line, and the points are relative to the Object UCS.
For Example a Line from '(1000 1000 1000) to '(3000 1000 1000) has points '(5.0 5.0 5.0) '(5.0 5.0 -5.0) '(-5.0 5.0 5.0) '(-5.0 -5.0 -5.0) relative to the Line. These points in the WCS would be '(1005.0 1005.0 1005.0) '(1005.0 1005.0 995.0) '(995.0 1005.0 1005.0) '(995.0 995.0 995.0).
I have a feeling that the solution lies in a displacement vector in the Trans Function (the optional 4th arguement), but I don't know how to come up with it.
If all else fails a creating a 3dpoly, and extracting the points from it will be a solution, however I was trying to avoid the overhead of creating a entity I don't always need, and then deleting it.
Thanks for you input.
Cheer
Greg.
Greg,
to tell you the truth i do not either know what the the 4th argument does
(except that it treats the point as vector - never use it before)
but you could easly calulate your points this way without a need to draw the 3dpoly
(setq base '(1000.0 1000.0 1000.0))
(setq PT-LIST (list '(5.0 5.0 5.0) '(5.0 5.0 -5.0) '(-5.0 5.0 5.0) '(-5.0 -5.0 -5.0)))
(mapcar '(lambda (pt)
(+ (car base) (car pt))
(+ (cadr base) (cadr pt))
(+ (caddr base) (caddr pt))
)
PT-LIST
)
now go to your (trans)
Moshe
If I understand you right maybe you want to use this
(setq move_list
(mapcar '(lambda (pt)(mapcar '+ pt base))PT-LIST)
)
~'J'~
Gents,
Thanks for that, but these solutions only work if the line is parallel to the WCS.... Once the line is rotated in either XY Plane or XZ Plane it doesn't work
I think I'll have to revert to creating a 3dpoly, and getting the points from there. It either that or make a study of Transformation Matrix, which is a little above my abilities.... 🙂
Thanks for your help
Cheers
Greg
@gregmcl wrote:...these solutions only work if the line is parallel to the WCS.... Once the line is rotated in either XY Plane or XZ Plane it doesn't work
....
If, when in the World Coordinate System, you draw a Line from 1,1,1 to 2,2,2 [which is, of course, neither in nor parallel to the WCS XY plane], you'll find that its extrusion direction (the 210 entry at the end of the entity data list) is still the WCS's 0,0,1. That may be why when you try to translate a point from its coordinate system to the WCS, or vice versa, it doesn't change the coordinates:
Command: (trans '(1 1 1) (entlast) 0)
(1.0 1.0 1.0)
Command: (trans '(1 1 1) 0 (entlast))
(1.0 1.0 1.0)
However, if you align the Coordinate System with that Line, using the Object option in the UCS command, and then translate between the then-current UCS and the WCS in either direction, it does:
Command: (trans '(1 1 1) 1 0)
(1.0 2.41421 2.0)
Command: (trans '(1 1 1) 0 1)
(0.0 0.0 0.0)
That process, of point coords from a non-WCS WPOLYLINE to the WCs, is an ordinary method and you should have seen a solution by now.
Googled it?
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Polyline-List/td-p/807955
Or, post your pline, in a small DWG, format 2000 with minmal other objects and no reactors.