本帖最后由 soly2006 于 2012-3-9 16:21 编辑
是求个嵌套型的程序,试了半天,还是不行,高手们指点一下。如图,其中825.15是线面积,没扣除的,而要的是718.176面积。
- (defun c:t3 () ;主程序
- (setq blc (/ (getvar "USERR1") 1000))
- (if (= blc 0.0)
- (setq blc 0.5)
- ) ;设定比例尺
- (While (Progn (SetQ pen (Car (EntSel "\n指定一条 LWPolyLine: ")))
- (princ pen)
- (/= "LWPOLYLINE" (Cdr (Assoc 0 (EntGet pen))))
- )
- (Alert "所指对象不是 PolyLine,请重新指定...")
- )
- (setq bp (getpoint "点取标注位置:"))
- (command ".TEXT"
- bp
- (* blc 6)
- ""
- (strcat "【面 积】 = " (rtos (pll pen) 2 3))
- )
- (princ)
- )
- ;;; ==================================================================
- ;;; 求嵌套线的面积(如果有扣除内部的)
- ;;; ==================================================================
- (Defun PLL (plen / sset1 erea1)
- (PrinC "\n。。。。。")
- (setq sset1 (ssget "F"
- (txt1-get-allvertexs plen)
- '((0 . "LWPolyline") (8 . "面积线"))
- )
- )
- (princ sset1)
- (if (= sset1 NIL)
- (setq erea1 (vlax-curve-getArea (vlax-ename->vla-object plen)))
- (progn
- (setq n (sslength sset1))
- (setq j 0)
- (repeat n
- (setq erea1 (vlax-curve-getArea (vlax-ename->vla-object plen)))
- (setq erea1 (- erea1 (pll (ssname sset1 0)) ))
- (setq j (+ 1 j))
- )
- )
- )
- )
- ;;; ==================================================================
- ;;; 求多义线所有顶点.返回所有顶点表.
- ;;; ==================================================================
- (defun txt1-get-allvertexs (ename / plist pp n obj)
- (setq obj (vlax-ename->vla-object ename))
- (setq plist (vlax-safearray->list
- (vlax-variant-value
- (vla-get-coordinates obj)
- )
- )
- )
- (setq n 0)
- (repeat (/ (length plist) 2)
- (setq pp (append
- pp
- (list (list (nth n plist) (nth (1+ n) plist)))
- )
- )
- (setq n (+ n 2))
- )
- pp
- )
文件在这里,上面看起来太乱,为什么?http://bbs.mjtd.com/forum.php?mod=attachment&aid=NjUxNjR8ODg2NjMzNmZlMjE2MjRkNjdhNWM2ODI3MmM4OTliMjh8MTczMjQ4MzU1OQ%3D%3D&request=yes&_f=.lsp
|