Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Trans 3d point from Object to Current Ucs

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
gregmcl
876 Views, 10 Replies

Trans 3d point from Object to Current Ucs

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

10 REPLIES 10
Message 2 of 11
Moshe-A
in reply to: gregmcl

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

 

 

Message 3 of 11
Moshe-A
in reply to: gregmcl

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

 

Message 4 of 11
gregmcl
in reply to: Moshe-A

That doesn't seem to work.

 

The mapcar function returns the same point list ???

Message 5 of 11
Moshe-A
in reply to: gregmcl

 

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

 

 

 

Message 6 of 11
gregmcl
in reply to: Moshe-A

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.

Message 7 of 11
Moshe-A
in reply to: gregmcl

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

 

Message 8 of 11
Hallex
in reply to: gregmcl

 

If I understand you right maybe you want to use this

 

(setq move_list
(mapcar '(lambda (pt)(mapcar '+ pt base))PT-LIST)
      )

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 9 of 11
gregmcl
in reply to: Hallex

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

Message 10 of 11
Kent1Cooper
in reply to: gregmcl


@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)

Kent Cooper, AIA
Message 11 of 11
stevor
in reply to: gregmcl

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/Coordinate-from-Lwpolyline-to-WCS/td-...

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.

S

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

Post to forums  

Autodesk Design & Make Report

”Boost