找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 2112|回复: 4

[日积月累]:日积月累知识贴(禁止回复本贴)

  [复制链接]
发表于 2005-4-27 10:53:57 | 显示全部楼层 |阅读模式

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

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

×
获取 acad.exe 所在目录
[php](vla-get-path (vlax-get-acad-object))[/php]
获取文件搜索路径
[php]
(getvar "acadprefix")
[/php]
增加文件搜索路径
[php]
(defun PutSupportPath (Path)
  (vla-put-SupportPath
    (vla-get-Files
      (vla-get-Preferences
        (vlax-get-acad-object)
      )
    )
    (strcat (getvar "acadprefix") ";"Path)
  )
)
[/php]

Windows系统路径(mjtd)
[php]
(getenv "Windir")
[/php]

获取AUTOCAD的语言版本(mjtd)
英文=enu  简体=chs 繁体=cht
[php]
(getvar "LOCALE")
[/php]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 488个

财富等级: 日进斗金

发表于 2005-4-28 23:51:16 | 显示全部楼层
打印机系列
[php]
; (setq ad (vla-get-activedocument (vlax-get-acad-object)))

;;所有的"图纸尺寸"定义
(defun GetCanonicalMediaNames (ad)
  (vla-RefreshPlotDeviceInfo
    (vla-get-activelayout ad))
  (vlax-safearray->list
    (vlax-variant-value
      (vla-GetCanonicalMediaNames
        (vla-item (vla-get-layouts ad) "Model"))))
)

;;"图纸尺寸"定义的本地名称
(defun GetLocaleMediaNames (ad / mn mnl)
  (setq la (vla-item (vla-get-layouts ad) "Model"))
  (foreach mn (GetCanonicalMediaNames ad)
    (setq mnl (cons (vla-GetLocaleMediaName la mn) mnl))
  )
  (reverse mnl)
)

;;所有的打印机设置.(设置,不是名称!)
(defun GetPlotDevices (ad)
  (vla-RefreshPlotDeviceInfo
    (vla-get-activelayout ad))
  (vlax-safearray->list
    (vlax-variant-value
      (vla-getplotdevicenames
        (vla-item (vla-get-layouts ad) "Model"))))
)

;;当前布局的当前打印机 :pc3
(defun GetActivePlotDevice (ad)
  (vla-get-ConfigName
    (vla-get-ActiveLayout ad))
)

;;当前设置下的"打印样式"  : ctb
(defun GetPlotStyleTableNames (ad)
  (vla-RefreshPlotDeviceInfo
    (vla-get-activelayout ad))
  (vlax-safearray->list
    (vlax-variant-value
      (vla-getplotstyletablenames
        (vla-item (vla-get-layouts ad) "Model"))))
)

;;所有的,(可能不会这么用)
(defun ListAllMediaNames(ad / al cn pd apmn)
  (setq al (vla-get-activelayout  ad))
  (setq cn (vla-get-configname al))
  (foreach pd (GetPlotDevices)
    (if (/= pd "None")
      (progn
        (vla-put-configname al pd)
        (setq apmn (cons pd apmn))
        (setq apmn (cons (GetCanonicalMediaNames ad) apmn))
      )
    )
  )
  (if (/= cn "None") (vla-put-configname al cn))
  (reverse apmn)
)

; (ListAllLocalMediaNames (vla-get-activedocument (vlax-get-acad-object)))
(defun ListAllLocalMediaNames(ad / al cn pd apmn)
  (setq al (vla-get-activelayout ad))
  (setq cn (vla-get-configname al))
  (foreach pd (GetPlotDevices ad)
    (if (/= pd "None")
      (progn
        (vla-put-configname al pd)
        (setq apmn (cons pd apmn))
        (setq apmn (cons (GetLocaleMediaNames ad) apmn))
      )
    )
  )
  (if (/= cn "None") (vla-put-configname al cn))
  (reverse apmn)
)

;;某一配置的"图纸尺寸"定义
; (GetCanonicalMediaNamesOfConfigname ad "Acrobat PDFWriter")
(defun GetCanonicalMediaNamesOfConfigname(ad cn / oldcn al cmn)
  (setq al (vla-get-ActiveLayout ad))
  (setq oldcn (vla-get-configname al))
  (vla-put-configname al cn)
  (vla-RefreshPlotDeviceInfo al)
  (setq cmn (GetCanonicalMediaNames ad))
  (if (/= oldcn "None") (vla-put-configname al oldcn))
  cmn
)

;;上面的本地名
; (GetLocalMediaNamesOfConfigname ad "Acrobat PDFWriter")
(defun GetLocalMediaNamesOfConfigname(ad cn / oldcn al cmn)
  (setq al (vla-get-ActiveLayout ad))
  (setq oldcn (vla-get-configname al))
  (vla-put-configname al cn)
  (vla-RefreshPlotDeviceInfo al)
  (setq cmn (GetLocaleMediaNames ad))
  (if (/= oldcn "None") (vla-put-configname al oldcn))
  cmn
)
[/php]
[php]
;;当前布局,下面有用.
(defun ActLay ()
       (vla-get-ActiveLayout
         (vla-get-activedocument
           (vlax-get-acad-object)
         )
       )
)

; Return the Plotter configuration name
(defun GetActivePlotDevice ()
  (vla-get-ConfigName
    (ActLay)
  )
)

; Return the Plot style table name
(defun GetActiveStyleSheet ()
  (vla-get-StyleSheet
    (ActLay)
  )
)

; Force the Plotter configuration to something
(defun PutActivePlotDevice (PlotDeviceName)
  (vla-put-ConfigName
    (ActLay)
    PlotDeviceName
  )
)

; Force the Plot style table to something
(defun PutActiveStyleSheet (StyleSheetName)
  (vla-put-StyleSheet
    (ActLay)
    StyleSheetName
  )
)

; Return a list of all Plotter configurations
(defun PlotDeviceNamesList ()
  (vla-RefreshPlotDeviceInfo (ActLay))
  (vlax-safearray->list
    (vlax-variant-value
      (vla-GetPlotDeviceNames
        (ActLay)
      )
    )
  )
)

; Return a list of all Plot style tables
(defun PlotStyleTableNamesList ()
  (vla-RefreshPlotDeviceInfo (ActLay))
  (vlax-safearray->list
    (vlax-variant-value
      (vla-GetPlotStyleTableNames
        (ActLay)
      )
    )
  )
)

; If the saved Plotter configuration doesn't exist set it to None
(defun PutActivePlotDeviceToNoneIfNotExist ()
  (if (not (member (GetActivePlotDevice) (PlotDeviceNamesList)))
    (PutActivePlotDevice "None")
  )
)

; If the saved Plot style table doesn't exist set it to None
(defun PutActiveStyleSheetToNoneIfNotExist ()
  (if (not (member (GetActiveStyleSheet) (PlotStyleTableNamesList)))
    (PutActiveStyleSheet "")
  )
)

; Change the Plotter configuration "Emtunga.pc3" to your need
(defun PutActivePlotDeviceToCompanyStandardIfNotExist ()
  (if (not (member (GetActivePlotDevice) (PlotDeviceNamesList)))
    (PutActivePlotDevice "Emtunga.pc3")
  )
)

; Change the Plot style table "Emtunga-A3-BW.ctb" to your need
(defun PutActiveStyleSheetToCompanyStandardIfNotExist ()
  (if (not (member (GetActiveStyleSheet) (PlotStyleTableNamesList)))
    (PutActiveStyleSheet "Emtunga-A3-BW.ctb")
  )
)

; Change the Plotter configuration to the default one set in the options
; if the active plot device does not exist
(defun PutActivePlotDeviceToDefaultIfNotExistOrNone ()
  (if (or (not (member (GetActivePlotDevice) (PlotDeviceNamesList)))
          (= (GetActivePlotDevice) "None")
      )
    (if        (= (vla-get-UseLastPlotSettings
             (vla-get-output
               (vla-get-preferences (vlax-get-acad-object))
             )
           )
           :vlax-true
        )
      (PutActivePlotDevice
        (getenv "General\\MRUConfig")
      )
      (PutActivePlotDevice
        (vla-get-DefaultOutputDevice
          (vla-get-output
            (vla-get-preferences (vlax-get-acad-object))
          )
        )
      )
    )
  )
)


; Change the Plot style table to the default one set in the options
; if the active Plot style table does not exist
(defun PutActiveStyleSheetToDefaultIfNotExistOrNone ()
  (if (or (not
            (member (GetActiveStyleSheet) (PlotStyleTableNamesList))
          )
          (= (GetActiveStyleSheet) "")
      )
    (PutActiveStyleSheet
      (vla-get-DefaultPlotStyleTable
        (vla-get-output
          (vla-get-preferences (vlax-get-acad-object))
        )
      )
    )
  )
)
[/php]

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

使用道具 举报

已领礼包: 488个

财富等级: 日进斗金

发表于 2005-5-14 14:42:43 | 显示全部楼层
读幻灯片库里面的名称
返回名称的表
[php]
(defun read-slb->sldnames (path /
                           ex n id app appstr namestr nth1 nth2 nth3 nth4 nth5 chklist)
  (setq app nil n 0)
  (setq id (open path "r"))
  (read-line id)
  (setq ex (read-char id))
  (setq app (read-line id))
  (setq app (vl-remove 'nil (vl-string->list app)))
  (while (and (/= 101 (last app)) (read-char id) (setq ex (read-line id)))
    (setq app (append app (cons 1  (cons 1 (vl-remove 'nil (vl-string->list ex))))))
  )
  (close id)
  (setq app (cdr (cdr app )))
  (setq app (cons 1 (cons 1 app)))
  (foreach x app
    (cond
      ((and (< 0 x) (not nth1 )) (setq nth1 x))
      ((and nth1 (not nth2 )) (setq nth2 x))
      ((and nth2 (not nth3 )) (setq nth3 x))
      ((and nth3 (not nth4 )) (setq nth4 x))
      ((and nth4 (not nth5 )) (setq nth5 x))
    )
    (if (and nth1 nth2 nth3 nth4 nth5)
      (if (and (< 0 nth1) (< 0 nth2) (< 0 nth5)  (= 0 nth4))
        (if (/= x 0)
          (setq namestr (append namestr (list x)))
          (setq appstr (append appstr (list namestr))
                namestr nil
                nth1 nil nth2 nil nth3 nil nth4 nil nth5 nil
          )
        )
        (setq nth1 nil nth2 nil nth3 nil nth4 nil nth5 nil)
      )
    )
  )
  (acad_strlsort (mapcar 'vl-list->string appstr))
)
[/php]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 488个

财富等级: 日进斗金

发表于 2005-5-21 14:55:27 | 显示全部楼层
在lisp编程中如何进行时间延迟控制

  1. (defun WAIT (SECONDS / STOP)
  2.   ;;
  3.   ;; Posted by Tony Tanzillo
  4.   ;; Creates a pause in your program flow
  5.   ;; This function provides for much finer
  6.   ;; increments in time then the command DELAY
  7.   ;;
  8.   (setq STOP (+ (getvar "DATE") (/ SECONDS 86400.0)))
  9.   (while (> STOP (getvar "DATE"))
  10.     (princ)
  11.   )
  12. )
  13. ;;[i]2005年05月18日 by LUCAS  [/i]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 488个

财富等级: 日进斗金

发表于 2005-5-21 15:01:09 | 显示全部楼层
删除 表中 相同项 的函数

  1. (defun tt (ptlst / a lst)
  2.   (while (setq a    (car ptlst)
  3.            lst  (cons a lst)
  4.            ptlst(vl-remove a ptlst))            
  5.   )
  6.   (reverse lst)
  7. )
  8. ;;[i]2005年05月19日 by 狂刀[/i]

  1. ;;pts:表  fuzz:精度
  2. ;;By Aeo
  3. (defun lst-remove-dups(pts fuzz / pt x)
  4. (cond ((=(length pts)1) pts)
  5.        (t(setq pt(car pts))
  6.          (cons pt(vl-remove-if '(lambda(x)(equal pt x fuzz))
  7.                (lst-remove-dups(cdr pts)fuzz))
  8.          )
  9.      ))
  10. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-28 05:26 , Processed in 0.273131 second(s), 38 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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