(defun BlockToInsertSetup (InsertEname
/
InsertEList
ZAxis
NCSXAxis
InsertAngle
)
;; Get the Entity Association List of the insert and the Z
;; axis of the NCS (and OCS)
(setq ZAxis (cdr (assoc 210 (setq InsertEList (entget InsertEName))))
;; The OCS X axis is, in OCS, '(1 0 0). The NCS X axis is
;; therefore, in OCS,
;; ((cos InsertAngle) (sin InsertAngle) 0.0).
;; Transforming this vector to WCS gives the NCS X axis in
;; WCS:
InsertAngle (cdr (assoc 50 InsertEList))
NCSXAxis (trans (list (cos InsertAngle) (sin InsertAngle) 0.0)
(cdr (assoc 210 InsertEList))
0
) ;_ end trans
) ;_ end setq
;; Set up the return value
(list NCSXAxis
;; The Y axis of the NCS (it will be a unit vector
;; because it's the cross product of two unit
;; vectors at a right angle to each other)
(VectorCrossProduct ZAxis NCSXAxis)
ZAxis
;; The insertion point of the insert
(trans (cdr (assoc 10 InsertEList)) ZAxis 0)
;; The scale factors
(list (cdr (assoc 41 InsertEList))
(cdr (assoc 42 InsertEList))
(cdr (assoc 43 InsertEList))
) ;_ end list
) ;_ end list
) ;_ end defun
(defun VectorCrossProduct (InputVector1 InputVector2)
(list (- (* (cadr InputVector1) (caddr InputVector2))
(* (cadr InputVector2) (caddr InputVector1))
) ;_ end -
(- (* (caddr InputVector1) (car InputVector2))
(* (caddr InputVector2) (car InputVector1))
) ;_ end -
(- (* (car InputVector1) (cadr InputVector2))
(* (car InputVector2) (cadr InputVector1))
) ;_ end -
) ;_ end list
) ;_ end defun
(defun 3DTransformAB (XA YA ZA OA SA P1 /)
;; Scale the input point to "B" system units
(setq P1 (mapcar '* P1 SA))
;; Translate and set up the return value
(mapcar '+
OA
;; The following does the rotation transformation
(list (+ (* (car XA) (car P1))
(* (car YA) (cadr P1))
(* (car ZA) (caddr P1))
) ;_ end +
(+ (* (cadr XA) (car P1))
(* (cadr YA) (cadr P1))
(* (cadr ZA) (caddr P1))
) ;_ end +
(+ (* (caddr XA) (car P1))
(* (caddr YA) (cadr P1))
(* (caddr ZA) (caddr P1))
) ;_ end +
) ;_ end list
) ;_ end mapcar
) ;_ end defun
(defun 3DTransformBA (XA YA ZA OA SA P1 /)
;; Translate
(setq P1 (mapcar '- P1 OA))
;; Scale and set up the return value
(mapcar '/
;; The following does the rotation
(list (+ (* (car XA) (car P1))
(* (cadr XA) (cadr P1))
(* (caddr XA) (caddr P1))
) ;_ end +
(+ (* (car YA) (car P1))
(* (cadr YA) (cadr P1))
(* (caddr YA) (caddr P1))
) ;_ end +
(+ (* (car ZA) (car P1))
(* (cadr ZA) (cadr P1))
(* (caddr ZA) (caddr P1))
) ;_ end +
) ;_ end list
SA
) ;_ end mapcar
) ;_ end defun