sharpooth 发表于 2022-7-6 09:03:17

Help Lee Mac for LM:GrText ...

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 - www.lee-mac.com       ;;;;------------------------------------------------------------;;;;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")   ("!"   454565 135)   ("\"" 104 134 107 137)   ("#"   4363466684948797 115 135 118 1387278 103 109)   ("$"   2535525243475878838792 112 123 127 118 118 135 135)   ("%"   52526363747485859696 107 107 118 118 129 1294748676856565959 113 114 133 134 122 122 125 125)   ("&"   4346494952725758676876767979838385859494 103 123 134 136 127 127)   ("'"105 135)   ("("   1717263645 105 116 126 137 137)   (")"   1414253546 106 115 125 134 134)   ("*"   7374767784869298 104 106 113 114 116 117)   ("+"   55 11582848688)   (","   343545465557)   ("-"   8388)   ("."   45465556)   ("/"   52526363747485859696 107 107 118 118 129 129)   ("0"   4447 134 13753 12358 128)   ("1"   4448 124 12556 136)   ("2"   434853536464757586869797 108 128 134 137 123 123)   ("3"   5353444758889597 108 128 134 137 123 123)   ("4"   464857 1377878737683839494 105 115 126 126)   ("5"   535344475888949793 133 134 138)   ("6"   444758889597848453 113 124 124 135 137)   ("7"   445465758696 107 117 128 138 133 137 123 123)   ("8"   44479497 134 13753835888 103 123 108 128)   ("9"   4446575768 12897978486 134 13793 123)   (":"   454655569596 105 106)   (";"   3435454655579596 105 106)   (""   434354546565767687879696 105 105 114 114 123 123)   ("?"   4545657586869797 108 128 134 137 123 123)   ("@"   3438434352 112 123 123 134 137 128 12879 11968686566 105 10677 1077494)   ("A"   4143474952625868737783938797 104 114 106 116 125 135 133 134)   ("B"   424753 1235888 108 1289497 132 137)   ("C"   44475353585862 112 123 123 134 136 127 127 108 138)   ("D"   42465757 127 127 132 13668 11853 123)   ("E"   42485858949586 106 132 137 128 13853 123)   ("F"   4245949586 106 132 137 128 13853 123)   ("G"   444753535878868962 112 123 123 134 136 127 127 108 138)   ("H"   41434749 131 133 137 139939752 12258 128)   ("I"   4347 133 13755 125)   ("J"   5262434657 127 135 139)   ("K"   42444849 132 134 136 13853 12384859595 106 116 127 127767667675858)   ("L"   4247485853 123 132 135)   ("M"   4143474952 12258 128 131 132 138 139 103 113 107 117849486966575)   ("N"   4144 131 132 136 13952 12248 128 113 11394 104858566765757)   ("O"   444653535757 123 123 127 127 134 13662 11268 118)   ("P"   42458487 132 13753 12398 128)   ("Q"134 136 123 123 127 127 11262 11868535357574446353623242728)   ("R"   42444849 132 137 12353 128988487767667675858)   ("S"   426253534447587886879395 102 122 133 136 127 127 118 138)   ("T"   434755 125 132 138 131 121 139 129)   ("U"   44465253575862 12268 128 131 133 137 139)   ("V"   45556474667683 10387 107 112 122 118 128 131 133 137 139)   ("W"   436347677292749476967898 101 121 105 115 109 129 131 132 138 139)   ("X"   41434749 131 133 137 1395252585863636767747476768595 104 104 106 106 113 113 117 117 122 122 128 128)   ("Y"   4347558594949696 103 113 107 117 122 122 128 128 131 133 137 139)   ("Z"122 1225858 132 1384248 128 1285252636374748595 106 106 117 117)   ("["   1517 135 13725 125)   ("\\" 122 122 113 113 104 10495958686777768685959)   ("]"   1416 134 13626 126)   ("^"102 102 113 113 124 124 135 135 126 126 117 117 108 108)   ("_"   2129)   ("`"125 125 134 134)   ("a"   43464848527257978386 103 106)   ("b"   424345465454575868989797 105 1069494 132 13253 133)   ("c"   44465353575852929393 104 1069798 108 108)   ("d"   444547485292535356569393 104 1059696 136 13657 137)   ("e"   44465353575852929393 104 106979888887378)   ("f"   434654 12493939596 135 137 128 128)   ("g"   131622322797 107 108666696965455 104 105636393936292)   ("h"   42444648579753 133 132 1329494 105 106)   ("i"   434755 105 103 104 135 135)   ("j"   2222131526 106 104 105 136 136)   ("k"   4244464853 133 132 132575766667475858596 106 107 108)   ("l"   434755 135 133 134)   ("m"   41434546484952 10255 10558 108 101 1019393 104 1049696 107 107)   ("n"   4244464853 1035797 102 1029494 105 106)   ("o"   4446 104 106535357579393979752925898)   ("p"   121523 103 102 102545494944546 105 106575897986888)   ("q"   151827 107 108 108565696964445 104 105525392936282)   ("r"   424654 104 102 1039595 106 1089999)   ("s"   52524347586873778292 103 1079898)   ("t"   4547585854 124 102 103 105 107)   ("u"102 102 106 10653 1035656444547 1074848)   ("v"   4545546456667383778792929898 101 103 107 109)   ("w"   435347576292648466866898 101 10395 105 107 109)   ("x"   42444648 102 104 106 108535357579393979764646666848486867575)   ("y"   121324243545546456667383778792929898 101 103 107 109)   ("z"   92925858 102 108424897978686757564645353)   ("{"   16172565737485 125 136 137)   ("|"   15 135)   ("}"   14152666777886 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 r0. 0. x )         (list 0. r0. y )         (list 0. 0. r0.)         (list 0. 0. 0. 1.)         )       )       s       (+ (carpt) (* 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 r0. 0. x )         (list 0. r0. y )         (list 0. 0. r0.)         (list 0. 0. 0. 1.)         )       )       s       (+ (carg) (* 15 s))       (- (cadr g) (* 31 s))   )   ) ) (redraw) (princ));;------------------------------------------------------------;;
 
Please help to solve the problem. May be problem is in (eval '...... '...... )
 
Thanks

Lee Mac 发表于 2022-7-6 09:08:17

 
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

sharpooth 发表于 2022-7-6 09:12:07

Hi Lee,
I compiled the file. When run test1 or test2 the AutoCAD is hang down.
 
In help of Autolisp I found :
 
 
Is it posible this is the problem or no?
 
 
Thanks
 
 

Lee Mac 发表于 2022-7-6 09:18:06

 
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?

sharpooth 发表于 2022-7-6 09:24:44

Because it is a part from program which draw rectangles and I need to write b and h of them.
 

Lee Mac 发表于 2022-7-6 09:26:57

What do you mean by:

sharpooth 发表于 2022-7-6 09:30:44

Width / b / of rectangle and high / h /of rectangle
 
 
 

Lee Mac 发表于 2022-7-6 09:37:34

 
So why would that mean you would need to compile the code?

sharpooth 发表于 2022-7-6 09:38:50

I have an idea to sell my program.
 

dbroada 发表于 2022-7-6 09:44:46

YOUR program - not Lee's?
页: [1] 2
查看完整版本: Help Lee Mac for LM:GrText ...