本帖最后由 Gu_xl 于 2010-12-14 12:46 编辑
回复 ljttjl 的帖子
这么简单的程序你也要编译发上来么?
花了几分钟,写了段代码,供大家修改使用
- ;;;(tk 图块名) 2010.12.14 By Gu_xl
- (defun tk(tkname / p1 p2 pp1 pp2 v h v1 h1 xscale yscale)
- (setq p1 (getpoint "\n插入图框角点:")
- p2 (GETCORNER p1 "图框另一角点")
- )
- (setq pp1 (mapcar '(lambda (x)(apply 'min x)) (apply 'mapcar (cons 'list (list p1 p2))))
- pp2 (mapcar '(lambda (x)(apply 'max x)) (apply 'mapcar (cons 'list (list p1 p2))))
- v (- (cadr pp2) (cadr pp1))
- h (- (car pp2) (car pp1))
- )
- (command "insert" tkname pp1 1 1 0)
- (setq en (entlast))
- (vla-getboundingbox (vlax-ename->vla-object en) 'p1 'p2)
- (setq pl (mapcar 'vlax-safearray->list (list p1 p2)))
- (setq p1 (vlax-safearray->list p1)
- p2 (vlax-safearray->list p2)
- v1 (- (cadr p2) (cadr p1))
- h1 (- (car p2) (car p1))
- )
- (setq xscale (/ h h1)
- yscale (/ v v1)
- )
- (entdel en)
- (command "insert" tkname pp1 xscale yscale 0)
- (setq en (entlast))
- (vla-getboundingbox (vlax-ename->vla-object en) 'p1 'p2)
- (setq pl (mapcar 'vlax-safearray->list (list p1 p2)))
- (setq p1 (vlax-safearray->list p1)
- p2 (vlax-safearray->list p2)
- )
- (command "move" en "" p1 pp1)
- (princ)
- )
- ;;;测试
- (defun c:tk()
- (setq oldcmdecho (getvar "cmdecho"))
- (setvar "cmdecho" 0)
- (setq blkname (getstring "\n输入要插入的图框名称:"))
- (tk blkname)
- (setvar "cmdecho" oldcmdecho)
- (princ)
- )
|