guitarguy1685 发表于 2022-7-5 16:25:58

如何检查特定Let

我想检查一下电脑上是否有硬盘。
 
我正在编写一个lisp,它将自动设置所有支持路径。系统将提示用户是希望支持路径指向其本地“C”驱动器还是指向服务器。
 
如果他们想让它指向他们的本地,我想运行一个检查,看看下面的路径是否存在
 
“C:\CompanyCAD”。
 
如果他们想指向服务器,我需要检查他们是否已经绘制了这个驱动器
 
“L:\工程\公司CAD
 
我仍然可以设置路径,而不让他们访问任何一个驱动器,如果他们没有访问,我只想发送一个警告。
 
如果你想知道为什么有些人需要本地访问。有些人在异地工作,并在本地加载我们的CAD库,并以这种方式工作,因为使用VPN运行AutoCAD有点糟糕。不确定这是ACAD的问题还是他们的ISP的问题。

Lee Mac 发表于 2022-7-5 16:33:34

以下函数将返回正在使用的驱动器号列表:
;; Drive Letters-Lee Mac
;; Returns a list of drive letters currently in use

(defun LM:driveletters ( / fso rtn )
   (if (setq fso (vlax-create-object "scripting.filesystemobject"))
       (progn
         (vl-catch-all-apply
            '(lambda ( )
                   (vlax-for obj (vlax-get fso 'drives)
                     (setq rtn (cons (vlax-get obj 'driveletter) rtn))
                   )
               )
         )
         (vlax-release-object fso)
         (vl-sort rtn '<)
       )
   )
)

Roy_043 发表于 2022-7-5 16:39:37

@罗伊,
我会使用:
; List all available disks (A: to Z:).
(defun KGA_File_DiskList ()
(vl-remove-if-not
   'vl-file-directory-p
   '("A:" "B:" "C:" "D:" "E:" "F:" "G:" "H:" "I:" "J:" "K:" "L:" "M:" "N:" "O:" "P:" "Q:" "R:" "S:" "T:" "U:" "V:" "W:" "X:" "Y:" "Z:")
)
)
这对懒惰的代码编写者来说并不是什么大事。

Grrr 发表于 2022-7-5 16:45:45

另一个
 

_$ (mapcar (function (lambda (x) (strcat x ":"))) (mapcar 'chr (vl-string->list "ABCDEFGHIJKLMNOPQRSTUVWXYZ")))
("A:" "B:" "C:" "D:" "E:" "F:" "G:" "H:" "I:" "J:" "K:" "L:" "M:" "N:" "O:" "P:" "Q:" "R:" "S:" "T:" "U:" "V:" "W:" "X:" "Y:" "Z:")

Tharwat 发表于 2022-7-5 16:51:02

 
是-可以在此处找到完整的WMI引用。
 
 
您所指的链接是一个可用于FileSystemObject(FSO)实例的属性列表。vlax创建对象函数允许您实例化一个类,允许您访问该类的属性和方法。

guitarguy1685 发表于 2022-7-5 16:54:40

 
谢谢你澄清李你在LISP的各个方面都太先进了。。。

Lee Mac 发表于 2022-7-5 16:56:36

李似乎无所不知。说真的,我还没发现他有什么问题。

Grrr 发表于 2022-7-5 17:03:21

guitarguy1685 发表于 2022-7-5 17:06:54

 
okay, wtf!?How does one even know that stuff is available? I did a google search on "scripting.filesystemobject" and this is what I found
 
FileSystemObject
 
Is this a list of properties i can access via "vlax-create-object"?

BIGAL 发表于 2022-7-5 17:14:09

This may be usefull, note the first part which checks for directories ie drives.
 

; resets the paths usefull for update versions of Autocad; by A H 2011; This sets a reference to the install path of your product; the gets are their for info maybe other use; use this to find other settings ;(vlax-dump-object (vla-get-files (vla-get-preferences (vlax-get-Acad-object))) T)(vl-load-com)(defun setpaths ( / *files* doc) ; make temp directory(if (vl-file-directory-p "C:\\Acadtemp\\")(Princ "Acadtemp exists")(vl-mkdir "C:\\AcadTEMP\\"))(setq *files*(vla-get-files(vla-get-preferences (vlax-get-Acad-object)))); savepath;(vla-get-AutoSavepath *files*)(vla-put-AutoSavepath *files* "C:\\AcadTemp"); custom icons;(vla-get-CustomIconPath *files*))(vla-put-CustomIconPath *files* "P:\\Autodesk\\ICONS"); custom menu;(vla-get-Menufile *files*));(vla-put-Menufile*files* "C:\\Users\\2013COGG"); printers config;(vla-get-PrinterConfigPath *files*)(vla-put-PrinterConfigPath *files* "P:\\AutoDESK\\Plotting\\Plot Styles 2011"); printers style sheet;(vla-get-PrinterStyleSheetPath *files*)(vla-put-PrinterStyleSheetPath *files* "P:\\AutoDESK\\Plotting\\Plot Styles"); printer drv's;(vla-get-PrinterDescPath *files*)(vla-put-PrinterDescPath *files* "P:\\AutoDESK\\Plotting\\Drv"); print spooler;(vla-get-PrintSpoolerPath *files*)(vla-put-PrintSpoolerPath *files* "C:\\AcadTemp\\"); templatepath;(vla-get-TemplateDwgPath *files*)(vla-put-TemplateDwgPath *files* "P:\\Autodesk\\c3d Templates"); template location;(vla-get-QnewTemplateFile *files*)(vla-put-QnewTemplateFile *files* "P:\\Autodesk\\c3d Templates\\gg.dwt");make new support paths exist + new(setq paths (vla-get-SupportPath *files*))(setq coggpaths "P:\\autodesk\\supportfiles;P:\\autodesk\\lisp;P:\\autodesk\\fonts;")(setq newpath (strcat coggpaths paths))(vla-put-SupportPath *files* newpath); Tempdirectory ;(vla-get-TempFilePath *files*))(vla-put-TempFilePath *files* "C:\\AcadTemp\\");   PlotLogFilePath = "C:\\Documents and Settings\\ah\\localsettings\\application data\\autodesk\\c3d 2011\\enu\\"(vla-put-PlotLogFilePath *files* "C:\\AcadTemp\\");   LogFilePath = "C:\\Documents and Settings\\ah\\localsettings\\application data\\autodesk\\c3d 2011\\enu\\"(vla-put-LogFilePath *files* "C:\\AcadTemp\\"); xref temp path;(vla-get-TempXrefPath *files*))(vla-put-TempXrefPath *files* "C:\\AcadTemp\\"); end use of *files*)(setpaths); exit quitely(princ "All Done")
页: [1] 2
查看完整版本: 如何检查特定Let