明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3504|回复: 2

有没有用南方CASS做二次开发的?我有问题。

[复制链接]
发表于 2006-3-20 19:24 | 显示全部楼层 |阅读模式

有没有用南方CASS做二次开发的?我有问题。

       我用南方CASS自己带的命令PUTP(加入实体编码,添加图元的扩展属性),结合一个文本文件(普通CAD下的图层和CASS图层、编码的对应表),实现图元自动添加扩展属性的功能。结果循环只能循环三次,超过4次循环就会出问题,弹出一个对话框“致命错误:命令嵌套超过4层”。

       我试了一下,只用PUT命令进行循环(不结合文本文件来读取图层)没有问题,循环多少次都可以。而我把有PUT命令的这一行屏蔽掉,结果文本文件也可以全部读取出来。就是这两个组合在一起就出问题。不知道是为什么?

发表于 2007-11-18 10:55 | 显示全部楼层
  1. (defun strParse (Str Delimiter / SearchStr StringLen return n char)
  2.   (setq SearchStr Str)
  3.   (setq StringLen (strlen SearchStr))
  4.   (setq return '())
  5.   (while (> StringLen 0)
  6.     (setq n 1)
  7.     (setq char (substr SearchStr 1 1))
  8.     (while (and (/= char Delimiter) (/= char ""))
  9.       (setq n (1+ n))
  10.       (setq char (substr SearchStr n 1))
  11.     )
  12.     (setq return (cons (substr SearchStr 1 (1- n)) return))
  13.     (setq SearchStr (substr SearchStr (1+ n) StringLen))
  14.     (setq StringLen (strlen SearchStr))
  15.   )
  16.   (reverse return)
  17. )
  18. (defun C:ck ()
  19.   (regapp "south")
  20.   (regapp "流水号")
  21.   (regapp "部件名称")
  22.   (regapp "部件代码")
  23.   (regapp "状况")
  24.   (regapp "现势性")
  25.   (regapp "责任单位")
  26.   (regapp "材料")
  27.   (regapp "规格")
  28.   (regapp "类别")
  29.   (regapp "备注")
  30.   (setvar "cmdecho" 0)
  31.   (initget 6)
  32.   (setq bxm (getreal "\n请输入插入块的编码:"))
  33.   (setq bnm (rtos bxm 2 0))
  34.   (setq files (findfile "部件.txt"))
  35.   (if files
  36.     (progn
  37.       (setq biao nil)
  38.       (setq fn (open files "r"))
  39.       (while (setq x (read-line fn))
  40. (setq biao (append biao (list x)))
  41.       )
  42.       (close fn)
  43.     )
  44.   )
  45.   (setq lenbiao (length biao))
  46.   (setq m 0)
  47.   (while (< m lenbiao)
  48.     (setq mxbiao (nth m biao))
  49.     (setq line (strparse mxbiao ","))
  50.     (setq cbm (nth 0 line))
  51.     (if (= bnm cbm)   ;0
  52.       (progn
  53. (setq bbl (nth 1 line))
  54. (setq btc (nth 2 line))
  55. (setq bjmc (nth 3 line))
  56. (setq bjdm (nth 4 line))
  57. (setq bjzk (nth 5 line))
  58. (setq bjxsx (nth 6 line))
  59. (setq bjzrdw (nth 7 line))
  60. (setq bjcl (nth 8 line))
  61. (setq bjgg (nth 9 line))
  62. (setq bjlb (nth 10 line))
  63. (setq bjbz (nth 11 line))
  64. (princ "\n您输入的编码为:")
  65. (princ bnm)
  66. (princ "●对应的图层为:")
  67. (princ btc)
  68. (princ "●对应地物名称为:")
  69. (princ bjmc)
  70. (setq bjr (getstring "\n确定<Y/n>?"))
  71. (if (= "n" bjr)   ;1
  72.    (progn
  73.      (setq btc (getstring "\n请输入插入块的图层:<1>COMPONENT<2>手动输入"))
  74.      (if (= btc "1")
  75.        (progn
  76.   (setq btc "COMPONENT")
  77.        )
  78.      )
  79.      (if (= btc "2")
  80.        (progn
  81.   (setq btc (getstring "\n请输入插入块的图层:"))
  82.        )
  83.      )    ;if2
  84.    )
  85. )    ;if1
  86. (setq bbm bnm)
  87.       )
  88.     )     ;if0
  89.     (setq m (+ 1 m))
  90.   )     ;while
  91.   (setq bpt (getpoint "\n请输入插入块的位置:"))
  92.   (setq blk (strcat bbl ".dwg"))
  93.   (setq bkk (findfile blk))
  94.      ;(setq ncode (list -3 (list "SOUTH" (cons 1000 bbm))))
  95.   (setq bls (getstring "\n请输入流水号:"))
  96.   (setq ncode (list -3 (list "SOUTH" (cons 1000 bbm)
  97.      (cons 1001 "流水号")(cons 1000 bls)
  98.      (cons 1001 "部件名称")(cons 1000 bjmc)
  99.      (cons 1001 "部件代码")(cons 1000 bjdm)
  100.      (cons 1001 "状况")(cons 1000 bjzk)
  101.      (cons 1001 "现势性")(cons 1000 bjxsx)
  102.      (cons 1001 "责任单位")(cons 1000 bjzrdw)
  103.      (cons 1001 "材料")(cons 1000 bjcl)
  104.      (cons 1001 "规格")(cons 1000 bjgg)
  105.      (cons 1001 "类别")(cons 1000 bjlb)
  106.      (cons 1001 "备注")(cons 1000 bjbz)
  107.         )))
  108.   (if (not (tblsearch "layer" btc))
  109.     (progn
  110.       (command "layer" "m" btc "")
  111.       (command "insert" blk bpt "0.5" "0.5" "0")
  112.       (setq lbl (entlast))
  113.       (setq bl (entget lbl))
  114.       (if (setq ocode (assoc -3 bl))
  115. (setq bl (subst bl ocode ncode))
  116. (setq bl (append bl (list ncode)))
  117.       )
  118.       (entmod bl)
  119.       (command "layer" "s" "0" "")
  120.     )
  121.   )
  122.   (if (tblsearch "layer" btc)
  123.     (progn
  124.       (command "layer" "s" btc "")
  125.       (command "insert" blk bpt "0.5" "0.5" "0")
  126.       (setq lbl (entlast))
  127.       (setq bl (entget lbl))
  128.       (if (setq ocode (assoc -3 bl))
  129. (setq bl (subst bl ocode ncode))
  130. (setq bl (append bl (list ncode)))
  131.       )
  132.       (entmod bl)
  133.       (command "layer" "s" "0" "")
  134.     )
  135.   )
  136. )
我自己写的一个用在我们部件调查的加属性块的程序。你要是会LISP的话,就能看懂了。
发表于 2007-11-18 11:10 | 显示全部楼层
  1. (defun strParse (Str Delimiter / SearchStr StringLen return n char)
  2.   (setq SearchStr Str)
  3.   (setq StringLen (strlen SearchStr))
  4.   (setq return '())
  5.   (while (> StringLen 0)
  6.     (setq n 1)
  7.     (setq char (substr SearchStr 1 1))
  8.     (while (and (/= char Delimiter) (/= char ""))
  9.       (setq n (1+ n))
  10.       (setq char (substr SearchStr n 1))
  11.     )
  12.     (setq return (cons (substr SearchStr 1 (1- n)) return))
  13.     (setq SearchStr (substr SearchStr (1+ n) StringLen))
  14.     (setq StringLen (strlen SearchStr))
  15.   )
  16.   (reverse return)
  17. )
  18. (defun C:ck ()
  19.   (regapp "south")
  20.   (regapp "流水号")
  21.   (regapp "部件名称")
  22.   (regapp "部件代码")
  23.   (regapp "状况")
  24.   (regapp "现势性")
  25.   (regapp "责任单位")
  26.   (regapp "材料")
  27.   (regapp "规格")
  28.   (regapp "类别")
  29.   (regapp "备注")
  30.   (setvar "cmdecho" 0)
  31.   (initget 6)
  32.   (setq bxm (getreal "\n请输入插入块的编码:"))
  33.   (setq bnm (rtos bxm 2 0))
  34.   (setq files (findfile "部件.txt"))
  35.   (if files
  36.     (progn
  37.       (setq biao nil)
  38.       (setq fn (open files "r"))
  39.       (while (setq x (read-line fn))
  40. (setq biao (append biao (list x)))
  41.       )
  42.       (close fn)
  43.     )
  44.   )
  45.   (setq lenbiao (length biao))
  46.   (setq m 0)
  47.   (while (< m lenbiao)
  48.     (setq mxbiao (nth m biao))
  49.     (setq line (strparse mxbiao ","))
  50.     (setq cbm (nth 0 line))
  51.     (if (= bnm cbm)   ;0
  52.       (progn
  53. (setq bbl (nth 1 line))
  54. (setq btc (nth 2 line))
  55. (setq bjmc (nth 3 line))
  56. (setq bjdm (nth 4 line))
  57. (setq bjzk (nth 5 line))
  58. (setq bjxsx (nth 6 line))
  59. (setq bjzrdw (nth 7 line))
  60. (setq bjcl (nth 8 line))
  61. (setq bjgg (nth 9 line))
  62. (setq bjlb (nth 10 line))
  63. (setq bjbz (nth 11 line))
  64. (princ "\n您输入的编码为:")
  65. (princ bnm)
  66. (princ "●对应的图层为:")
  67. (princ btc)
  68. (princ "●对应地物名称为:")
  69. (princ bjmc)
  70. (setq bjr (getstring "\n确定<Y/n>?"))
  71. (if (= "n" bjr)   ;1
  72.    (progn
  73.      (setq btc (getstring "\n请输入插入块的图层:<1>COMPONENT<2>手动输入"))
  74.      (if (= btc "1")
  75.        (progn
  76.   (setq btc "COMPONENT")
  77.        )
  78.      )
  79.      (if (= btc "2")
  80.        (progn
  81.   (setq btc (getstring "\n请输入插入块的图层:"))
  82.        )
  83.      )    ;if2
  84.    )
  85. )    ;if1
  86. (setq bbm bnm)
  87.       )
  88.     )     ;if0
  89.     (setq m (+ 1 m))
  90.   )     ;while
  91.   (setq bpt (getpoint "\n请输入插入块的位置:"))
  92.   (setq blk (strcat bbl ".dwg"))
  93.   (setq bkk (findfile blk))
  94.      ;(setq ncode (list -3 (list "SOUTH" (cons 1000 bbm))))
  95.   (setq bls (getstring "\n请输入流水号:"))
  96.   (setq ncode (list -3 (list "SOUTH" (cons 1000 bbm)
  97.      (cons 1001 "流水号")(cons 1000 bls)
  98.      (cons 1001 "部件名称")(cons 1000 bjmc)
  99.      (cons 1001 "部件代码")(cons 1000 bjdm)
  100.      (cons 1001 "状况")(cons 1000 bjzk)
  101.      (cons 1001 "现势性")(cons 1000 bjxsx)
  102.      (cons 1001 "责任单位")(cons 1000 bjzrdw)
  103.      (cons 1001 "材料")(cons 1000 bjcl)
  104.      (cons 1001 "规格")(cons 1000 bjgg)
  105.      (cons 1001 "类别")(cons 1000 bjlb)
  106.      (cons 1001 "备注")(cons 1000 bjbz)
  107.         )))
  108.   (if (not (tblsearch "layer" btc))
  109.     (progn
  110.       (command "layer" "m" btc "")
  111.       (command "insert" blk bpt "0.5" "0.5" "0")
  112.       (setq lbl (entlast))
  113.       (setq bl (entget lbl))
  114.       (if (setq ocode (assoc -3 bl))
  115. (setq bl (subst bl ocode ncode))
  116. (setq bl (append bl (list ncode)))
  117.       )
  118.       (entmod bl)
  119.       (command "layer" "s" "0" "")
  120.     )
  121.   )
  122.   (if (tblsearch "layer" btc)
  123.     (progn
  124.       (command "layer" "s" btc "")
  125.       (command "insert" blk bpt "0.5" "0.5" "0")
  126.       (setq lbl (entlast))
  127.       (setq bl (entget lbl))
  128.       (if (setq ocode (assoc -3 bl))
  129. (setq bl (subst bl ocode ncode))
  130. (setq bl (append bl (list ncode)))
  131.       )
  132.       (entmod bl)
  133.       (command "layer" "s" "0" "")
  134.     )
  135.   )
  136. )
  137. 这是我写的我们工作测区的一个程序,是给块加附加属性的。如果你会LISP的话,应该能看懂,按自己需要改吧。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-19 09:07 , Processed in 0.283416 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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