明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1187|回复: 4

ssget时有时无选择问题,贴源代码。

[复制链接]
发表于 2011-5-28 16:03:32 | 显示全部楼层 |阅读模式
本帖最后由 tm20038175 于 2011-5-28 16:07 编辑


(defun c:et ()
      (setq $orr *error*)
    (setq *error* #err)   ;当程序出错时就会执行#err函数
  (setq pt2 null)
   (setq ptlst null)
(setq oldmode (getvar "osmode") p1mode t)
  (setvar "osmode" 0)
(setvar "CMDECHO" 0)

  (if (setq pt2 (getpoint "\nSpecify a point:"))
    (progn
      (setq ptlst (list pt2))
      (while (setq pt2 (getpoint pt2 "\nSpecify a point:"))
        (redraw)
        (setq ptlst (cons pt2 ptlst))
        (grvecs (apply 'append (mapcar 'list ptlst (cdr ptlst))))
      )
      (princ "\n111111")
      (setq ss (ssget "_WP"  ptlst '((0 . "point"))))

      (redraw)
      ;(sssetfirst nil ss)
    )
  )
  (if (= ss nil)    (exit)    )
          (princ "\n222222")
(Print_Piont1 ss)
(Print_Piont2 ss)
(sssetfirst nil ss)
  (setvar "osmode" oldmode)
      (setq *error* $orr)
  (princ)
)

(defun Print_Piont1 (ss)

(setq num 0)
(setq l(sslength ss))
     (setq l1(itoa l))
    (princ (strcat "\n<Tm提取点程序>:\n一共提取了<" l1 "> 个点:"))
    (princ "\n<Tm提取点程序>:\n提取的点坐标为:")

(repeat l
     ; (princ "\n311111")
  (setq ty(ssname ss num))

  (setq data (entget ty))

    ;(princ data)


(setq z(cadddr(assoc 10 data)))

(setq x(car(cdr(assoc 10 data))))

(setq y(cadr(cdr(assoc 10 data))))

   ;(princ "\n[" )(princ x ) (princ " " ) (princ y ) (princ " " )
(princ z ) (princ "]" )

(setq xx(rtos x 2 3))

(setq yy(rtos y 2 3))

(setq zz(rtos z 2 3))
      ;)
     ;)
   (princ "\n" )(princ xx ) (princ " " ) (princ yy ) (princ " " ) (princ zz
) (princ "" )
  
(setq num(+ num 1))
)

)


(defun Print_Piont2 (ss)

(setq num 0)
(setq l(sslength ss))
          (setq l1(itoa l))



    (princ (strcat "\n<Tm提取点程序>:\n一共提取了<" l1 "> 个点:"))
    (princ "\n<Tm提取点程序>:\n提取的点转换为MSC.Patran坐标为[<单位>(mm)]
:\n")
        (princ "\n///%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%///\n")
(repeat l
     ; (princ "\n311111")
  (setq ty(ssname ss num))

  (setq data (entget ty))

    ;(princ data)


(setq z(cadddr(assoc 10 data)))    (setq zm(/ z 1000))

(setq x(car(cdr(assoc 10 data))))  (setq xm(/ x 1000))

(setq y(cadr(cdr(assoc 10 data)))) (setq ym(/ y 1000))

   ;(princ "\n[" )(princ x ) (princ " " ) (princ y ) (princ " " )
(princ z ) (princ "]" )

(setq xx(rtos xm 2 3))

(setq yy(rtos ym 2 3))

(setq zz(rtos zm 2 3))
      ;)
     ;)
   (princ "[" )(princ xx ) (princ " " ) (princ yy ) (princ " " ) (princ zz
) (princ "]" )
  
(setq num(+ num 1))
)

        (princ
"\n///*********************************************************************
***///\n")
)


(defun #err (s)
    (princ "出错了")
    (setvar "osmode" oldmode)
  (setq *error* $orr)

)


"觉得好,就打赏"
还没有人打赏,支持一下
 楼主| 发表于 2011-5-28 16:43:25 | 显示全部楼层
哈哈,明白为什么错了,原来我选择多边形的时候多边形的边相交了,所以出错,选择时候应该小心点啊
发表于 2011-7-8 16:13:30 | 显示全部楼层
没有的东西
发表于 2011-7-8 17:05:08 | 显示全部楼层
(setq ss (ssget "_WP"  ptlst '((0 . "point"))))

改成 (setq ss (ssget "_CP"  ptlst '((0 . "point"))))

 楼主| 发表于 2011-7-8 17:26:03 | 显示全部楼层
改成cp就变成框内选择了,其实只要选择多边形不要相交就可以了…………
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-9-24 04:53 , Processed in 0.157643 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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