(defun c:CurvInt(/ doc spc ss i j 1L oPt cEnt cObj Int iLst pt)
(vl-load-com)
(setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object))
spc (if (zerop (vla-get-activespace doc))
(if (= (vla-get-mspace doc) :vlax-true)
(vla-get-modelspace doc)
(vla-get-paperspace doc))
(vla-get-modelspace doc)))
(setq file (getfiled "\nSelect Location for Excel File"
(if def_file def_file "") "csv" 1))
(if (not (setq def_file file))
(exit))
(prompt "\nSelect Vertical Lines...")
(if (setq ss (ssget (list (cons 0 "LINE,*POLYLINE")
(if (getvar "CTAB")
(cons 410 (getvar "CTAB"))
(cons 67 (- 1 (getvar "TILEMODE")))))))
(progn
(setq oFile (open file "w") i 0 j 1 1L (chr 44))
(while (<= (setq i (1+ i)) (sslength ss))
(setq 1L (strcat 1L (itoa i) (chr 44))))
(write-line 1L oFile)
(setq oPt (getpoint "\nSpecify Origin <0,0,0> : "))
(or oPt (setq oPt '(0 0 0)))
(while (and (setq cEnt (car (entsel "\nSelect Curve to Measure: ")))
(member (cdr (assoc 0 (entget cEnt)))
'("LINE" "LWPOLYLINE" "POLYLINE" "SPLINE" "ARC")))
(setq cObj (vlax-ename->vla-object cEnt))
(foreach Obj(vl-sort
(mapcar 'vlax-ename->vla-object
(vl-remove-if 'listp
(mapcar 'cadr (ssnamex ss))))
'(lambda (x1 x2)
(< (car (vlax-curve-getStartPoint x1))
(car (vlax-curve-getStartPoint x2)))))
(setq Int (vlax-invoke cObj
'IntersectWith Obj
acExtendNone))
(if Int
(progn
(setq iLst (cons (- (car Int) (car oPt)) iLst)
pt (list (car Int) (cadr Int) (caddr Int)))
(vla-addDimRotated spc
(vlax-3D-point pt) (vlax-3D-point (list (car pt) (cadr oPt) 0))
(vlax-3D-point pt) (/ pi 2))
(vla-addDimRotated spc
(vlax-3D-point pt) (vlax-3D-point (list (car oPt) (cadr pt) 0))
(vlax-3D-point pt) 0))
(setq iLst (cons 0.0 iLst))))
(write-line (strcat "Curve " (itoa j) (chr 44) (Pnt->Csv iLst)) oFile)
(setq j (1+ j) iLst nil))
(close oFile))
(princ "\n<!> No Lines/*Polylines Selected <!>"))
(princ))
(defun Pnt->Csv(lst / Str)
(setq Str "")
(while lst
(setq Str (strcat (rtos (car lst)) (chr 44) Str)
lst (cdr lst)))
Str)
以前我只需要一个坐标,但现在我对船有不同的看法,所以我需要其他坐标轴。。因为输出很好,有2个坐标,甚至所有3个坐标(不知道它们是否在这个项目中变得方便-我知道我需要计算负载的体积和位置,所以可能需要进行3d绘制,这将有助于绘制线和找到曲线的距离等…)在单独的单元格中,因为我将其用于不同的2d视图,所以垂直线在其他投影视图中变为水平,我正在使用脚本,使水平线是垂直的(我很容易修复它,只是更改了(提示“\n选择垂直线…”提示“\n选择相交线…”)(我用同一个脚本来测量很多距离——当我需要距离时,我只需要画一条与曲线相交的线,然后用这个脚本找到所需的距离。)在表格中有这样的值是有用的,因为我在excel中使用了-函数,称为“Transpose”。。为了对信息进行重新排序,因为第一个工作表和第二个工作表都很直观,而在第三个工作表中,我用于准备(连接功能)和将信息回溯到Autocad,并与您的脚本和此完全集成,我首先在autocad中进行测量,查看结果,然后当我在计算中进行更改时,我只在第一个表格中键入它们,它们将其传输到第三个表格中,我只需在autocad中按ctrl+c,ctrl+v,它会自动绘制它。。。所以这个过程变成了半自动的。
所以这就像是库德画画一样。。。请参阅存档文件。。。因此,如果该脚本输出第一个表(在“Gettedcoordsfrom Autocad”表中),那将非常棒。。流程见全部3张。。
现在,输出仅在一个带有逗号的单元格中。这不像你在照片上展示的那样。。细胞分离没有发生在我身上:
http://img27.imageshack.us/img27/6287/outputo.png
基本上我需要x,y,z输出和曲线的名称和交点数。。。如果它不能发生,那么只有x,y才是最棒的。。
顺便说一下,删除脚本工作顺利!!!
实例拉链 它是否导出到。csv文件? 对这是的内容。在excel中打开的csv文件。。。
The output seems to be fine to me? - I know there is no y-value, but I thought you only wanted x values?
See pic attached for how mine appears in csv.
For deletion of dimension lines:
(defun c:CurvInt(/ doc spc ss i j 1L oPt cEnt cObj Int iLst pt dObjlst) (vl-load-com) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (setq file (getfiled "\nSelect Location for Excel File" (if def_file def_file "") "csv" 1)) (if (not (setq def_file file)) (exit)) (prompt "\nSelect Vertical Lines...") (if (setq ss (ssget (list (cons 0 "LINE,*POLYLINE") (if (getvar "CTAB") (cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq oFile (open file "w") i 0 j 1 1L (chr 44)) (while (vla-object cEnt)) (foreach Obj(vl-sort (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) '(lambda (x1 x2) (< (car (vlax-curve-getStartPoint x1)) (car (vlax-curve-getStartPoint x2))))) (setq Int (vlax-invoke cObj 'IntersectWith Obj acExtendNone)) (if Int (progn (setq iLst (cons (- (car Int) (car oPt)) iLst) pt (list (car Int) (cadr Int) (caddr Int))) (setq dObjlst (cons (vla-addDimRotated spc (vlax-3D-point pt) (vlax-3D-point (list (car pt) (cadr oPt) 0)) (vlax-3D-point pt) (/ pi 2)) dObjlst)) (setq dObjlst (cons (vla-addDimRotated spc (vlax-3D-point pt) (vlax-3D-point (list (car oPt) (cadr pt) 0)) (vlax-3D-point pt) 0) dObjlst))) (setq iLst (cons 0.0 iLst)))) (write-line (strcat "Curve " (itoa j) (chr 44) (Pnt->Csv iLst)) oFile) (setq j (1+ j) iLst nil) (initget "Yes No") (if (not (eq "No" (getkword "\nDelete Old Dimensions? : "))) (mapcar 'vla-delete dObjlst)) (setq dObjlst nil)) (close oFile)) (princ "\n No Lines/*Polylines Selected ")) (princ))(defun Pnt->Csv(lst / Str) (setq Str "") (while lst (setq Str (strcat (rtos (car lst)) (chr 44) Str) lst (cdr lst))) Str) Before i need only one coord but now I have different view of the ship so i need other axis coords..For the output is nice to have 2 coords even all 3(don't know if they became handy in future in this project - I know that i will need to calculate the volumes and placment of loads so maybe will need to go 3d it will be usefull to draw line and find distance of curve and etc.....)in separate cells because i'm using it for different 2d views so vertical lines became horizontalin other projection view and i'm lieing the script that horizontal lines are vertical(This I fix it easy just changed (prompt "\nSelect Vertical Lines..." with prompt "\nSelect Intersection Lines...")(I'm using the same script to measure a lot of distances - when I need distance I just make a linethat intersect curve and using this script find the needed distance.) It is usefull to have values in table like this because I'm using - function in excel called "Transpose".. To reorder the information because first sheet tables are nice visual and second sheet and in thirdsheetI use for preparing (CONCATENATEfunction )and drawing back information to Autocad- and to make full integration with your script and this, I first measure in autocad see the results then when I make change in calculations I only type it in first tables they transport it to third sheet there i just ctrl+c,ctrl+v back in Autocad and it draws it automaticlly... So the process becames semi-automatic.
So it is the idea like drawing by coords then... See atached file... So if this script outputs first tables(in sheet "Gettedcoordsfrom Autocad") it will be great..See all 3 sheets for the process..
Now the output is only in one cell with commas. it is not like you show on the picture.. The separation of cell didn't happen to me:
http://img27.imageshack.us/img27/6287/outputo.png
Basicly i need x,y,z output and name of curve and number of intersection... If it can't happen just x,y will be wonderfull..
By the way deleting script works smoothly!!!
example.zip Is it exporting to a .csv file? Yes.. this is the content of .csv file opened in excel...
页:
1
[2]