乐筑天下

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

请问陈伯雄老师[求助]

[复制链接]

37

主题

297

帖子

15

银币

后起之秀

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

铜币
449
发表于 2002-9-14 10:52:00 | 显示全部楼层 |阅读模式
我老是在我的dwg文件目录下面发现一个stoa文件,
经检查,
在你的ssx程序中,有这么一个函数,请问它的作用是什么?
  (Defun SToA (|s / |f)
    (SetQ |f (Open "stoa" "w"))
    (PrinC |s |f)
    (Close |f)
    (SetQ |f (Open "stoa" "r")
          |s (Read-Line |f)
    )
    (Close |f)
    (Eval |s)
  )
回复

使用道具 举报

37

主题

297

帖子

15

银币

后起之秀

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

铜币
449
发表于 2002-9-14 14:12:00 | 显示全部楼层
_$ (vl-prin1-to-string '((1 2 3) "" 3))
"((1 2 3) \"\" 3)"
_$ (read (vl-prin1-to-string '((1 2 3) "" 3)))
((1 2 3) "" 3)
回复

使用道具 举报

37

主题

297

帖子

15

银币

后起之秀

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

铜币
449
发表于 2002-9-14 14:51:00 | 显示全部楼层
自己写了一个想不用vl的纯autolisp的qf-list->string, 毛病多多。看来还是陈老师的方法好。[br](defun QF-list->string (lst / atom->string)
  (defun atom->string(a) (cond
              ((= (type a) 'Str) (strcat "\"" a "\""))
              ((= (type a) 'Int) (itoa a))
              ((= (type a) 'real) (rtos a))
              (T "")
             )
  )
  (strcat "("
          (apply 'strcat
                 (mapcar '(lambda (x)
                            (if        (= (type x) 'list)
                              (QF-list->string x)
                              (strcat (atom->string x) " ")
                            )
                          )
                         lst
                 )
          )
          ")"
  )
)
测试:
_$ (qf-list->string '(1 2.0 3 (4 5 6.0) 2))
"(1 2 3 (4 5 6 )2 )"
_$ (qf-list->string '(1 2.0 3 (4 5 6.45) 2))
"(1 2 3 (4 5 6.45 )2 )"
对于符号名,('a 'b 'c)的列表,我也没法子了,只能用vl函数,vl-symbol-name, 呵呵。
回复

使用道具 举报

37

主题

297

帖子

15

银币

后起之秀

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

铜币
449
发表于 2002-9-14 15:25:00 | 显示全部楼层
测试:
_$ (qf-list->string '(1 a b (2 4 5) 'e "teststring" (3 4 (5))k))
"(1 A B (2 4 5 )(QUOTE E )\"teststring\" (3 4 (5 ))K )"
_$ (read (qf-list->string '(1 a b (2 4 5) 'e "teststring" (3 4 (5))k)))
(1 A B (2 4 5) (QUOTE E) "teststring" (3 4 (5)) K)
程序:
(defun QF-list->string (lst / atom->string)
  (defun atom->string (a)
    (cond ((= (type a) 'Str) (strcat "\"" a "\""))
          ((= (type a) 'Int) (itoa a))
          ((= (type a) 'real) (rtos a))
          ((= a 'QUOTE) "QUOTE")
          ((= (type a) 'sym) (SymToStr a))
          (T "")
    )
  )
  (strcat "("
          (apply 'strcat
                 (mapcar '(lambda (x)
                            (if        (= (type x) 'list)
                              (QF-list->string x)
                              (strcat (atom->string x) " ")
                            )
                          )
                         lst
                 )
          )
          ")"
  )
)
(defun SymToStr        (SymbolName)
  ;; If the argument is a symbol ...
  (if (= (type SymbolName) 'SYM)
    (progn ;; Execute the function we are going to create ...
           (;; Create a function on the fly
            (list ;; The argument and local variable list.  Note
                  ;; that SymbolName will be evaluated, so the
                  ;; symbol name that we're trying to convert
                  ;; will be a local variable.
                  (list '/ SymbolName)
                  ;; Set the local variable to 0 to make sure it
                  ;; appears in the atoms-family (variables that
                  ;; are "bound to NIL", explicitly or implicitly,
                  ;; do not appear in the atoms-family)
                  (list set (quote SymbolName) 0)
                  ;; In "native "AutoLISP", the symbol would
                  ;; now be the first one in the atoms-family
                  ;; list.  Not so in Visual LISP.  So we have
                  ;; to look up the symbol [as a symbol] using
                  ;; (member ...), compute its position in the
                  ;; list, and then extract it from the string
                  ;; version of the atoms-family list.  This
                  ;; also sets up the return value.
                  (list        nth
                        (list -
                              (list length (list atoms-family 0))
                              (list length
                                    (list member
                                          (list (quote quote) SymbolName)
                                          (list atoms-family 0)
                                    ) ;_ end list
                              ) ;_ end list
                        ) ;_ end list
                        (list atoms-family 1)
                  ) ;_ end list
                  ;; End of the dynamic function
            ) ;_ end list
           )
    ) ;_ end progn
    ;; If the argument is not a symbol, return NIL
    nil
  ) ;_ end if
) ;_ end defun
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-5-25 20:42 , Processed in 0.305605 second(s), 60 queries .

© 2020-2025 乐筑天下

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