Author Topic: Isometric Text Request  (Read 21085 times)

0 Members and 1 Guest are viewing this topic.

reltro

  • Guest
Re: Isometric Text Request
« Reply #30 on: May 30, 2014, 05:19:37 AM »
This may help to place an entitiy wich looks like to be isometric...

In this special case it is a block wich will be placed in 3D-space, but should be easy to modifiy for any kind of object...

Code - Auto/Visual Lisp: [Select]
  1. ;;;===============================================================================================
  2. ;;;                            ___...:::{INSERT BlockReference 3P}:::...___
  3. ;;;
  4. ;;;    Creates a BlockReference from three 3D-Points
  5. ;;;
  6. ;;;
  7. ;;;    ****
  8. ;;;    Author:    Reltro
  9. ;;;    Version:    1.0
  10. ;;;    Released:    29.06.2013
  11. ;;;    ****
  12. ;;;
  13. ;;;    Input:
  14. ;;;        - BlockName [STR]    ... Name of the BlockDefinition
  15. ;;;        - InsPt        [LST]     ... 3D-Point (WCS)
  16. ;;;        - xDir        [LST]     ... 3D-Point (WCS) - matches the positiv xDir of the BlockDefinition
  17. ;;;        - xyPlane    [LST]     ... 3D-Point (WCS) - matches the positiv-positiv xyPlane of the BlockDefinition
  18. ;;;
  19. ;;;        - xScale    [REAL]     ... ScaleFactor in xDirection
  20. ;;;        - yScale    [REAL]     ... ScaleFactor in yDirection
  21. ;;;        - zScale    [REAL]     ... ScaleFactor in zDirection
  22. ;;;        - zRot        [REAL]    ... Rotation around the zAxis (radians)
  23. ;;;
  24. ;;;    Return:
  25. ;;;        - BlockReference [VLA-Object]
  26. ;;;        
  27. ;;;===============================================================================================
  28. (defun InsBlockRef3P (BlockName InsPt xDir xyPlane xScale yScale zScale zRot / TransformationMatrix)
  29.  
  30.     (setq TransformationMatrix
  31.         (lambda (P1 P2 P3 / AAA tMatrix Rotation mxm)
  32.             ;;;-------------------------------------------------------------------------------------------
  33.             ;;;                    ___...:::{Abritrary Axis Algorithm}:::...___
  34.             ;;;
  35.             ;;; http://www.autodesk.com/techpubs/autocad/acadr14/dxf/arbitrary_axis_algorithm_al_u05_c.htm
  36.             (setq AAA
  37.                 (lambda (P1 P2 P3 / cross Ax Ay Az)
  38.                     (setq cross
  39.                         (lambda (V1 V2 / )
  40.                             (    (lambda (nV / o len)
  41.                                     (setq len (sqrt (apply '+ (foreach k nV (setq o (cons (expt k 2) o))))))
  42.                                     (mapcar '(lambda (a / ) (/ a len)) nV)
  43.                                 )
  44.                                 (mapcar
  45.                                     '(lambda (n / ) (- (* (nth (car n) V1) (nth (cadr n) V2)) (* (nth (cadr n) V1) (nth (car n) V2))))
  46.                                     '((1 2) (2 0) (0 1))
  47.                                 )
  48.                             )
  49.                         )
  50.                     )
  51.                     (setq    Az    (cross (mapcar '- P1 P2) (mapcar '- P1 P3))
  52.                             Ax    (if (and (< (abs (car Az)) (/ 1 64.0)) (< (abs (cadr Az)) (/ 1 64.0)))
  53.                                     (cross '(0 1 0) Az)
  54.                                     (cross '(0 0 1) Az)
  55.                                 )
  56.                             Ay    (cross Az Ax)
  57.                     )
  58.                     (list Ax Ay Az)
  59.                 )
  60.             )
  61.             ;;;-------------------------------------------------------------------------------------------
  62.  
  63.  
  64.             ;;;-------------------------------------------------------------------------------------------
  65.             (setq   mxm         (lambda (m v) (mapcar '(lambda (r) (apply '+ (mapcar '* r v))) m))
  66.                     Rotation    (lambda (V ang / m+m mxs vxs)
  67.                                     ;;; >>>>>>>>>
  68.                                     ;;; Lee Mac
  69.                                     (setq m+m   (lambda (m n) (mapcar '(lambda (r s) (mapcar '+ r s)) m n))
  70.                                              mxs    (lambda (m s) (mapcar '(lambda (r) (mapcar '(lambda (n) (* n s)) r)) m))
  71.                                              vxs     (lambda (v s) (mapcar '(lambda (n) (* n s)) v))
  72.                                     )
  73.  
  74.                                     (m+m
  75.                                         (list
  76.                                             (list (cos ang) 0. 0.)
  77.                                             (list 0. (cos ang) 0.)
  78.                                             (list 0. 0. (cos ang))
  79.                                         )
  80.                                         (m+m
  81.                                             (mxs
  82.                                                 (list
  83.                                                     (list 0. (- (nth 2 V)) (nth 1 V))
  84.                                                     (list (nth 2 V) 0. (- (nth 0 V)))
  85.                                                     (list (- (nth 1 V)) (nth 0 V) 0.)
  86.                                                 )
  87.                                                 (sin ang)
  88.                                             )
  89.                                             (mxs (mapcar '(lambda (e) (vxs V e)) V) (- 1. (cos ang)))
  90.                                         )
  91.                                     )
  92.                                     ;;; <<<<<<<<<
  93.                                 )
  94.             )
  95.             ;;;-------------------------------------------------------------------------------------------
  96.             (setq tMatrix (AAA P1 P2 P3))
  97.  
  98.             (append
  99.                 (mapcar
  100.                     '(lambda (v o / ) (append (mxm tMatrix v) (list o)))
  101.                     (Rotation
  102.                         (nth 2 tMatrix)
  103.                         (angle (mxm tMatrix P1) (mxm tMatrix P2))
  104.                     )
  105.                     P1
  106.                 )
  107.                 (list '(0 0 0 1))
  108.             )
  109.         )
  110.     )
  111.  
  112.         (vla-insertblock
  113.             (vlax-3d-point '(0 0 0))
  114.             BlockName
  115.             XScale
  116.             YScale
  117.             ZScale
  118.             zRot
  119.         )
  120.         (vlax-tMatrix (TransformationMatrix InsPt xDir xyPlane))
  121.     )
  122. )
  123.  



Edit : code=cadlisp-7
« Last Edit: August 10, 2014, 05:49:15 PM by Kerry »