Ciaran_mccreary 发表于 2022-7-6 03:15:12

参考网格

它有一个Lisp,它将参照网格进行注释。
我想读一个csv并输入到最近网格交点的距离。
 
让我举个例子
 
例如,我在a*中有以下内容。csv

Commandobill 发表于 2022-7-6 03:24:35

 
之后你似乎被切断了
朋友

Lee Mac 发表于 2022-7-6 03:33:26

离题,但。。。Commandobill!
很高兴看到你回来!

Commandobill 发表于 2022-7-6 03:38:01

 
谢谢你,伙计!我移动了状态,不再使用autoCAD=(但“FreeRefill”退出了,所以我的老老板让我再次为他编写lisps。
 
你比我上次在这里发布的内容早了几光年!难以置信的工作,说真的。。。

Ciaran_mccreary 发表于 2022-7-6 03:47:45

抱歉,我不知怎么断开了
 
假设我有一个csv,它概述了网格的位置。
 
实例
 
网格名称,X,Y
A1,0,0
A2,01000
A3,02000
B11000,0
B220001000
 
等等等等
 
我现在想使用GRIDNAME作为参考。。。。。。。。。。因此,我可以将世界坐标系引用回网格。
下面是一个“屏幕抓取”我目前得到的和在泡沫是什么,我希望能够看到。
 

 
任何帮助都会很好
 
 
谢谢
 
西亚兰

Lee Mac 发表于 2022-7-6 03:53:55

 
很高兴看到你们再次在这里发帖,我记得你们两个都很好
 
 
干杯伙计!
 
很抱歉这些离题帖子-现在回到主题上来。

Commandobill 发表于 2022-7-6 04:03:57

 
这有点初级,没有很多检查来确保你得到了正确的信息,但我是基于你提供的信息。您也可以更改多行文字部分,使其说出您想要的内容。
 

(defun c:yeah ( / pnt file pntlist bob apntlst pntlst sttext)
(if (setq pnt (getpoint "\nClick the point you want: "))
   (progn
   (findfile "myfile.csv")
   (setq file (open "C://myfile.csv" "r"))
   (setq pntlst (list ""))
   (while (setq bob (read-line file))
(if (not (vl-string-search "GRID" (strcase bob)))
(progn
    (setq apntlst (list (substr bob 1 (vl-string-search "," bob)) (list (atoi (substr bob (+ 2 (vl-string-search "," bob)) (- (vl-string-search "," bob (vl-string-search "," bob)) 1))) (atoi (substr bob (+ 2 (vl-string-position (ascii ",") bob nil t)) (strlen bob))) 0)))
    (setq pntlst (vl-remove "" (cons apntlst pntlst)))
    )))
   (if pntlst
(progn
(setq pntlst (vl-sort pntlst '(lambda (z a) ( < (distance pnt (cadr z)) (distance pnt (cadr a))))))
(setq sttext (strcat "Gridline Reference \\P" "Closest point: " (caar pntlst)))
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(sb-mktxt2 sttext pnt)
(setvar "osmode" os)
))
   
   
   ))

)

(defun sb-mktxt2 (text pnt / )
(vlax-put-property (vla-addMText (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point pnt) 0 text))

)

Ciaran_mccreary 发表于 2022-7-6 04:09:57

太棒了我试试看!

Ciaran_mccreary 发表于 2022-7-6 04:22:40

嗨,伙计们,现在回到这里。
谢谢你到目前为止的帮助。我有一个Lisp程序的问题,并寻求一些进一步的帮助。lisp当前正在报告错误
 
 
它放置了“网格线参考”和“最近点:A003”,但没有给出到网格的距离
(见附件capture.jpg。我正在寻找示例.jpg)
 
我已附上*。我正在使用的csv和下面的是我正在使用的当前代码。
 
如果有人能帮忙,那就太好了。提前谢谢。
 
(defun c:yeah ( / pnt file pntlist bob apntlst pntlst sttext)
(if (setq pnt (getpoint "\nClick the point you want: "))
   (progn
   (findfile "GRIDLINE.csv")
   (setq file (open "C://GRIDLINE.csv" "r"))
   (setq pntlst (list ""))
   (while (setq bob (read-line file))
(if (not (vl-string-search "GRID" (strcase bob)))
(progn
    (setq apntlst (list (substr bob 1 (vl-string-search "," bob)) (list (atoi (substr bob (+ 2 (vl-string-search "," bob)) (- (vl-string-search "," bob (vl-string-search "," bob)) 1))) (atoi (substr bob (+ 2 (vl-string-position (ascii ",") bob nil t)) (strlen bob))) 0)))
    (setq pntlst (vl-remove "" (cons apntlst pntlst)))
    )))
   (if pntlst
(progn
(setq pntlst (vl-sort pntlst '(lambda (z a) ( < (distance pnt (cadr z)) (distance pnt (cadr a))))))
(setq sttext (strcat "Gridline Reference \\P" "Closest point: " (caar pntlst)))
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(sb-mktxt2 sttext pnt)
(setvar "osmode" os)
))
   
   
   ))

)

(defun sb-mktxt2 (text pnt / )
(vlax-put-property (vla-addMText (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point pnt) 0 text))

)



网格线。csv
页: [1]
查看完整版本: 参考网格