PDA

View Full Version : Strange translation of part/assy [LISP]


Harry
05-07-2004, 03:28 AM
I made a little function to position a part/assy in the world. To my suprise the part always rotates first and then translates over the
vector vx,vy,vz.

After placing two position_pa calls in this function to sepperate translate and rotate actions, the result is the same!

Does anyone has clue what is going on here?


(defun position-part (&key partname vx vy vz ax ay az)
;function: move part over vector and angles
;date : 03-05-2004
;----------------------------------------------------------------------
;input : :partname [string] , name of part
; : :vx [number] , vector x
; : :vy [number] , vector y
; : :vz [number] , vector z
; : :ax [degr] , angle x
; : :ay [degr] , angle y
; : :az [degr] , angle z

(progn
;local vars
(let (3dpnt_1 3dpnt_2)
(setf 3dpnt_1 (make-gpnt3d :x 0 :y 0 :z 0))
(setf 3dpnt_2 (make-gpnt3d :x vx :y vy :z vz))

(POSITION_PA
partname
:TRANSLATE :TWO_PTV 3dpnt_1 3dpnt_2
:ROTATE :AXIS :X :ROTATION_ANGLE ax :done
:ROTATE :AXIS :Y :ROTATION_ANGLE ay :done
:ROTATE :AXIS :Z :ROTATION_ANGLE az :done
)

);let
);progn
);defun


Best regards

Harry

Wolfgang
05-08-2004, 10:46 AM
just a guess! I did not try at all


...
partname
:TRANSLATE :TWO_PTV 3dpnt_1 3dpnt_2 :DONE
:ROTATE :AXIS :X :ROTATION_ANGLE ax :done
...

Harry
05-10-2004, 03:07 AM
Originally posted by Wolfgang
...


...
partname
:TRANSLATE :TWO_PTV 3dpnt_1 3dpnt_2 :DONE
:ROTATE :AXIS :X :ROTATION_ANGLE ax :done
...
[/B]

When I add this parameter, the translation works fine now, but the rotation point moves now as well... :(

Harry
05-10-2004, 11:26 PM
I forgot something completely, the moving part has its own coord system! :(

So OSD worked like it was told, turn the part around the axis of the world coord system.

I changed the code to select the axis of the local coord system.


(defun position-part (&key partname vx vy vz ax ay az)
;function: move part over vector and angles
;date : 03-05-2004
;----------------------------------------------------------------------
;input : :partname [string] , name of part
; : :vx [number] , vector x
; : :vy [number] , vector y
; : :vz [number] , vector z
; : :ax [degr] , angle x
; : :ay [degr] , angle y
; : :az [degr] , angle z

(progn
;local vars
(let (3dpnt_1 3dpnt_2 a_csname)
(setf 3dpnt_1 (make-gpnt3d :x 0 :y 0 :z 0))
(setf 3dpnt_2 (make-gpnt3d :x vx :y vy :z vz))
(setf a_csname (format nil "~A/~A" partname "cs1"))

(POSITION_PA
partname
:TRANSLATE :TWO_PTV 3dpnt_1 3dpnt_2 :done
)

(POSITION_PA
partname
:ROTATE
:AXIS
(sd-inq-coord-sys-elem-type
(getf (sd-inq-coord-sys-elem a_csname :all t) :X-AXIS)
)
:ROTATION_ANGLE ax
:done
)

(POSITION_PA
partname
:ROTATE
:AXIS
(sd-inq-coord-sys-elem-type
(getf (sd-inq-coord-sys-elem a_csname :all t) :Y-AXIS)
)
:ROTATION_ANGLE ay
:done
)

(POSITION_PA
partname
:ROTATE
:AXIS
(sd-inq-coord-sys-elem-type
(getf (sd-inq-coord-sys-elem a_csname :all t) :Z-AXIS)
)
:ROTATION_ANGLE az
:done
)

);let
);progn
);defun


The problem I have now that I have the point to a coord system by calling its name. In this case 'a_csname'.
i get an error msg telling me that 'a_csname' is not a structur. (it is read as string, not an coord object)
Is there a way to initiate 'a_csname' as a coord system object?

Best regards Harry

Wolfgang
05-13-2004, 10:53 AM
I like that version with a single call of POSITION_PA much more.

(sd-inq-coord-sys-elem-type
(getf (sd-inq-coord-sys-elem a_csname :all t) :Y-AXIS)

looks strange to me

a)
coord-sys {SEL_ITEM} - The coordinate system to inquire.

your're passing a string to that function but a sel-item is required. -> to be corrected.

b)
I would recommend to use
(sd-inq-coord-sys-elem-value coord-sys :Y-AXIS T)
in this case

There's no need to use sd-inq-coord-sys-elem-type in this case.. because you already know that you would like to get the XYZ-Axis.

HTH

Harry
05-17-2004, 12:35 AM
For all of you how are interested, here is my final code. Thanks to all of you who lead me in the land of ((((())))).

Best regards,

Harry



(in-package :my-package)
(use-package :oli)


(sd-defdialog 'place_part
:dialog-title "coord"
:variables
'(
(partname
:title "Part"
:selection *sd-object-seltype*
:multipul-items t

)
(a_csname
:title "Coord Sys"
:selection *sd-coord-sys-object-seltype*
:multipul-items t
)

(vx
:value-type :number
:initial-value 0
)

(vy
:value-type :number
:initial-value 0
)

(vz
:value-type :number
:initial-value 0
)

(ax
:value-type :number
:initial-value 0
)

(ay
:value-type :number
:initial-value 0
)

(az
:value-type :number
:initial-value 0
)
)

:ok-action
'(progn
(my-position-part :partname (sd-inq-obj-pathname partname) :vx vx :vy vy :vz vz :ax ax :ay ay :az az)
)
)





(defun my-position-part (&key partname vx vy vz ax ay az)
;function: move part over vector and angles
;date : 03-05-2004

;----------------------------------------------------------------------
;input : :partname [string] , name of part
; : :vx [number] , vector x
; : :vy [number] , vector y
; : :vz [number] , vector z
; : :ax [degr] , angle x
; : :ay [degr] , angle y
; : :az [degr] , angle z


(progn
;local vars
(let (3dpnt_1 3dpnt_2 a_csname a_csname_tst)
(setf 3dpnt_1 (make-gpnt3d :x 0 :y 0 :z 0))
(setf 3dpnt_2 (make-gpnt3d :x vx :y vy :z vz))
(setf a_csname (format nil "~A/~A" partname "cs1"))
(setf a_csname (sd-pathname-to-obj a_csname ) )


(POSITION_PA
partname
:TRANSLATE :TWO_PTV 3dpnt_1 3dpnt_2 :done
)


(POSITION_PA
partname
:ROTATE
:AXIS :two_pta
(getf (sd-inq-coord-sys-elem-value a_csname :all t :dest-space :global) :ORIGIN)
(sd-vec-add
(getf (sd-inq-coord-sys-elem-value a_csname :all t :dest-space :global) :ORIGIN)
(getf (sd-inq-coord-sys-elem-value a_csname :all t :dest-space :global) :x-axis)
)
:ROTATION_ANGLE ax
:done
:ROTATE
:AXIS :two_pta
(getf (sd-inq-coord-sys-elem-value a_csname :all t :dest-space :global) :ORIGIN)
(sd-vec-add
(getf (sd-inq-coord-sys-elem-value a_csname :all t :dest-space :global) :ORIGIN)
(getf (sd-inq-coord-sys-elem-value a_csname :all t :dest-space :global) :y-axis)
)
:ROTATION_ANGLE ay
:done
:ROTATE
:AXIS :two_pta
(getf (sd-inq-coord-sys-elem-value a_csname :all t :dest-space :global) :ORIGIN)
(sd-vec-add
(getf (sd-inq-coord-sys-elem-value a_csname :all t :dest-space :global) :ORIGIN)
(getf (sd-inq-coord-sys-elem-value a_csname :all t :dest-space :global) :z-axis)
)
:ROTATION_ANGLE az
:done
);POSITION_PA
);let
);progn
);defun