程序是读一个文件,文件格式是 01-R-居住用地,Continuous,50 01-R1-一类居住,Continuous,51 01-R11-住宅,Continuous,51 01-R12-公共服务设施,Continuous,51 【前面是 名字 ,中间是线型,最后是颜色】 读完一个就画一个图层。 我想问的第一问题是画图层函数 (command "layer" "make" "01-R-居住用地" "c" 50 "" "") ,可是如何把线性(continous)加进去啊,因为我其它的有不是continous的。 二是我的程序老是报错:参数类型错误 :numberp: nil 谢谢!代码附后: (defun c:creatlayer() (if (not (member "objectdcl2005.arx" (arx))) (arxload "objectdcl2005.arx" "File objectdcl2005.arx was not find.") );2000及2002则加载objectdcl.arx (ODcl_LoadProject "C:\\Documents and Settings\\zhu xiaodong\\桌面\\DCLTEST\\creatlayer.odc") (Odcl_Form_Show creatlayer_DclForm1) ) ;新建图层的按钮事件,点按钮建立图层 (defun c:DclForm1_TextButton1_OnClicked () ;打开数据文件 (setq file1 (open "C:\\Documents and Settings\\zhu xiaodong\\桌面\\DCLTEST\\城市用地.lay" "r") ) ;定义一个变量用作循环用 (setq x "5") ( while (/= x "");最好不要用nil (setq x (read-line file1));读文件的一行,返回给变量x (setq layerName (getname x) );获取该行的第一部分(图层名字),通过后面的getname函数实现 (setq layerStyle (getstyle x) );获取该行的第二部分(图层线型),通过后面的getstyle函数实现
(setq layerColor (getcolor x) );获取该行的第三部分(图层颜色),通过后面的getcolor函数实现
(setq layerColor2 (atoi layerColor)) ;将颜色由"50"这样的字符转换成整数 (command "layer" "m" layerName "c" layerColor2 "" "") ;建图层,不知道如何设置线性 (princ); )
) ;提取字符串中的第一部分(图层名字) (defun getname(s) (setq num1 (vl-string-search "," s)) (setq num2 (vl-string-search "," s (+ num1 1))) (setq strname (substr s 1 num1)) ) ;提取线型 (defun getstyle(s) (setq num1 (vl-string-search "," s)) (setq num2 (vl-string-search "," s (+ num1 1))) (setq strstyle (substr s (+ num1 2) (- num2 num1 1))) ) ;提取颜色 (defun getcolor(s) (setq num1 (vl-string-search "," s)) (setq num2 (vl-string-search "," s (+ num1 1))) (setq strcolor (substr s (+ num2 2) )) ) 我跟踪研究发现提取的都是结果都是正确的。 请指正,谢谢! |