Hi Tim,
I'm not sure to understand what you want to do with 'ename->4x4Matrix', but it seams to be : return the same 4X4 matrix as the one returned by 'nentselp' on a non nested entity in a reference (block or xref).
Here's the way I do it. Note I'd rather deal with 3X3 matrices than 4X4 matrices for scales and rotations, and then add a fourth column (deplacement) and the last row (0.0 0.0 0.0 1.0).
As said Joe, if the reference is non uniformaly scaled, the matrix shouldn't be used with 'vla-TransformBy'.
I purpose also another way to get OCS axis using 'trans'.
(mapcar '(lambda (v) (trans v ename 0 T))
'((1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0))
)
returns the same thing as
(
SCO (cdr (assoc 210 entData)))
EDIT: I change 'ename' argument to 'norm' in the (trans ...) expression, because it didn't work with nested entities in 'testCopyObject'.
;; Multiply two matrices by Vladimir Nesterovsky
;; Arguments : two matrices
;; Return : the matrices combination
;; Attention : (mxm mat1 mat2) is not equal to (mxm mat2 mat1)
(defun mxm (m q)
(mapcar '(lambda (r)
(mapcar '(lambda (l) (apply '+ (mapcar '* l r)))
(apply 'mapcar (cons 'list q))
)
)
m
)
)
(defun ename->4x4Matrix (ename / entData ang norm mat)
(setq entData (entget ename))
(setq ang (- (cdr (assoc 50 entData))))
(setq norm (cdr (assoc 210 entData)))
;; a 3X3 matrix as this returned by (butlast (caddr (nentsel)))
(setq mat (mxm
;; scale
(list (list (cdr (assoc 41 entData)) 0.0 0.0)
(list 0.0 (cdr (assoc 42 entData)) 0.0)
(list 0.0 0.0 (cdr (assoc 43 entData)))
)
(mxm
;; rotation on Z axis ...
(list (list (cos ang) (- (sin ang)) 0.0)
(list (sin ang) (cos ang) 0.0)
'(0.0 0.0 1.0)
)
;; ... of OCS
(mapcar '(lambda (v) (trans v norm 0 T))
'((1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0))
)
)
)
)
;; the 4X4 matrix as this returned by (caddr (nentselp))
(append
(mapcar
'(lambda (v1 v2)
(append v1 (list v2))
)
(apply 'mapcar (cons 'list mat)) ; transposed 3X3 matrix
(trans (cdr (assoc 10 entData)) norm 0) ; deplacement
)
(list '(0.0 0.0 0.0 1.0))
)
)