马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- ;;VL方法
- (defun _layoutvla (name / o)
- (if (= 'vla-object
- (type
- (setq
- o (vl-catch-all-apply
- 'vla-item
- (list (vla-get-layouts
- (vla-get-activedocument (vlax-get-acad-object))
- )
- name
- )
- )
- )
- )
- )
- o
- )
- )
- ;;LISP方法
- (defun _layoutvic (name / o)
- (if (and (setq
- o (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_LAYOUT")))
- )
- (setq o (cdr (assoc -1 (dictsearch o name))))
- )
- (vlax-ename->vla-object o)
- )
- )
测试代码:
- (xd::quickbench '((_layoutvic "model") (_layoutvla "model")))
可见,LISP方法dicsearch方法更快。
=========================================================
CPU:(1x)Intel(R) Xeon(R) E3-1575M v5 @ 3.00GHz 4Cores / Memory:64G / OS:WIN10教育版
Benchmarking ....... done for 8192 iterations. Sorted from fastest.
Statement Increment Time(ms) Normalize Relative
-------------------------------------------------------------------------------
(_LAYOUTVIC Model) 8192 2000 2000 1.56 <fastest>
(_LAYOUTVLA Model) 4096 1562 3124 1.00 <slowest>
-------------------------------------------------------------------------------
_$
|