为什么坐标重复?为什么?
在精神病院度过了可怕的假期后,我又回来问问题了(vl-load-com)
(setq myFilter (list (cons 0 "LINE") (cons 410 "model")))
(setq alllines (ssget "x" myfilter))
(setq myFilter2 (list (cons 0 "insert") (cons 410 "model")))
(setq alllitems (ssget "x" myfilter2))
(setq acadobj1 (vlax-ename->vla-object (ssname alllines 0)))
(setq acadobj2 (vlax-ename->vla-object (ssname alllitems 0)))
(setq iPts (vla-intersectwith acadobj1 acadobj2 0))
(setq iPts (vlax-variant-value iPts))
(setq iPts (vlax-safearray->list iPts))
不记得我在哪里找到这个Lisp程序,但它说的东西像变体类型是不好的,我想知道为什么
(defun get_all_inters_in_SS (SS / SSL ;length of SS
PTS ;returning list
aObj1 ;Object 1
aObj2 ;Object 2
N1 ;Loop counter
N2 ;Loop counter
iPts ;intersects
)
(setq N10 ;index for outer loop
SSL (sslength SS)
)
; Outer loop, first through second to last
(while (< N1 (1- SSL))
; Get object 1, convert to VLA object type
(setq aObj1 (ssname SS N1)
aObj1 (vlax-ename->vla-object aObj1)
N2 (1+ N1)
) ;index for inner loop
; Inner loop, go through remaining objects
(while (< N2 SSL)
; Get object 2, convert to VLA object
(setq aObj2 (ssname SS N2))
aObj2 (vlax-ename->vla-object aObj2)
; Find intersections of Objects
iPts(vla-intersectwith
aObj1
aObj2
0
)
; variant result
iPts(vlax-variant-value iPts)
)
; Variant array has values?
(if (> (vlax-safearray-get-u-bound iPts 1)
0
)
(progn ;array holds values, convert it
(setq iPts ;to a list.
(vlax-safearray->list iPts)
)
;Loop through list constructing points
(while (> (length iPts) 0)
(setq Pts(cons (list (car iPts)
(cadr iPts)
(caddr iPts)
)
Pts
)
iPts (cdddr iPts)
)
)
)
)
(setq N2 (1+ N2))
) ;inner loop end
(setq N1 (1+ N1))
;outer loop end
Pts
) ;return list of points found
(setq all (ssget "X"))
(get_all_inters_in_SS all)
z是10000000? “e”用于表示非常小的亚单位坐标:
(expt 10.0 - ;will return 1.0e-008
(princ 0.00000001) ;will return 1.0e-008
也可能遇到大数字:
(expt 10.0 ;will return 1.0e+008 关于第一个问题,你看到的是显示值,它实际上是一个双精度浮点数。它可能“看起来”是一样的,也可能是一样的,但不是真的。
您发布的代码中有一个错误的右括号
(defun get_all_inters_in_SS (SS / SSL ;length of SS
PTS ;returning list
aObj1 ;Object 1
aObj2 ;Object 2
N1;Loop counter
N2;Loop counter
iPts ;intersects
)
(setq N10 ;index for outer loop
SSL (sslength SS)
)
; Outer loop, first through second to last
(while (< N1 (1- SSL))
; Get object 1, convert to VLA object type
(setq aObj1 (ssname SS N1)
aObj1 (vlax-ename->vla-object aObj1)
N2 (1+ N1)
) ;index for inner loop
; Inner loop, go through remaining objects
(while (< N2 SSL)
; Get object 2, convert to VLA object
(setq aObj2 (ssname SS N2)
aObj2 (vlax-ename->vla-object aObj2)
; Find intersections of Objects
iPts(vla-intersectwith
aObj1
aObj2
0
)
; variant result
iPts(vlax-variant-value iPts))
; Variant array has values?
(if (> (vlax-safearray-get-u-bound iPts 1)
0
)
(progn ;array holds values, convert it
(setq iPts ;to a list.
(vlax-safearray->list iPts)
)
;Loop through list constructing points
(while (> (length iPts) 0)
(setq Pts(cons (list (car iPts)
(cadr iPts)
(caddr iPts)
)
Pts
)
iPts (cdddr iPts)
)
)
)
)
(setq N2 (1+ N2))
) ;inner loop end
(setq N1 (1+ N1))
)
;outer loop end
Pts
) ;return list of points found
(setq all (ssget "X" ))
(get_all_inters_in_SS all)
HTH公司 http://en.wikipedia.org/wiki/Scientific_notation#E_notation
切换到2d工作区,你认为可能有帮助吗?
页:
[1]