明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1389|回复: 4

[已解答] 模板分段源程序改善

[复制链接]
发表于 2014-11-26 19:59 | 显示全部楼层 |阅读模式


         图层样板

模板分段数为1时,

新增图层有:UC1,UF1,UM1,  HC1,HF1,HM1,  KC1,KF1,KM1,  SC1,SF1,SM1,  DC1,DF1,DM1, BC1,BF,BM1,

模板分段数为2时,

  新增图层有:UC2,UF2,UM2,  HC2,HF2,HM2,  KC2,KF2,KM2,  SC2,SF2,SM2,  DC2,DF2,DM2, BC2,BF2,BM2,

   模板新增以此类推

  新增的图层与样板文件中的所对应的图层要一致(即:UC1与UC的图层颜色、线型、线宽都要一致)

(defun c:MBFD ()
  (setvar "cmdecho" 0)
  (setq M (getDIST "\n-->请输入模板分段数值:"));

  (command "layer" "n" "UC1" "s" "UC1"   "C" 4 ""  "L" "Continuous" ""  "LW" 0.5 "" "")
  (command "layer" "n" "UF1" "s" "UF1"   "C" 2 ""  "L" "Continuous" ""  "LW" 0.3 "" "")
  (command "layer" "n" "UM1" "s" "UM1"   "C" 1 ""  "L" "Continuous" ""  "LW" 0.2 "" "")

  (command "layer" "n" "HC1" "s" "HC1"   "C" 5 ""  "L" "Continuous" ""  "LW" 0.5 "" "")
  (command "layer" "n" "HF1" "s" "HF1"   "C" 6 ""  "L" "Continuous" ""  "LW" 0.3 "" "")
  (command "layer" "n" "HM1" "s" "HM1"   "C" 3 ""  "L" "Continuous" ""  "LW" 0.2 "" "")

  (command "layer" "n" "KC1" "s" "KC1"   "C" 1 ""  "L" "Continuous" ""  "LW" 0.5 "" "")
  (command "layer" "n" "KF1" "s" "KF1"   "C" 2 ""  "L" "Continuous" ""  "LW" 0.3 "" "")
  (command "layer" "n" "KM1" "s" "KM1"   "C" 7 ""  "L" "Continuous" ""  "LW" 0.2 "" "")

  (command "layer" "n" "SC1" "s" "SC1"   "C" 3 ""  "L" "Continuous" ""  "LW" 0.5 "" "")
  (command "layer" "n" "SF1" "s" "SF1"   "C" 4 ""  "L" "Continuous" ""  "LW" 0.3 "" "")
  (command "layer" "n" "SM1" "s" "SM1"   "C" 2 ""  "L" "Continuous" ""  "LW" 0.2 "" "")

  (command "layer" "n" "DC1" "s" "DC1"   "C" 1 ""  "L" "Continuous" ""  "LW" 0.5 "" "")
  (command "layer" "n" "DF1" "s" "DF1"   "C" 2 ""  "L" "Continuous" ""  "LW" 0.3 "" "")
  (command "layer" "n" "DM1" "s" "DM1"   "C" 6 ""  "L" "Continuous" ""  "LW" 0.2 "" "")

  (command "layer" "n" "BC1" "s" "BC1"   "C" 4 ""  "L" "Continuous" ""  "LW" 0.5 "" "")
  (command "layer" "n" "BF1" "s" "BF1"   "C" 5 ""  "L" "Continuous" ""  "LW" 0.3 "" "")
  (command "layer" "n" "BM1" "s" "BM1"   "C" 6 ""  "L" "Continuous" ""  "LW" 0.2 "" "")
  (PRINC)
)

    以上程序输入数值1时,程序会自动生成所需图层,但输入数值2时,就无法自动累加。请高手们指导,谢谢

本帖子中包含更多资源

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

x
"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2014-11-27 08:13 | 显示全部楼层
  1. (defun c:MBFD ()
  2. (setvar "CMDECHO" 0)
  3. (setq M (getint "\n-->请输入模板分段数值: "))
  4. (if (> M 0) (progn
  5.   (setq M (itoa M))
  6.   (command "-layer" "m" (strcat "UC" M) "C" 4 "" "LW" 0.5 "" "")
  7.   (command "-layer" "m" (strcat "UF" M) "C" 2 "" "LW" 0.3 "" "")
  8.   (command "-layer" "m" (strcat "UM" M) "C" 1 "" "LW" 0.2 "" "")

  9.   (command "-layer" "m" (strcat "HC" M) "C" 5 "" "LW" 0.5 "" "")
  10.   (command "-layer" "m" (strcat "HF" M) "C" 6 "" "LW" 0.3 "" "")
  11.   (command "-layer" "m" (strcat "HM" M) "C" 3 "" "LW" 0.2 "" "")

  12.   (command "-layer" "m" (strcat "KC" M) "C" 1 "" "LW" 0.5 "" "")
  13.   (command "-layer" "m" (strcat "KF" M) "C" 2 "" "LW" 0.3 "" "")
  14.   (command "-layer" "m" (strcat "KM" M) "C" 7 "" "LW" 0.2 "" "")

  15.   (command "-layer" "m" (strcat "SC" M) "C" 3 "" "LW" 0.5 "" "")
  16.   (command "-layer" "m" (strcat "SF" M) "C" 4 "" "LW" 0.3 "" "")
  17.   (command "-layer" "m" (strcat "SM" M) "C" 2 "" "LW" 0.2 "" "")

  18.   (command "-layer" "m" (strcat "DC" M) "C" 1 "" "LW" 0.5 "" "")
  19.   (command "-layer" "m" (strcat "DF" M) "C" 2 "" "LW" 0.3 "" "")
  20.   (command "-layer" "m" (strcat "DM" M) "C" 6 "" "LW" 0.2 "" "")

  21.   (command "-layer" "m" (strcat "BC" M) "C" 4 "" "LW" 0.5 "" "")
  22.   (command "-layer" "m" (strcat "BF" M) "C" 5 "" "LW" 0.3 "" "")
  23.   (command "-layer" "m" (strcat "BM" M) "C" 6 "" "LW" 0.2 "" "")
  24. ))
  25.   (setvar "CMDECHO" 1)
  26.   (princ)
  27. )
发表于 2014-11-27 08:25 | 显示全部楼层
本帖最后由 USER2128 于 2014-11-27 08:41 编辑
  1. (defun c:MBFD ()
  2.   (setvar "cmdecho" 0)
  3.   (initget 6)
  4.   (or (setq M (getint "\n-->请输入模板分段数值/<1>:"));
  5.       (setq M 1)
  6.       )
  7.   (setq ly '(UC  UF  UM   HC  HF HM   KC KF   KM  SC SF  SM  DC  DF  DM   BC  BF BM))
  8.   (setq cl '(7   4   1    7   4   1   7   4   1   7   4   1   7   4   1   7   4   1))
  9.   (setq lw '(0.5 0.3 0.2 0.5 0.3 0.2 0.5 0.3 0.2 0.5 0.3 0.2 0.5 0.3 0.2 0.5 0.3 0.2))
  10.   (setq ly (mapcar 'vl-princ-to-string ly))
  11.   (setq n 1)
  12.   (while (<= n m)
  13.     (mapcar '(lambda(x y z)
  14.       (setq str (strcat x (itoa n)))
  15.       (if (not (tblsearch "Layer" str))
  16.   (command "_.layer" "_n" str "_s" str "_C" y ""  "_L" "Continuous" ""  "_LW" z "" "")
  17.   )
  18.       ) ly cl lw)
  19.     (setq n (1+ n))
  20.     )
  21.   (princ)
  22.   )
 楼主| 发表于 2014-11-27 18:42 | 显示全部楼层
USER2128 发表于 2014-11-27 08:25

谢谢您的帮忙修改
 楼主| 发表于 2014-11-27 18:43 | 显示全部楼层
ZZXXQQ 发表于 2014-11-27 08:13

谢谢您的帮忙
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-25 01:17 , Processed in 0.336814 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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