caoyin 发表于 2009-2-8 13:15:00

本帖最后由 作者 于 2009-2-8 13:21:41 编辑

就是vlax-ename->vla-object,我本帖中没有使用en2obj啊

jxphklibin 发表于 2009-2-10 08:33:00

本帖最后由 作者 于 2009-2-10 9:01:10 编辑

缺少函数(en2obj)把 en2obj 改为 vlax-ename->vla-object 即可。
见下面这个,其实你写这么多代码,和这个一样:不适用于不等比例缩放的块
(defun c:bcopy (/ e el ss p1)
(setq ss (ssadd))
(while (and (setq e (nentselp "\n选择块内实体: "))
       (= (length e) 4)
)
    (setq el (entget (car e)))
    (entmake el)
   ;(vla-transformby ;该函数不能用于不等比例缩放的实体对象
   ; (vlax-ename->vla-object (entlast))
   ;(vlax-tmatrix (caddr e))
   ;)
    (setq ss (ssadd (entlast) ss))
)
(if (and SS (/= (sslength SS) 0))
    (progn
      (if (setq P1 (getpoint "\n指定基点 <原位置>: "))
(progn
   (command "_.move" SS "" "_non" P1)
   (princ "指定第二点: ")
   (command "\\")
)
      )
      (command "_.select" SS "")
    )
)
(princ)
)

caoyin 发表于 2009-2-11 09:03:00

<p>&nbsp;</p>

koyote 发表于 2009-2-17 17:42:00

老大,我9楼和10楼的程序下载率最高哟,给个什么奖给我呀,caoyin老大

jxphklibin 发表于 2009-3-2 13:03:00

本帖最后由 作者 于 2009-3-2 16:24:11 编辑

Delete the spaces before and after the strings 删除字符串中前后的空格
Cutting string of spaces before and after 裁剪字符串中前后的空格
Trimming spaces before and after the strings 修剪字符串中前后的空格;; Delete the spaces before and after the strings 删除字符串中前后的空格
;; Cutting string of spaces before and after 裁剪字符串中前后的空格
;; Trimming spaces before and after the strings 修剪字符串中前后的空格
;;by 小李子 木子CAD 2009.3.2
(defun trim32B&A (str / lst)
;;先检测字符串前后有没有包含空格
(if (or (wcmatch str " *") (wcmatch str "* "))
    (progn
      (setq lst (vl-string->list str))
      (while (= 32 (car lst))
(setq lst (cdr lst))
      )
      (setq lst (reverse lst))
      (while (= 32 (car lst))
(setq lst (cdr lst))
      )
      (vl-list->string (reverse lst))
    )
    str
)
)
多谢caoyin提醒,例程:
_$ (vl-list->string (vl-string->list "adf 1234648   dddd   "))
"adf 1234648   dddd   "
_$ (vl-string-left-trim " \t\n" "\n\t STR ")
"STR "
_$ (vl-string-left-trim "12456789" "12463CPO is not R2D2")
"3CPO is not R2D2"
_$ (vl-string-left-trim " " "   There are too many spaces here")
"There are too many spaces here"
_$ (vl-string-right-trim " \t\n" " STR \n\t ")
" STR"
_$ (vl-string-right-trim "1356789" "3CPO is not R2D267891")
"3CPO is not R2D2"
_$ (vl-string-right-trim " " "There are too many spaces here      ")
"There are too many spaces here"

只要用这个函数就可以删除字符串的前后空格了:(vl-string-trim " " str) 删除前后空格

jxphklibin 发表于 2009-3-2 13:43:00

<p>;; 去除字符串中的所有空格<br/>;; by 小李子 2009-2-28<br/>(defun trim32str (str /)<br/>&nbsp; (repeat (strlen str)<br/>&nbsp;&nbsp;&nbsp; (setq str (vl-string-subst "" " " str 0))<br/>&nbsp; )<br/>)</p>

jxphklibin 发表于 2009-3-2 13:44:00

本帖最后由 作者 于 2009-3-2 13:48:10 编辑 <br /><br /> <p>;; 删除去除字符串中的所有空格<br/>;; by 小李子 木子CAD 2009-3-2<br/>(defun No32strs (str / no item NewLst)<br/>&nbsp; (setq no 0 NewLst "")<br/>&nbsp; (repeat (strlen str)<br/>&nbsp;&nbsp;&nbsp; (setq item (substr str (setq no (1+ no)) 1))<br/>&nbsp;&nbsp;&nbsp; (if&nbsp;(/= item " ")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq NewLst (strcat NeWLst item))<br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp; )<br/>&nbsp; NewLst<br/>)<br/></p>

jxphklibin 发表于 2009-3-2 13:47:00

<p>最简洁代码为:</p><p>;; 删除去除字符串中的所有空格<br/>;; by 小李子 木子CAD 2009-3-2<br/>(defun strs-&gt;No32 (str /)<br/>&nbsp; (vl-list-&gt;string (vl-remove 32 (vl-string-&gt;list str)))<br/>)</p>

caoyin 发表于 2009-3-2 14:32:00

jxphklibin发表于2009-3-2 13:03:00static/image/common/back.gifDelete the spaces before and after the strings 删除字符串中前后的空格Cutting string of spaces before and after 裁剪字符串中前后的空格Trimming spaces before and after the strings 修

<p>删除前后空格用 vl-string-left-trim&nbsp;&nbsp; vl-string-right-trim就好了</p>

redsnake 发表于 2009-3-3 17:31:00

<p>都是强人呀</p>
页: 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14 15
查看完整版本: 【分享明经——发程序、拜新年专贴】