sharpooth Posted August 11, 2011 Share Posted August 11, 2011 Hi Lee Mac and guys, I am using LM:GrText - it is working SUPER when is loaded from *.lsp , but if you start Vlisp compiler it gives an error: ; warning: run time evaluated expression: (LIST (QUOTE DEFUN) (QUOTE LM:GRTEXT) (QUOTE ( ... )) ... ) here is the code: ;;-----------------------=={ GrText }==-----------------------;; ;; ;; ;; Returns a grvecs pixel vector list relative to the origin ;; ;; encoding the supplied string. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url] ;; ;;------------------------------------------------------------;; ;; With thanks to ElpanovEvgeniy for the method of vector ;; ;; encoding to save me a lot of typing ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; str - String to be expressed in vector list format. ;; ;; col - Colour of Text (ACI Colour). ;; ;;------------------------------------------------------------;; ;; Returns: GrVecs Pixel Vector List relative to the Origin ;; ;;------------------------------------------------------------;; ;; Version 1.0 - 19-03-2011 ;; ;;------------------------------------------------------------;; (defun LM:GrText ( str col / c i l v y ) (setq v '( (" ") ("\t") ("!" 45 45 65 135) ("\"" 104 134 107 137) ("#" 43 63 46 66 84 94 87 97 115 135 118 138 72 78 103 109) ("$" 25 35 52 52 43 47 58 78 83 87 92 112 123 127 118 118 135 135) ("%" 52 52 63 63 74 74 85 85 96 96 107 107 118 118 129 129 47 48 67 68 56 56 59 59 113 114 133 134 122 122 125 125) ("&" 43 46 49 49 52 72 57 58 67 68 76 76 79 79 83 83 85 85 94 94 103 123 134 136 127 127) ("'" 105 135) ("(" 17 17 26 36 45 105 116 126 137 137) (")" 14 14 25 35 46 106 115 125 134 134) ("*" 73 74 76 77 84 86 92 98 104 106 113 114 116 117) ("+" 55 115 82 84 86 88) ("," 34 35 45 46 55 57) ("-" 83 88) ("." 45 46 55 56) ("/" 52 52 63 63 74 74 85 85 96 96 107 107 118 118 129 129) ("0" 44 47 134 137 53 123 58 128) ("1" 44 48 124 125 56 136) ("2" 43 48 53 53 64 64 75 75 86 86 97 97 108 128 134 137 123 123) ("3" 53 53 44 47 58 88 95 97 108 128 134 137 123 123) ("4" 46 48 57 137 78 78 73 76 83 83 94 94 105 115 126 126) ("5" 53 53 44 47 58 88 94 97 93 133 134 138) ("6" 44 47 58 88 95 97 84 84 53 113 124 124 135 137) ("7" 44 54 65 75 86 96 107 117 128 138 133 137 123 123) ("8" 44 47 94 97 134 137 53 83 58 88 103 123 108 128) ("9" 44 46 57 57 68 128 97 97 84 86 134 137 93 123) (":" 45 46 55 56 95 96 105 106) (";" 34 35 45 46 55 57 95 96 105 106) ("<" 47 47 56 56 65 65 74 74 83 83 94 94 105 105 116 116 127 127) ("=" 73 78 93 98) (">" 43 43 54 54 65 65 76 76 87 87 96 96 105 105 114 114 123 123) ("?" 45 45 65 75 86 86 97 97 108 128 134 137 123 123) ("@" 34 38 43 43 52 112 123 123 134 137 128 128 79 119 68 68 65 66 105 106 77 107 74 94) ("A" 41 43 47 49 52 62 58 68 73 77 83 93 87 97 104 114 106 116 125 135 133 134) ("B" 42 47 53 123 58 88 108 128 94 97 132 137) ("C" 44 47 53 53 58 58 62 112 123 123 134 136 127 127 108 138) ("D" 42 46 57 57 127 127 132 136 68 118 53 123) ("E" 42 48 58 58 94 95 86 106 132 137 128 138 53 123) ("F" 42 45 94 95 86 106 132 137 128 138 53 123) ("G" 44 47 53 53 58 78 86 89 62 112 123 123 134 136 127 127 108 138) ("H" 41 43 47 49 131 133 137 139 93 97 52 122 58 128) ("I" 43 47 133 137 55 125) ("J" 52 62 43 46 57 127 135 139) ("K" 42 44 48 49 132 134 136 138 53 123 84 85 95 95 106 116 127 127 76 76 67 67 58 58) ("L" 42 47 48 58 53 123 132 135) ("M" 41 43 47 49 52 122 58 128 131 132 138 139 103 113 107 117 84 94 86 96 65 75) ("N" 41 44 131 132 136 139 52 122 48 128 113 113 94 104 85 85 66 76 57 57) ("O" 44 46 53 53 57 57 123 123 127 127 134 136 62 112 68 118) ("P" 42 45 84 87 132 137 53 123 98 128) ("Q" 134 136 123 123 127 127 112 62 118 68 53 53 57 57 44 46 35 36 23 24 27 28) ("R" 42 44 48 49 132 137 123 53 128 98 84 87 76 76 67 67 58 58) ("S" 42 62 53 53 44 47 58 78 86 87 93 95 102 122 133 136 127 127 118 138) ("T" 43 47 55 125 132 138 131 121 139 129) ("U" 44 46 52 53 57 58 62 122 68 128 131 133 137 139) ("V" 45 55 64 74 66 76 83 103 87 107 112 122 118 128 131 133 137 139) ("W" 43 63 47 67 72 92 74 94 76 96 78 98 101 121 105 115 109 129 131 132 138 139) ("X" 41 43 47 49 131 133 137 139 52 52 58 58 63 63 67 67 74 74 76 76 85 95 104 104 106 106 113 113 117 117 122 122 128 128) ("Y" 43 47 55 85 94 94 96 96 103 113 107 117 122 122 128 128 131 133 137 139) ("Z" 122 122 58 58 132 138 42 48 128 128 52 52 63 63 74 74 85 95 106 106 117 117) ("[" 15 17 135 137 25 125) ("\\" 122 122 113 113 104 104 95 95 86 86 77 77 68 68 59 59) ("]" 14 16 134 136 26 126) ("^" 102 102 113 113 124 124 135 135 126 126 117 117 108 108) ("_" 21 29) ("`" 125 125 134 134) ("a" 43 46 48 48 52 72 57 97 83 86 103 106) ("b" 42 43 45 46 54 54 57 58 68 98 97 97 105 106 94 94 132 132 53 133) ("c" 44 46 53 53 57 58 52 92 93 93 104 106 97 98 108 108) ("d" 44 45 47 48 52 92 53 53 56 56 93 93 104 105 96 96 136 136 57 137) ("e" 44 46 53 53 57 58 52 92 93 93 104 106 97 98 88 88 73 78) ("f" 43 46 54 124 93 93 95 96 135 137 128 128) ("g" 13 16 22 32 27 97 107 108 66 66 96 96 54 55 104 105 63 63 93 93 62 92) ("h" 42 44 46 48 57 97 53 133 132 132 94 94 105 106) ("i" 43 47 55 105 103 104 135 135) ("j" 22 22 13 15 26 106 104 105 136 136) ("k" 42 44 46 48 53 133 132 132 57 57 66 66 74 75 85 85 96 106 107 108) ("l" 43 47 55 135 133 134) ("m" 41 43 45 46 48 49 52 102 55 105 58 108 101 101 93 93 104 104 96 96 107 107) ("n" 42 44 46 48 53 103 57 97 102 102 94 94 105 106) ("o" 44 46 104 106 53 53 57 57 93 93 97 97 52 92 58 98) ("p" 12 15 23 103 102 102 54 54 94 94 45 46 105 106 57 58 97 98 68 88) ("q" 15 18 27 107 108 108 56 56 96 96 44 45 104 105 52 53 92 93 62 82) ("r" 42 46 54 104 102 103 95 95 106 108 99 99) ("s" 52 52 43 47 58 68 73 77 82 92 103 107 98 98) ("t" 45 47 58 58 54 124 102 103 105 107) ("u" 102 102 106 106 53 103 56 56 44 45 47 107 48 48) ("v" 45 45 54 64 56 66 73 83 77 87 92 92 98 98 101 103 107 109) ("w" 43 53 47 57 62 92 64 84 66 86 68 98 101 103 95 105 107 109) ("x" 42 44 46 48 102 104 106 108 53 53 57 57 93 93 97 97 64 64 66 66 84 84 86 86 75 75) ("y" 12 13 24 24 35 45 54 64 56 66 73 83 77 87 92 92 98 98 101 103 107 109) ("z" 92 92 58 58 102 108 42 48 97 97 86 86 75 75 64 64 53 53) ("{" 16 17 25 65 73 74 85 125 136 137) ("|" 15 135) ("}" 14 15 26 66 77 78 86 126 134 135) ("~" 112 122 133 134 125 125 116 117 128 138) ) ) (eval (list 'defun 'LM:GrText '( str col / c i l v y ) (list 'setq 'v (list 'quote (mapcar (function (lambda ( b ) (cons (car b) (mapcar '(lambda ( a ) (if a (list (rem a 10) (/ a 10)))) (cdr b))) ) ) v ) ) ) '(setq i 0 y 0) '(repeat (strlen str) (cond ( (eq (setq c (substr str 1 1)) " ") (setq i (+ i 9) str (substr str 2)) ) ( (eq c "\t") (setq i (+ i 36) str (substr str 2)) ) ( (eq c "\n") (setq i 0 y (- y 16) str (substr str 2)) ) ( (setq l (cons (mapcar (function (lambda ( a ) (if a (list (+ (car a) i) (+ (cadr a) y))) ) ) (cdr (assoc c v)) ) l ) str (substr str 2) i (+ i 9) ) ) ) ) '(cons col (apply 'append l)) ) ) (LM:GrText str col) ) ;;------------------------------------------------------------;; ;; Test Functions ;; ;;------------------------------------------------------------;; (defun c:test1 ( / *error* _grvecs c g1 g2 gr s v ) (defun *error* ( msg ) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (redraw) (princ) ) (defun _grvecs ( pt vl / s ) (setq s (/ (getvar "viewsize") (cadr (getvar "SCREENSIZE")))) (grvecs vl ( (lambda ( r x y ) (list (list r 0. 0. x ) (list 0. r 0. y ) (list 0. 0. r 0.) (list 0. 0. 0. 1.) ) ) s (+ (car pt) (* 15 s)) (- (cadr pt) (* 31 s)) ) ) ) (setq s "" c 2) (princ "\nType Your Message...") (while (progn (setq gr (grread nil 15 0) g1 (car gr) g2 (cadr gr)) (cond ( (= 5 g1) (redraw) (not (if v (_grvecs (trans g2 1 3) v)))) ( (= 2 g1) (cond ( (= 8 g2) (if (< 0 (strlen s)) (setq v (LM:GrText (setq s (substr s 1 (1- (strlen s)))) c)) ) ) ( (= 9 g2) (setq v (LM:GrText (setq s (strcat s "\t")) c)) ) ( (= 13 g2) (setq v (LM:GrText (setq s (strcat s "\n")) c)) ) ( (< 31 g2 127) (setq v (LM:GrText (setq s (strcat s (chr g2))) c)) ) ) t ) ) ) ) (redraw) (princ) ) ;;------------------------------------------------------------;; (defun c:test2 ( / *error* g p s ) (defun *error* ( msg ) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (redraw) (princ) ) (while (= 5 (car (setq g (grread nil 13 0)))) (redraw) (setq p (mapcar 'rtos (trans (cadr g) 1 0)) s (/ (getvar "viewsize") (cadr (getvar "SCREENSIZE"))) g (trans (cadr g) 1 3) ) (grvecs (LM:GrText (strcat "X=" (car p) "\nY=" (cadr p)) 3) ( (lambda ( r x y ) (list (list r 0. 0. x ) (list 0. r 0. y ) (list 0. 0. r 0.) (list 0. 0. 0. 1.) ) ) s (+ (car g) (* 15 s)) (- (cadr g) (* 31 s)) ) ) ) (redraw) (princ) ) ;;------------------------------------------------------------;; Please help to solve the problem. May be problem is in (eval '...... '...... ) Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 11, 2011 Share Posted August 11, 2011 Hi Lee Mac and guys,I am using LM:GrText - it is working SUPER when is loaded from *.lsp , but if you start Vlisp compiler it gives an error: ; warning: run time evaluated expression: (LIST (QUOTE DEFUN) (QUOTE LM:GRTEXT) (QUOTE ( ... )) ... ) Hi Sharpooth, glad you like the program. The compile 'warning' appears because of the use of eval, but this is only a warning, not an error, and should not affect the resultant vlx/fas. Similar warnings appear when compiling programs using various forms of action_tile statements. here is the code: Where possible, I would prefer if you could post a hyperlink to the code in question, instead of the code in its entirety - otherwise I shall have many different versions of my programs strewn over the forums. Lee Quote Link to comment Share on other sites More sharing options...
sharpooth Posted August 11, 2011 Author Share Posted August 11, 2011 Hi Lee, I compiled the file. When run test1 or test2 the AutoCAD is hang down. In help of Autolisp I found : The function function is identical to the quote function, except it tells the Visual LISP compiler to link and optimize the argument as if it were a built-in function or defun. Compiled lambda expressions that are quoted by function will contain debugging information when loaded into the Visual LISP IDE. The Visual LISP compiler cannot optimize the quoted lambda expression in the following code: (mapcar '(lambda (x) (* x x)) '(1 2 3)) Is it posible this is the problem or no? Thanks Hi Sharpooth, glad you like the program. The compile 'warning' appears because of the use of eval, but this is only a warning, not an error, and should not affect the resultant vlx/fas. Similar warnings appear when compiling programs using various forms of action_tile statements. Where possible, I would prefer if you could post a hyperlink to the code in question, instead of the code in its entirety - otherwise I shall have many different versions of my programs strewn over the forums. Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 11, 2011 Share Posted August 11, 2011 I compiled the file. When run test1 or test2 the AutoCAD is hang down. I see - this is probably caused by the 'LM:GrText' function being recursively redefined within its own function definition. I use this construct to improve performance for subsequent function calls, however it may not perhaps be compatible with compilation. Why are you compiling it anyway? Quote Link to comment Share on other sites More sharing options...
sharpooth Posted August 11, 2011 Author Share Posted August 11, 2011 Because it is a part from program which draw rectangles and I need to write b and h of them. I see - this is probably caused by the 'LM:GrText' function being recursively redefined within its own function definition. I use this construct to improve performance for subsequent function calls, however it may not perhaps be compatible with compilation. Why are you compiling it anyway? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 11, 2011 Share Posted August 11, 2011 What do you mean by: I need to write b and h of them. Quote Link to comment Share on other sites More sharing options...
sharpooth Posted August 11, 2011 Author Share Posted August 11, 2011 Width / b / of rectangle and high / h /of rectangle What do you mean by: Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 11, 2011 Share Posted August 11, 2011 Width / b / of rectangle and high / h /of rectangle So why would that mean you would need to compile the code? Quote Link to comment Share on other sites More sharing options...
sharpooth Posted August 12, 2011 Author Share Posted August 12, 2011 (edited) I have an idea to sell my program. So why would that mean you would need to compile the code? Edited August 12, 2011 by sharpooth Quote Link to comment Share on other sites More sharing options...
dbroada Posted August 12, 2011 Share Posted August 12, 2011 I have an idea to sell my program.YOUR program - not Lee's? Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted August 12, 2011 Share Posted August 12, 2011 I have an idea to sell my program. haha, that was honest you better read this http://lee-mac.com/terms.html Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2011 Share Posted August 12, 2011 I have an idea to sell my program. Then you had better remove my code from it. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 12, 2011 Share Posted August 12, 2011 I have an idea to sell my program. Is it yours to say that ? you may need to read about Author's rights very carefully . Quote Link to comment Share on other sites More sharing options...
sharpooth Posted August 12, 2011 Author Share Posted August 12, 2011 Wait, wait wait...., I will not insert Lee's code in my program. I want to take an idea how to to make custom Grtext (the engine). Now I understood (in my way) how to do the engine and I will post my code for FREE OF USE, NO LIMITS. About the Author's rights I never break it. I have read lee-mac's tutorials - it is good, but from now - stop. So in the end - when I post my code of GrText, I want from You to excuse. Thanks Quote Link to comment Share on other sites More sharing options...
sharpooth Posted August 12, 2011 Author Share Posted August 12, 2011 because I am very insulted from this case I am posting MY code unfinished : ; for free use ; Read closely the comments to understand the logic of works of code (defun c:go () ; ver 1.0 (setq vl nil) (setq i 0) (repeat 2 ; we can put (strlen... ) to repeat for evry character in string (setq vlist ; making list ONLY with vectors without color (cons (mapcar; i is step by X. 0 is for Step by Y '(lambda (x) (list (+ (car x) i) (+ (cadr x) 0))) '((2 10) (2 10) (6 10) (6 10) (3 5) (3 10) (6 5) (6 5) (4 4) (5 4) (7 4) (7 10) (8 4) (8 4)) ; this u character describe (point by point by point) ; If We make a list (point by point by point) with all alphabet will receive every message on screen.Now is just "u" char ) vlist) ) (setq i (+ 10 i)) ; Next interval (step by X) );repeat (setq vl1 (cons 2 (apply 'append vlist))) ; Here put color 2 / yellow / in vector list (while (setq drag (grread t 4 0)) (if (= (type (nth 1 drag)) 'LIST) (progn (redraw) (setq s (/ (getvar "viewsize") (cadr (getvar "SCREENSIZE")))) ; this scale factor to receive constant high of character on screen (grvecs vl1 ((lambda ( Scale PosX PosY ) ; define anonymous function (list (list Scale 0. 0. PosX ) ; Matrix for scaling (list 0. Scale 0. PosY ) (list 0. 0. Scale 0.) (list 0. 0. 0. 1.) ) ) s ; Scale (+ (car (nth 1 drag)) (* 15 s)) ;PosX (- (cadr (nth 1 drag)) (* 31 s)) ;PosY )) )) (princ drag) ; );while ) Next step is to make list (point by point by point) (0 0) (2 2) (15 2) ...... and so on, with all alphabetic characters. Next step is to write code for joint all lists of characters in one list. May be I have to use mapcar and append. But I am beginner and need time to do it. Thank you for your attention! If you have questions please.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.