ASMI,
非常感谢,这正是我想要的。
我确实注意到,在输出文件中,值用分号而不是逗号分隔。这有什么原因吗?
我已经设法和你的*玩了。lsp将输出值用逗号分隔,这似乎确实有效。
我还在开头加了一点描述,在结尾加了一行,提醒我键入什么命令。我已附上*。lsp适用于任何其他可能觉得有用的人。
- ;;;--------------------------------------------------------------------------;
- ;;; DESCRIPTION
- ;;; This is a utility that exports the X,Y,Z co-ordinates of the selected 3D polyline to a *.csv file.
- ;;; The *.csv file is saved in the same folder as the autocad *.DWG with the same file name prefix.
- ;;; e.g. the CSV file created from a 3d polyline extracted from "Example.dwg" would be named "Example.csv"
- ;;;
- ;;; Thank you to ASMI for writing this .lsp
- ;;;
- (defun c:3csv (/ cPl cFmn fVar pLst cAns *error*)
- (vl-load-com)
- (defun *error*(msg)
- (if fVar(close fVar))
- (princ)
- ); end of *error*
- (defun Extract_3DPoly_Vertexes(Ent / cLst oLst)
- (if(= 'ENAME(type Ent))
- (setq Ent(vlax-ename->vla-object Ent))
- ); end if
- (if(= "AcDb3dPolyline"(vla-get-ObjectName Ent))
- (progn
- (setq cLst(vlax-safearray->list
- (vlax-variant-value
- (vla-get-Coordinates Ent))))
- (while cLst
- (setq oLst(cons
- (list
- (car cLst)
- (cadr cLst)
- (nth 2 cLst))
- oLst)
- ); end setq
- (repeat 3(setq cLst(cdr cLst)))
- ); end while
- (reverse oLst)
- ); end progn
- ); end if
- ); end of Extract_3DPoly_Vertexes
- (if(and
- (setq cPl(entsel "\nSelect 3D-Polyline > "))
- (= "POLYLINE"(cdr(assoc 0(entget(setq cPl(car cPl))))))
- ); and
- (progn
- (setq fVar(open(setq cFmn(strcase(strcat(getvar "DWGPREFIX")
- (vl-filename-base(getvar "DWGNAME")) ".csv"))) "a")
- pLst(Extract_3DPoly_Vertexes cPl)
- ); end setq
- (write-line "X,Y,Z" fVar)
- (foreach pt pLst
- (write-line
- (strcat(rtos(car pt))","(rtos(cadr pt))","(rtos(last pt)))
- fVar)
- ); end foreach
- (close fVar)
- (alert(strcat "\nCSV File location: " cFmn))
- ); end progn
- (princ "<!> It isn't 3D-Polyline <!> ")
- ); end if
- (princ)
- ); end of c:3csv
- (princ "\nType 3csv to run")
再次感谢大家,
安得烈
3csv。lsp |