关于模型空间和图纸空间的转换
请各位高手看看,为什么程序加载后,第一次运行的结果总是不对,而以后运行的结果就是对的,这是什么毛病,怎么改 程序代码如下(defun c:ft (/ p0 p0xx py0y p0x p0y p1 p1xx p1yy p1x p1y p2 p2xx p2yy<BR> p2x p2y a1 a2 lx ly l2)
(command "undo" "begin")<BR> (setq CHO (getvar "CMDECHO"))<BR> (setvar "CMDECHO" 0)
(command "ucs" "world") ;转到世界坐标系<BR> (setq os (getvar "osmode"))<BR> (setvar "osmode" 37)<BR> (setq p0 (getpoint "\n 请选择插入1点:"))<BR> (setq p1 (getpoint "\n 请选择插入2点:"))<BR> (setq p2 (getpoint "\n 请选择插入3点:"))<BR> (setq a1 (angle p0 p1))<BR> (setq a2 (angle p0 p2))<BR> (setq l2 (distance p0 p2))<BR> (setq lxx (cos (- a2 a1)))<BR> (setq lyy (sin (- a2 a1)))<BR> (setq lx (* lxx l2))<BR> (setq ly (* lyy l2))<BR> (setq p0x (car p0))<BR> (setq p0y (cadr p0))<BR> (setq q2x (+ p0x lx))<BR> (setq q2y (- p0y ly))<BR> (setq q2 (list q2x q2y))<BR> (command "layout" "set" "layout1")<BR> (command "RECTANGLE" p0 q2 "")<BR> (setq e1 (entlast))<BR> (command "mview" "object" e1)<BR> (command "MSPACE" p0)<BR> (setvar "ucsfollow" 1)<BR> (command "ucs" "z" p0 p1)<BR> (setvar "ucsfollow" 0)<BR> (command "ucs" "w")<BR> (command "zoom" p0 p2)<BR> (command "PSPACE")<BR> (setvar "CMDECHO" cho)<BR> (setvar "osmode" os)<BR> (command "undo" "end")
) 问题可能出在 (command "layout" "set" "layout1")<BR>若布局名不存在则会出错。 1当布局存在的时候第一次运行也是不对的,
2如果布局不存在是会出错,那怎么解决呢 怎么没有人回答我的问题啊 本帖最后由 作者 于 2004-7-5 18:10:15 编辑 <br /><br /> 1.(command "layout" "set" "layout1")上多加一行(command "layout" "N" "layout1")
2.(command "RECTANGLE" p0 q2 "")可少一个"",程序不会错,但可避免出现"不明的指令「FT」。请按 F1 取得说明"<BR><BR>
页:
[1]