请试试这个函数,是到CSV文件的。excel有点麻烦
- ;;;参数 SourcePoly 要计算的多段线图元名 TargetPoly 另一条多段线 CSVFile 输出文件名
- (defun NearstPtoCSV (SourcePoly TargetPoly CSVFile)
- (setq f (open CSVFile "a"))
- (if (vlax-curve-isClosed SourcePoly)
- (setq n (fix(1- (vlax-curve-getEndParam SourcePoly))))
- (setq n (fix(vlax-curve-getEndParam SourcePoly)))
- )
- (setq nn 0)
- (repeat n
- (setq p (vlax-curve-getPointAtParam SourcePoly nn)
- p1 (vlax-curve-getClosestPointTo TargetPoly p)
- d (rtos (distance p p1) 2 3)
- rtn (cons d rtn)
- )
- (setq nn (1+ nn))
- )
- (setq rtn (reverse rtn))
- (setq str "" nn 0)
- (repeat n
- (if (/= str "")
- (setq str (strcat str "," (nth nn rtn)))
- (setq str (nth nn rtn))
- )
- )
- (write-line str f)
- (close f)
- str
- )
|