找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 598|回复: 4

[求助]:如何获得所有style字型样式名的列表?

[复制链接]
发表于 2005-2-25 20:24:29 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
如何获得所有style字型样式名的列表?

(vla-get-TextStyles Object)说明不全。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2005-2-27 23:48:13 | 显示全部楼层
[php]
(defun dxf (code elist)
  (cdr (assoc code elist))
)
;;;
;;;  搜索图中所定义的字形,并形成两个表:表“stytab”和表“sty_zh”
;;;
(defun fdzx (/ sty1 sty2 first tab sm1 sm2)
  (setq zixchangdu 14)
  (setq xiaoziti 10)
  (setq daziti 10)
  (setq first T)
  (setq tab '())
  (setq stytab '())
  (setq sty_zh '())
  (while (setq sty1 (tblnext "style" first)) ;搜索图中字型
    (setq sm2_id nil)
    (if        (= first T)
      (setq first nil)
    )                                        ;end if
    (if        (/= sty1 nil)
      (progn
        (setq tab (cons sty1 tab))
        (setq sty1 (nth 0 tab))
        (if (= (setq sty2 (dxf 2 sty1)) "")
          (progn
            (setq sm2_id 2)
            (setq sty3 "形")
          )                                ;end progn
          (setq sty3 sty2)
        )                                ;end if
        (setq sty_n (strlen sty3))
        (if (< sty_n zixchangdu)
          (while (/= sty_n zixchangdu)
            (setq sty3 (strcat sty3 " "))
            (setq sty_n (1+ sty_n))
          )                                ; end while
        )                                ;end if
        (if (> sty_n zixchangdu)
          (setq sty3 (substr sty3 1 zixchangdu))
        )                                ;end if
        (setq sm1 (dxf 3 sty1))
        (if (and sm1 (/= sm1 ""))
          (progn
            (if        (wcmatch sm1 "*.shx,*.Shx,*.SHX")
              (progn
                (setq sm1_n (strlen sm1))
                (setq sm1 (substr sm1 1 (- sm1_n 4)))
              )                                ;end pr
            )                                ; if
            (if        (wcmatch sm1 "*.ttf,*.TTF,*.Ttf")
              (progn
                (setq sm1_n (strlen sm1))
                (setq sm1 (substr sm1 1 (- sm1_n 4)))
                (setq sm2_id 1)
              )                                ;pr
            )                                ;if
            (setq sm1_n (strlen sm1))
            (if        (< sm1_n xiaoziti)
              (while (/= sm1_n xiaoziti)
                (setq sm1 (strcat sm1 " "))
                (setq sm1_n (1+ sm1_n))
              )                                ; wh
            )                                ;if
            (if        (> sm1_n xiaoziti)
              (setq sm1 (substr sm1 1 xiaoziti))
            )                                ;if
          )                                ;pr
        )                                ;if
        (if (and (setq sm2 (dxf 4 sty1)) (/= sm2 ""))
          (progn
            (if        (wcmatch sm2 "*.shx,*.Shx,*.SHX")
              (progn
                (setq sm2_n (strlen sm2))
                (setq sm2 (substr sm2 1 (- sm2_n 4)))
              )
            )
            (setq sm2_n (strlen sm2))
            (if        (< sm2_n daziti)
              (while (/= sm2_n daziti)
                (setq sm2 (strcat sm2 " "))
                (setq sm2_n (1+ sm2_n))
              )
            )
            (if        (> sm2_n daziti)
              (setq sm2 (substr sm2 1 daziti))
            )
          )
          (if (= sm2 "")
            (progn
              (setq sm2 "未定义")
              (if (= sm2_id 1)
                (setq sm2 "WIN字体")
              )
              (if (= sm2_id 2)
                (setq sm2 "形文件")
              )
            )
          )
        )
        (setq stytab (cons sty2 stytab))
        (if (and sm2 (/= sm2 ""))
          (setq sty_zh (cons (strcat sty3 sm1 sm2) sty_zh))
          (setq sty_zh (cons (strcat sty3 sm1) sty_zh))
        )
      )
    )
  )
)
[/php]

本程序搜索图中所定义的所有字体以及形文件,并形成两个表:
样式表和所对应的字体表。

这是实际应用:
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-2-28 01:28:57 | 显示全部楼层

  1. (defun getstyles (/ d r)
  2.   (while (setq d (tblnext "style" (null d)))
  3.     (setq
  4.       r        (cons
  5.           (list (cdr (assoc 2 d)) (cdr (assoc 3 d)) (cdr (assoc 4 d)))
  6.           r
  7.         )
  8.     )
  9.   )
  10.   (reverse r)
  11. )
  12. (defun vl-getstyles (/ r)
  13.   (vlax-map-collection
  14.     (vlax-get-property
  15.       (vlax-get-property (vlax-get-acad-object) 'activedocument)
  16.       'textstyles
  17.     )
  18.     '(lambda (x)
  19.        (setq r (cons (list (vla-get-name x)
  20.                            (vla-get-fontfile x)
  21.                            (vla-get-bigfontfile x)
  22.                      )
  23.                      r
  24.                )
  25.        )
  26.      )
  27.   )
  28.   r
  29. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-2-28 11:04:05 | 显示全部楼层

Re: [求助]:如何获得所有style字型样式名的列表?

最初由 xyp1964 发布
[B]如何获得所有style字型样式名的列表?

(vla-get-TextStyles Object)说明不全。 [/B]


何为:“说明不全”?
俺就是 这样获得列表的:
[php]
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq styles (vla-get-TextStyles doc))

[/php]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-4 21:31:54 | 显示全部楼层

Re: Re: [求助]:如何获得所有style字型样式名的列表?

最初由 它山之石 发布
[B]

何为:“说明不全”?
俺就是 这样获得列表的:
  (vl-load-com... [/B]


(setq styles (vla-get-TextStyles doc))
“styles”的内容到底是什么?
“#(VLA-OBJECT IAcadTextStyles 031906f4)”的真实内容如何得到?

3楼的不错:
简单修改就可用了
[php]
;;;获得所有style字型样式名的列表
(defun getstyles (/ lst d)
  (while (setq d (tblnext "style" (null d)))
    (setq lst (cons (dxf 2 d) lst))
  )
  (reverse lst)
lst
)
[/php]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-22 04:27 , Processed in 0.184387 second(s), 39 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表