Just in case anyone whats the code by itself. I thought it might be useful to some other lispers one day, so that is why it is here only. Hope my wording is correct, as far as what each item is, and how it is used.
Enjoy.
(defun RotateAtByVector ( obj pt vec ang / RotateAboutXAxis RotateAboutYAxis )
; obj = valid ' vla ' object
; pt = point in WCS, which will be used as base point of axis of rotation, along with ' vec ' as the vector
; vec = vector inwhich to rotate around
; ang = angle to rotate object, in radians
; Figured out how to rotate about an axis based on this site:
; http://local.wasp.uwa.edu.au/~pbourke/geometry/rotate/
(defun RotateAboutXAxis ( obj vec firstMulti secondMulti / Dist )
(if (not (equal (setq Dist (sqrt (+ (* (cadr vec) (cadr vec)) (* (caddr vec) (caddr vec))))) 0. 0.00000001))
(vla-TransFormBy
obj
(vlax-tmatrix
(list
(list 1. 0. 0. 0.)
(list 0. (/ (caddr vec) Dist) (firstMulti (/ (cadr vec) Dist)) 0.)
(list 0. (secondMulti (/ (cadr vec) Dist)) (/ (caddr vec) Dist) 0.)
(list 0. 0. 0. 1.)
)
)
)
)
)
;---------------------------------------------------------------------------------------------
(defun RotateAboutYAxis ( obj vec firstMulti secondMulti / Dist )
(setq Dist (sqrt (+ (* (cadr vec) (cadr vec)) (* (caddr vec) (caddr vec)))))
(vla-TransFormBy
obj
(vlax-tmatrix
(list
(list Dist 0. (firstMulti (car vec)) 0.)
(list 0. 1. 0. 0.)
(list (secondMulti (car vec)) 0. Dist 0.)
(list 0. 0. 0. 1.)
)
)
)
)
;---------------------------------------------------------------------------------------------
(vlax-invoke obj 'Move pt '(0. 0. 0.))
(RotateAboutXAxis obj vec - +)
(RotateAboutYAxis obj vec - +)
(vla-TransformBy
obj
(vlax-tmatrix
(list
(list (cos ang) (- (sin ang)) 0. 0.)
(list (sin ang) (cos ang) 0. 0.)
(list 0. 0. 1. 0.)
(list 0. 0. 0. 1.)
)
)
)
(RotateAboutYAxis obj vec + -)
(RotateAboutXAxis obj vec + -)
(vlax-invoke obj 'Move '(0. 0. 0.) pt)
)