Author Topic: Isometric Text Request  (Read 15315 times)

0 Members and 1 Guest are viewing this topic.

bayoubuoy

  • Guest
Isometric Text Request
« on: March 10, 2011, 01:13:06 PM »
Hi Y'all,
Does anyone have a routine(s) from which I can set up a toolbar (vanilla 2005)
to change the plane (rotation and slant) of a previously created text string
in any one of the 8 options to any other of the options?
The text is created by three text styles, standard, iso30 and iso330.
The preferred operation would be to select the desired form from a toolbar button
that executes the appropiate function, then to select the text string to change?
I have used a commercial product that does this.

« Last Edit: March 10, 2011, 09:30:38 PM by bayoubuoy »

barc

  • Guest
Re: Isometric Text Request
« Reply #1 on: March 10, 2011, 01:17:49 PM »
Rather than a lisp,why not just define three text styles with different obliquing angles; vertical, +30 and -30.  Then you just need to modify the style of the appropriate text entities.

M-dub

  • Guest
Re: Isometric Text Request
« Reply #2 on: March 10, 2011, 01:26:21 PM »
For what it's worth...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10395
Re: Isometric Text Request
« Reply #3 on: March 10, 2011, 03:00:50 PM »
I have collected, not tried, a few but they are old routines.

I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10395
Re: Isometric Text Request
« Reply #4 on: March 10, 2011, 03:51:22 PM »
OK here is one that I have used and works well except for dimensions.
http://cadtips.cadalyst.com/solids/iso-view-drafting-tool

Code: [Select]
;;; CADALYST 08/05 Tip 2052: Iso_Views.lsp ISO View Drafting Tool (c) Lloyd Beachy

;***********************************************************
;Iso_Views.lsp                        (c) 2005 Lloyd Beachy
;A routine to redraw objects into an isometric view        
;Works with lines, circles, arcs, text, lwplines, & splines
;***********************************************************

PS the DCL may have some spelling error so here is a working version
Code: [Select]
iso : dialog {label="Isometric Views";
  : row {
    : boxed_column {label="Include:";
      : toggle {key="line";label="Lines";}
      : toggle {key="circle";label="Circles";}
      : toggle {key="arc";label="Arcs";}
      : toggle {key="text";label="Text";}
      : toggle {key="lwpolyline";label="LWPlines";}
      : toggle {key="spline";label="Splines";}
    }
    : boxed_column {label="Select drawing plane:";
      : row {
        spacer_0;
        : image_button {key="left";width=10;aspect_ratio=1;fixed_width=true;color=254;}
        : image_button {key="right";width=10;aspect_ratio=1;fixed_width=true;color=254;}
        spacer_0;
      }
      : row {
        spacer_0;
        : image_button {key="top_left";width=10;aspect_ratio=1;fixed_width=true;color=254;}
        : image_button {key="top_right";width=10;aspect_ratio=1;fixed_width=true;color=254;}
        spacer_0;
      }
      spacer;
    }
  }
  spacer;
  : row {:spacer{width=17;}cancel_button;help_button;spacer_1;}
}
« Last Edit: March 10, 2011, 03:55:13 PM by CAB »
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10395
Re: Isometric Text Request
« Reply #5 on: March 10, 2011, 03:58:09 PM »
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12514
  • London, England
Re: Isometric Text Request
« Reply #6 on: March 10, 2011, 07:42:36 PM »
A fun one:

Code: [Select]
(defun c:isotext ( / e i j ) (vl-load-com) (setq i (/ pi 6.) j -1.)
  ;; Lee Mac 2011
  (if
    (and
      (setq e (car (entsel "\nSelect Text: ")))
      (eq (vla-get-Objectname (setq e (vlax-ename->vla-object e))) "AcDbText")
      (princ "\nPress [Tab] to Change Projection <Accept>")
    )     
    (while (= 9 (cadr (grread nil 14 0)))
      (vla-put-rotation     e i)
      (vla-put-obliqueangle e (setq i (* i (setq j (- j)))))
    )
  )
  (princ)
)



Or, for a general object, one can use the appropriate transformation matrix to rotate the object about two axes:

Code: [Select]
;;-----------------=={ Isometric Projection }==---------------;;
;;                                                            ;;
;;  Isometrically Projects a VLA-Object or Point List using a ;;
;;  Transformation Matrix to the specified view.              ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  target - VLA-Object or Point List to transform            ;;
;;  p1     - Base Point for Transformation                    ;;
;;  view   - String specifying view: NE,NW,SE,SW              ;;
;;------------------------------------------------------------;;

(defun LM:IsometricProjection ( target p1 view )
  (
    (lambda ( m )
      (LM:ApplyMatrixTransformation target m (mapcar '- p1 (mxv m p1)))
    )
    (mxs
      (cadr
        (assoc view
          (list
            (list "SE"
              (list
                (list    (sqrt 3.)     (sqrt 3.)         0.    )
                (list       -1.            1.            2.    )
                (list    (sqrt 2.)  (- (sqrt 2.))    (sqrt 2.) )
              )
            )
            (list "SW"
              (list
                (list    (sqrt 3.)  (- (sqrt 3.))        0.    )
                (list        1.            1.            2.    )
                (list (- (sqrt 2.)) (- (sqrt 2.))    (sqrt 2.) )
              )
            )
            (list "NE"
              (list
                (list    (sqrt 3.)        0.      (- (sqrt 3.)))
                (list        1.           2.             1.    )
                (list    (sqrt 2.)  (- (sqrt 2.))    (sqrt 2.) )
              )
            )
            (list "NW"
              (list
                (list    (sqrt 3.)        0.         (sqrt 3.) )
                (list       -1.           2.             1.    )
                (list (- (sqrt 2.)) (- (sqrt 2.))    (sqrt 2.) )
              )
            )
          )
        )
      )
      (/ (sqrt 6.) 6.)
    )
  )
)

;;-----------=={ Apply Matrix Transformation }==--------------;;
;;                                                            ;;
;;  Transforms a VLA-Object or Point List using a             ;;
;;  Transformation Matrix                                     ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright 2010 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  target - VLA-Object or Point List to Transform            ;;
;;  matrix - 3x3 Matrix by which to Transform object          ;;
;;  vector - 3D translation vector                            ;;
;;------------------------------------------------------------;;

(defun LM:ApplyMatrixTransformation ( target matrix vector ) (vl-load-com)
  ;; Lee Mac 2010
  (cond
    ( (eq 'VLA-OBJECT (type target))
     
      (vla-TransformBy target
        (vlax-tMatrix
          (append (mapcar '(lambda ( x v ) (append x (list v))) matrix vector)
           '((0. 0. 0. 1.))
          )
        )
      )
    )
    ( (listp target)

      (mapcar
        (function
          (lambda ( point ) (mapcar '+ (mxv matrix point) vector))
        )
        target
      )
    )       
  )
)

;; Matrix x Vector  -  Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n

(defun mxv ( m v )
  (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)

;; Matrix x Scalar - Lee Mac 2010
;; Args: m - nxn matrix, n - real scalar

(defun mxs ( m s )
  (mapcar '(lambda ( r ) (mapcar '(lambda ( n ) (* n s)) r)) m)
)

Test Function:

Code: [Select]
(defun c:projectobject ( / e p v )
  (if
    (and
      (setq e (car (entsel)))
      (setq p (getpoint "\nBase Point: "))
      (progn
        (initget 1 "NE NW SE SW")
        (setq v (getkword "\nSelect View [NE/NW/SE/SW]: "))
      )
    )
    (LM:IsometricProjection (vlax-ename->vla-object e) (trans p 1 0) v)
  )
  (princ)
)

(Note: the above result will be 3D, remove Z-Coord to project to the XY-Plane)
« Last Edit: January 06, 2012, 07:46:50 AM by Lee Mac »

bayoubuoy

  • Guest
Re: Isometric Text Request
« Reply #7 on: March 10, 2011, 08:06:53 PM »
@CAB,
Thanks for the offerings. The following is my results:
Iso Text.lsp works, but is limited to three options. Also requires command line entry.
ISOCAD.LSP errored.
ISOMK.LSP works, but is limited to two options. Also requires command line entry.
ISO Text.lsp is for creating iso text.

@Lee Mac,
You never cease to amaze me how you can use so few lines of code to do so much.
Your isotext.lsp certainly is fun and would be perfect if it cycled through the standard
and two vertical options too.
Thanks much.
« Last Edit: March 13, 2011, 12:20:41 AM by bayoubuoy »

Lee Mac

  • Seagull
  • Posts: 12514
  • London, England
Re: Isometric Text Request
« Reply #8 on: March 11, 2011, 07:24:48 AM »
@Lee Mac,
You never cease to amaze me how you can use so few lines of code to do so much.
Your isotext.lsp certainly is fun and would be perfect if it cycled through the standard
and two vertical options too.
Thanks much.

Thanks Bayoubuoy  8-)

I could incorporate the vertical views, but this would unfortunately disrupt the concision of the code  :|

alanjt

  • Needs a day job
  • Posts: 5340
  • Standby for witty remark...
Re: Isometric Text Request
« Reply #9 on: March 11, 2011, 07:29:04 AM »
@Lee Mac,
You never cease to amaze me how you can use so few lines of code to do so much.
Your isotext.lsp certainly is fun and would be perfect if it cycled through the standard
and two vertical options too.
Thanks much.

Thanks Bayoubuoy  8-)

I could incorporate the vertical views, but this would unfortunately disrupt the concision of the code  :|
I'm hesitant to implement it however as (now this is going to sound a bit OCD'ish) I feel it would spoil the logical cleanliness of the program - currently the code and interface is clean-cut: a list of collections and a list of items for each collection - introducing the metric/imperial filter would, I believe, only apply to a few collections hence making the code uglier... is it wrong to value the flow of the source code over the limited functionality of the program?

^-^
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12514
  • London, England
Re: Isometric Text Request
« Reply #10 on: March 11, 2011, 07:31:36 AM »
 :evil:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10395
Re: Isometric Text Request
« Reply #11 on: March 11, 2011, 08:30:07 AM »
Perhaps this wouldn't be too much. :evil:
Code: [Select]
      (or (eq (vla-get-Objectname (setq e (vlax-ename->vla-object e))) "AcDbText")
          (prompt "\n**  ERROR - Must be plain text  **"))
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12514
  • London, England
Re: Isometric Text Request
« Reply #12 on: March 11, 2011, 08:31:36 AM »
Perhaps this wouldn't be too much. :evil:
Code: [Select]
      (or (eq (vla-get-Objectname (setq e (vlax-ename->vla-object e))) "AcDbText")
          (prompt "\n**  ERROR - Must be plain text  **"))

I think that would be acceptable  :lol:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10395
Re: Isometric Text Request
« Reply #13 on: March 11, 2011, 08:38:56 AM »
@CAB,
Thanks for the offerings.

You're welcome, glad Lee came up with a cool routine. 8-)

You should try the one with the DCL though, you'll like it too.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Stefan

  • Bull Frog
  • Posts: 255
Re: Isometric Text Request
« Reply #14 on: March 11, 2011, 09:43:51 AM »
Lee, too much disruptions in this?

Code: [Select]
(defun c:isotext ( / e i j k)
  (vl-load-com)
 ;(setq i (/ pi 6.) j -1.)
  (setq i 0 k (/ pi 6.) j -1.)
  ;; Lee Mac 2011
  (if
    (and
      (setq e (car (entsel "\nSelect Text: ")))
      (eq (vla-get-Objectname (setq e (vlax-ename->vla-object e))) "AcDbText")
      (princ "\nPress [Tab] to Change Projection <Accept>")
    )     
    (while (= 9 (cadr (grread nil 14 0)))
     ;(vla-put-rotation     e i)
      (vla-put-rotation     e (* k (1- (* 2 (setq i (rem (+ i (max 0 (setq j (- j)))) 3))))))
     ;(vla-put-obliqueangle e (setq i (* i (setq j (- j)))))
      (vla-put-obliqueangle e (* j k))
    )
  )
  (princ)
)