明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1667|回复: 7

谁来帮忙看看这个程序哪有问题

[复制链接]
发表于 2012-5-15 08:36:58 | 显示全部楼层 |阅读模式
(defun c:A4H( )
(setq p0 '(0 0) p1 '(25 205) p2 '(292 205) p3 '(292 5) p4 '(25 5) p5 '(0 210) p6 '(297 210) p7 '(297 0) p8 ' (280 23.75) p9 '(235 5) p10 '(165 49) P11 '(139 31) P12 '(0 300))
(command "zoom" "a")
(command "layer" "n" "MAIN" "c" "7" "MAIN" "")
(command "layer" "n" "CENTER" "c" "1" "CENTER" "")
(command "layer" "n" "DIM" "c" "5" "DIM" "" )
(command "layer" "n" "HIDD" "c" "3" "HIDD" "" )
(command "layer" "n" "2" "c" "2" "2" "" )
(command "layer" "l" "hidden2" "HIDD" "" )
(command "layer" "l" "center2" "CENTER" "" )
(command "regen")
(command "layer" "s" "2" "")
(COMMAND "OSNAP" "off")
(command "pline" p1 p2 p3 p4 p1 "")
(command "layer" "s" "MAIN" "")
(command "pline" p0 p5 p6 p7 p0 "")
(command "zoom" "e")
(COMMAND "OSNAP" "off")
(command "pline" "148,41" "292,41" "")
(command "pline" "196,41" "196, 5" "")
(command "pline" "148,25" "196,25" "")
(command "pline" "148,41" "148, 5" "")
(command "pline" "244,29" "292,29" "")
(command "pline" " 244,41" "244, 5" "")
(command "pline" "244,17" "292,17" "")
(command "pline" "196,21.8" "244,21.8" "")
(command "layer" "s" "dim" "")
(command "pline" "176,41" "176,25" "")
(command "pline" "186,41" "186,25" "")
(command "pline" "154,41" "154,25" "")
(command "pline" "160,41" "160,5" "")
(command "pline" "148,33" "196,33" "")
(command "pline" "148,37" "196,37" "")
(command "pline" "148,29" "196,29" "")
(command "pline" "148,20" "196,20" "")
(command "pline" "184,25" "184,5" "")
(command "pline" "148,15" "196,15" "")
(command "pline" "172,25" "172,5" "")
(command "pline" "148,10" "196,10" "")
(command "pline" "220,21.8" "220, 5" "")
(command "pline" "196,16.2" "244,16.2" "")
(command "pline" "208,21.8" "208,10.6" "")
(command "pline" "232,21.8" "232,10.6" "")
(command "pline" "196,10.6" "244,10.6" "")
(command "style" "DIMENSION" "ROMANT.SHX" "0" "0.8" "0" "n" "n" "n")
(command "style" "Standard" "楷体_GB2312" "0" "0.8" "0" "n" "n" )
(command "layer" "s" "dim" "")
(command "text" "j" "m" "151.0000,27.0000" "2.4" "0" "标记")
(command "text" "j" "m" "157.0000,27.0000" "2.4" "0" "处数")
(command "text" "j" "m" "168.0000,27.0000" "2.4" "0" "更改文件号")
(command "text" "j" "m" "181.0000,27.0000" "2.4" "0" "签  名")
(command "text" "j" "m" "191.0000,27.0000" "2.4" "0" "日  期")
(command "text" "j" "m" "154.0000,22.5000" "3.2" "0" "设 计")
(command "text" "j" "m" "154.0000,17.5000" "3.2" "0" "校 对")
(command "text" "j" "m" "154.0000,12.5000" "3.2" "0" "审 核")
(command "text" "j" "m" "154.0000,7.5000" "3.2" "0" "工 艺")
(command "text" "j" "m" "178.0000,22.5000" "3.2" "0" "标准化")
(command "text" "j" "m" "178.0000,17.5000" "3.2" "0" "审 定")
(command "text" "j" "m" "178.0000,12.5000" "3.2" "0" "录 入")
(command "text" "j" "m" "178.0000,7.5000" "3.2" "0" "日 期")
(command "text" "j" "m" "202.0000,19.0000" "3.2" "0" "材 料")
(command "text" "j" "m" "214.0000,19.0000" "3.2" "0" "数 量")
(command "text" "j" "m" "226.0000,19.0000" "3.2" "0" "重 量")
(command "text" "j" "m" "238.0000,19.0000" "3.2" "0" "比 例")
(command "text" "j" "m" "208.0000,7.8000" "3.2" "0" "共     页")
(command "text" "j" "m" "232.0000,7.8000" "3.2" "0" "第     页")
(alert "提示:本程序标题栏在标准基础上缩小了0.8倍
       点击确定继续填写其他内容")
  (if (null str$$)
    (progn
      (setq str$$ "机器名称")
      (prompt "\n请输入机器名称 <>: ")
    )
    (progn
      (prompt "\n请输入机器名称<")
      (princ (strcat str$$ ">: "))
    )
  );if end
  (setq str (getstring))
  (if (= "" str)
    (setq str str$$)
    (setq str$$ str)
  );if end
(if (null str1$$)
    (progn
      (setq str1$$ "零件图号")
      (prompt "\n请输入零件图号 <>: ")
    )
    (progn
      (prompt "\n请输入零件图号<")
      (princ (strcat str1$$ ">: "))
    )
  );if end
  (setq str1 (getstring))
  (if (= "" str1)
    (setq str1 str1$$)
    (setq str1$$ str1)
  );if end
  (if (null str2$$)
    (progn
      (setq str2$$ "零件名称")
      (prompt "\n请输入零件名称 <>: ")
    )
    (progn
      (prompt "\n请输入零件名称<")
      (princ (strcat str2$$ ">: "))
    )
  );if end
  (setq str2 (getstring))
  (if (= "" str2)
    (setq str2 str2$$)
    (setq str2$$ str2)
  );if end
(if (null s1$$)
    (progn
      (setq s1$$ "A3")
      (prompt "\n请输入材料类别 <A3>: ")
    )
    (progn
      (prompt "\n请输入材料类别<")
      (princ (strcat s1$$ ">: "))
    )
  );if end
  (setq s1 (getstring))
  (if (= "" s1)
    (setq s1 s1$$)
    (setq s1$$ s1)
  );if end
(if (null s2$$)
    (progn
      (setq s2$$ "1")
      (prompt "\n请输入零件数量 <1>: ")
    )
    (progn
      (prompt "\n请输入零件数量<")
      (princ (strcat s2$$ ">: "))
    )
  );if end
  (setq s2 (getstring))
  (if (= "" s2)
    (setq s2 s2$$)
    (setq s2$$ s2)
  );if end
(if (null s3$$)
    (progn
      (setq s3$$ "1:1")
      (prompt "\n请输入图形比例 <默认1:1>: ")
    )
    (progn
      (prompt "\n请输入图形比例<")
      (princ (strcat s3$$ ">: "))
    )
  );if end
  (setq s3 (getstring))
  (if (= "" s3)
    (setq s3 s3$$)
    (setq s3$$ s3)
  );if end
(if (null s5$$)
    (progn
      (setq s5$$ "公司名称")
      (prompt "\n请输入公司名称 <>: ")
    )
    (progn
      (prompt "\n请输入公司名称<")
      (princ (strcat s5$$ ">: "))
    )
  );if end
  (setq s5 (getstring))
  (if (= "" s5)
    (setq s5 s5$$)
    (setq s5$$ s5)
  );if end
(if (null s4$$)
    (progn
      (setq s4$$ "林承强")
      (prompt "\n请输入设计者姓名 <林承强>: ")
    )
    (progn
      (prompt "\n请输入设计者姓名<")
      (princ (strcat s4$$ ">: "))
    )
  );if end
  (setq s4 (getstring))
  (if (= "" s4)
    (setq s4 s4$$)
    (setq s4$$ s4)
  );if end
(command "text" "j" "m" "202,13.3963" "3.333" "0" s1 )
(command "text" "j" "m" "214,13.3963" "3.333" "0" s2 )
(command "text" "j" "m" "238,13.3963" "3.333" "0" s3 )
(command "text" "j" "m" "220,31.4000" "4" "0" str )
(command "text" "j" "m" "268,35" "4" "0" str1 )
(command "text" "j" "m" "268,23" "4" "0" str2 )
(command "text" "j" "m" "166.3000,22.5668" "3" "0" s4 )
(command "text" "j" "m" "268.0000,11.0000" "4.2" "0" s5)
(command "DIMTXSTY" "DIMENSION"  )
(command "osnap" "end,int,mid,cen,per,app")
(initget 1 "Y N")
(setq pd (getkword "\n是否要对图框进行缩放 (Y/N)  "))
(if (= pd "N") ("\n程序已经结束")
  );if end
(if (null qw$$)
    (progn
      (setq qw$$ "1")
      (prompt "\n 请输入图框缩放的比例<>: ")
    )
    (progn
      (prompt "\n请输入图框缩放的比例<")
      (princ (strcat qw$$ ">: "))
    )
  );if end
  (setq qw (getstring))
  (if (= "" qw)
    (setq qw qw$$)
    (setq qw$$ qw)
  );if end
(if (= pd "Y")
     (command "scale" "all" "" "0,0" qw )
  );if end
      (command "zoom" "e")
(command "ortho" "on")
(alert "OK操作已完成,如有发现程序有误请与本人联系。")
)
end
加载后,说红字那部分函数错误
发表于 2012-5-15 09:42:54 | 显示全部楼层
("\n程序已经结束")是什么用法?
是不是应该改为:
(if (= pd "N") (prompt "\n程序已经结束")
  );if end
 楼主| 发表于 2012-5-15 09:45:45 | 显示全部楼层
zyhandw 发表于 2012-5-15 09:42
("\n程序已经结束")是什么用法?
是不是应该改为:
(if (= pd "N") (prompt "\n程序已经结束")

我去试试,谢谢你啊
发表于 2012-5-15 09:47:28 | 显示全部楼层
本帖最后由 xyh 于 2012-5-15 09:50 编辑

将红字以后的if语句段全部屏蔽后运行,无出错信息。原因是屏蔽的if语句段。
(command "scale" "all" "" "0,0" qw )
qw是字符,命令中需实数,类型不匹配,将后面的改写如下:
(setq pd (getkword "\n是否要对图框进行缩放 (Y/N)  "))
(if (= pd "N") (prompt "\n程序已经结束")
  (progn
    (if (null qw$$)(setq qw$$ 1))
    (prompt (strcat "\n请输入图框缩放的比例<" (itoa qw$$) ">: "))
;    (princ (strcat qw$$ ">: "))
    (initget 1)
    (setq qw (getint))
    (if (= "" qw)    (setq qw qw$$)    (setq qw$$ qw))
    (command "scale" "all" "" "0,0" qw)
  );if progn
);if end
(command "zoom" "e")
(command "ortho" "on")
如需实数比例,将getint改成getreal,转换的atoi改成atof,itoa改成rtos
 楼主| 发表于 2012-5-15 10:10:35 | 显示全部楼层
xyh 发表于 2012-5-15 09:47
将红字以后的if语句段全部屏蔽后运行,无出错信息。原因是屏蔽的if语句段。
(command "scale" "all" "" "0 ...

你好,那运行后,图框出来了,但是里面的文字比如日期 材料什么的怎么不显示,都显示的是问号呀
发表于 2012-5-15 10:41:54 | 显示全部楼层
(command "style" "Standard" "楷体_GB2312" "0" "0.8" "0" "n" "n" )
有些问题,可能和操作系统有关,有些系统中无"楷体_GB2312" ,而是"楷体" ,以上语句执行不成功,用的是DIMENSION样式,该样式无中文定义,故显示?。
用style命令设定standard样式试试,作相应修改
(command "style" "Standard" "楷体" "0" "0.8" "0" "n" "n" )
或改成其它字型。
(command "style" "HZ" "txt,hztxt" "0" "0.8" "0" "n" "n" )
有些可以单条命令执行调试,看语句是否完整
 楼主| 发表于 2012-5-15 10:50:38 | 显示全部楼层
xyh 发表于 2012-5-15 10:41
(command "style" "Standard" "楷体_GB2312" "0" "0.8" "0" "n" "n" )
有些问题,可能和操作系统有关,有些 ...

太感谢您了,我第一次接触这语言,好多命令都不懂,
(command "zoom" "a")
(command "layer" "n" "MAIN" "c" "7" "MAIN" "")
(command "layer" "n" "CENTER" "c" "1" "CENTER" "")
(command "layer" "n" "DIM" "c" "5" "DIM" "" )
(command "layer" "n" "HIDD" "c" "3" "HIDD" "" )
(command "layer" "n" "2" "c" "2" "2" "" )
(command "layer" "l" "hidden2" "HIDD" "" )
(command "layer" "l" "center2" "CENTER" "" )
(command "regen")
(command "layer" "s" "2" "")
(COMMAND "OSNAP" "off")
向这些命令我都不知道什么意思,您能给解释下不,我现在时间太急,来不及学了
发表于 2012-5-15 11:42:06 | 显示全部楼层
(command "zoom" "a") ;窗口缩放
(command "layer" "n" "MAIN" "c" "7" "MAIN" "") ;新建main层,颜色7
(command "layer" "n" "CENTER" "c" "1" "CENTER" "")
(command "layer" "n" "DIM" "c" "5" "DIM" "" )
(command "layer" "n" "HIDD" "c" "3" "HIDD" "" )
(command "layer" "n" "2" "c" "2" "2" "" )
(command "layer" "l" "hidden2" "HIDD" "" ) ;装入hidden2线型并为hidd层指定线型
(command "layer" "l" "center2" "CENTER" "" )
(command "regen") ;重新生成
(command "layer" "s" "2" "")  ;设置"2"层为当前层
(COMMAND "OSNAP" "off")  ;关闭捕捉
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-7-23 12:07 , Processed in 0.908035 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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