rob150588 发表于 2022-7-6 09:45:45

使用Lisp搜索并插入mu

早上好。
 
I'v编写了一个很短的例程,用于插入服务器上的地图块,用户只需键入所需的网格引用。所有瓷砖均以其参考号命名(即SJ4522或NZ0572)
 

(defun c:mmbmap ( / GRDREF MAPPATH)
(setvar "cmdecho" 1)
(setq GRDREF (getstring "Enter Grid Ref : "))
(setq MAPPATH (strcat "N:/CAD/2D/MappingTiles/" GRDREF ".dwg"))
(command "_.insert" MAPPATH "0,0,0" "1" "" "")
(command "zoom" "o" "l" "")
(princ))

 
这很简单,但是(总是有一个BUT),大约10%的图块文件大小很大,它们被分成4个图块(即,不是SE5076,而是SE5076NE、SE5076NW、SE5076SE、SE5076SW)。
 
所以我要问的是,我的例程是否可以修改为只搜索文件名的前6个字符,如果它找到多个具有该名称的文件来插入所有文件?

Hippe013 发表于 2022-7-6 09:55:13

我建议使用dos\u find函数。它是DosLib的一部分,可以在以下站点免费下载:http://www.mcneel.com
 
您可以对文件进行通配符搜索,它将返回文件名列表。然后知道列表中的项目数,在例程的插入部分重复一次。此外,DosLib还提供了许多其他有用的功能。
 
祝您愉快!
 
Hippe013

rob150588 发表于 2022-7-6 09:59:23

谢谢你的回复。
 
这可能会起到作用。。。
 
我假设DosLib必须安装在需要调用该函数的每台计算机上,这对吗?
 
或者可以将所需的函数放在服务器上并从那里调用它吗?
 
我更喜欢后一种选择,因为这是一种企业定制,可在多个有大量机器的地点使用。
 
干杯

Tharwat 发表于 2022-7-6 10:03:36

实际上,如果您将图形如下图所示放在Autocad reference文件夹中,则可以使用函数查找任何一个
你想要多少。
 
将绘图添加到此文件夹中,让例程为您找到它们。。。。
希望这个程序能帮你。

(defun c:Test ( / Nme FName) (vl-load-com)
(if (and (setq Nme (getstring T "\n Enter name of Drawing :" ))
   (setq FName (findfile (strcat Nme ".dwg")))
          )
(vl-cmdf "_.-insert" FName pause "" "" "")
   (alert "File not found ")
   )
(princ)
)
Tharwat

Hippe013 发表于 2022-7-6 10:09:06

 
DosLib是一个arx文件,只需添加到appload中的每台计算机的启动套件中即可。实际的arx文件将驻留在服务器上的某个位置。

alanjt 发表于 2022-7-6 10:14:48

这是我一年前做的一个快速引入GIS DWG的例子。它只是在0,0,0处插入一组选定的DWG/DXF。
 
(defun c:GISIn (/ lst)
;; Alan J. Thompson
(if (setq lst (dos_getfilem
               "Select drawing files to insert at 0,0,0"
               (getvar "dwgprefix")
               "*.dwg;*.dxf|*.DXF;*.DWG"
               )
   )
   (foreach x (cdr lst) (vl-cmdf "_.-insert" (strcat (car lst) x) "0,0,0" "" "" ""))
)
(princ)
)
 
 
 
你所要做的就是把arx文件放在服务器上,然后从你公司的acaddoc文件中加载它。
 
这是我保存在阿卡多克里面的东西。LSP:
 
(vl-some
(function (lambda (dos)
             (or (vl-position dos (arx))
               (not (vl-catch-all-error-p (vl-catch-all-apply (function arxload) (list dos))))
             )
         )
)
'("doslib17.arx" "doslib18.arx")
)
 
可以缩短,但我需要它在2009年和2011年加载。

David Bethel 发表于 2022-7-6 10:17:37

来自我的acad。lsp:

(defun load_exp (/ v p a av)
(setq v (ver)
       p (getvar "PLATFORM")
       a (getvar "ACADVER"))

(setq av (cond ((and (wcmatch a "*12*")
                      (wcmatch p "*DOS*"))
                  "12DOS")
                ((and (wcmatch a "*12*")
                      (wcmatch p "*Win*"))
                  "12WIN")
                ((and (wcmatch a "*13*")
                      (wcmatch p "*DOS*"))
                  "13DOS")
                ((and (wcmatch a "*13*")
                      (wcmatch p "*Win*"))
                  "13WIN")
                ((wcmatch a "*14*")
                  "14")
                ((wcmatch a "*15*")
                  "15")
                (T "UnKnown")))

(cond ((= av "12DOS")
      (and (not (member "C:/ACAD/12/ACADAPP.EXP" (ads)))
             (xload "c:/acad/12/acadapp.exp"))
      (and (not (member "C:/ACAD/12/HPMPLOT.EXP" (ads)))
             (xload "c:/acad/12/hpmplot.exp"))
      (and (not (member "C:\\ACAD\\UT\\DOSLIB12.EXP" (ads)))
             (xload "doslib12.exp")))
       ((= av "12WIN")
      (and (/= (type dos_dir) 'EXSUBR)
             (xload "doslib12.exe")))
       ((= av "13DOS")
      (xload "c:/acad/13/acadapp.exp")
      (xload "c:/acad/13/hpmplot.exp")
      (and (/= (type dos_dir) 'EXSUBR)
             (xload "doslib13.exp")))
       ((= av "13WIN")
      (load "c:/acad/common/ai_utils.lsp")
      (load "c:/acad/common/appload.lsp")
      (and (/= (type dos_dir) 'EXSUBR)
             (xload "doslib13.exe"))
      (and (not (member "c:\\accuren2\\accurend.arx" (arx)))
             (arxload "c:/accuren2/accurend.arx")))
       ((= av "14")
      (and (not (member "doslib14.arx" (arx)))
             (arxload "doslib14.arx")))
       ((= av "15")
      (and (not (member "doslib2k.arx" (arx)))
             (arxload "doslib2k.arx")))))

 
保持多个版本的运行非常有趣-大卫

alanjt 发表于 2022-7-6 10:25:16

伙计,我对两个很恼火。

irneb 发表于 2022-7-6 10:25:56

这里有一种根本不需要使用DosLib的方法:
然后你应该把你的函数改成这样:
顺便说一句,matchfiles适用于多个匹配。因此,您实际上可以使用类似“C:\\Temp\\*.DWG,N:\\CAD\\2D\\MappingTiles\\*.DWG”的内容来搜索这两个文件夹。

rob150588 发表于 2022-7-6 10:32:46

谢谢你的回复。
 
我决定走非DosLib路线,只是为了保持服务器上的一切整洁(尽管我可能会后悔)。
 
我使用了irneb的代码来插入所需的映射,效果相当好。
 
然而,基于irneb的评论,我不得不问,块插入方法并不完全可靠,为什么会这样?始终接受建议
页: [1] 2
查看完整版本: 使用Lisp搜索并插入mu