关于第一个问题,你看到的是显示值,它实际上是一个双精度浮点数。它可能“看起来”是一样的,也可能是一样的,但不是真的。
您发布的代码中有一个错误的右括号
- (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 N1 0 ;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公司 |