乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 91|回复: 14

[编程交流] Help Lee Mac for LM:GrText ...

[复制链接]

16

主题

64

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-6 09:03:17 | 显示全部楼层 |阅读模式
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:
 
  1. ;;-----------------------=={ 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)     (""   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
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 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
回复

使用道具 举报

16

主题

64

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 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
 
 
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 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?
回复

使用道具 举报

16

主题

64

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 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.
 
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:26:57 | 显示全部楼层
What do you mean by:
回复

使用道具 举报

16

主题

64

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-6 09:30:44 | 显示全部楼层
Width / b / of rectangle and high / h /of rectangle
 
 
 
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:37:34 | 显示全部楼层
 
So why would that mean you would need to compile the code?
回复

使用道具 举报

16

主题

64

帖子

48

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-6 09:38:50 | 显示全部楼层
I have an idea to sell my program.
 
回复

使用道具 举报

48

主题

1073

帖子

1043

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
238
发表于 2022-7-6 09:44:46 | 显示全部楼层
YOUR program - not Lee's?
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-7 06:10 , Processed in 0.568923 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表