mig20 发表于 2022-7-6 06:07:53

用于多CAD的LayerDirector

**我在另一个网站上发布了这个问题,这里的很多人也经常发这个问题,所以我提前道歉,不希望两个论坛都有答案。**
 
我经常在四种不同的CAD标准之间使用自己的图层集,我使用Lee Mac的LayerDirector(谢谢Lee)为每个标准提供图层列表,但在切换项目时必须手动重新加载正确的图层。
 
这并不是世界末日必须这么做,但我想把它推广给其他用户,以帮助强制执行正确的层使用,不过我希望它自动化,这样他们就不必自己加载LayerDirector。
 
我的第一个想法是在图形中使用一个变量来标识要使用的标准(我以为PROJECTNAME会这样做),然后LayerDirectory会知道要使用哪个图层列表,或者设置一个项目搜索路径,加载正确的lisp。
 
欢迎提供任何建议或帮助!
 
谢谢
 
 
ps.我不知道是否启动另一个线程,因为这是一个类似的问题,但我目前有一个用于每个CAD标准的工具选项板,这些标准几乎相同,允许我运行相同的LISP/脚本,但对每个标准进行了轻微修改。如果可以设置在每个图形中识别的项目搜索路径,那么我只需要维护一个版本的工具选项板,它就会相应地找到正确版本的lisp/script。

Lee Mac 发表于 2022-7-6 06:26:14

欢迎来到CADTutor;我很高兴你发现我的图层控制器在你的工作中非常有用。
 
PROJECTNAME系统变量如何与CAD标准的名称关联?
i、 e.CAD标准的名称是否与PROJECTNAME相同?
 

BIGAL 发表于 2022-7-6 06:30:10

与Lee一样,变量USERI1-USERI5的简单使用可以用于检索存储值,但需要注意的是,其他程序也可能会写入USERI1。更好的方法是使用字典变量
 
(setvar "USERI1" 1)
(setq layerstd (getvar "USERI1")


 
本例存储了两个变量wallsize和thickness
 
(defun get-or-create-Dict (/ adict)

;;test if "LAYSTD" is already present in the main dictionary
(if (not (setq adict (dictsearch (namedobjdict) "LAYSTD")))

   ;;if not present then create a new one and set the main
   ;; dictionary as owner
   (progn

   (setq adict (entmakex '((0 . "DICTIONARY")(100 . "AcDbDictionary"))))

   ;;if succesfully created, add it to the main dictionary
   (if adict (setq adict (dictadd (namedobjdict) "LAYSTD" adict)))
   )

   ;;if present then just return its entity name
   (setq adict (cdr (assoc -1 adict)))
)
)

(defun get-or-make-Xrecord (/ adict anXrec)
; change to allow w1 etc and thickness

(cond
    ;;first get our dictionary. Notice that "LAYSTD" will be
   ;;created here in case it doesn't exist
   ((setq adict (get-or-create-Dict))
   (cond
       ;;if "LAYSTD" is now valid then look for "LAYSTDVARS" Xrecord
      ((not (setq anXrec (dictsearch adict wallvar)))
;the variable LAYSTDvars is name of xrecord so need to be a variable to add lots
       ;;if "LAYSTDVARS" was not found then create it
       ;(setq anXrec (entmakex '((0 . "XRECORD")
(setq anXrec (entmakex (list (cons 0"XRECORD")
                               (cons 100"AcDbXrecord")
                               ;(1 . wallvar)
   (cons 1 wallvar)
   (cons 40 wallsize)
    ;(40 . wallsize)
                               )
                  )
       )
       ;;if creation succeeded then add it to our dictionary
       (if anXrec (setq anXrec (dictadd adict wallvar anXrec)))
      )
      ;;if it's already present then just return its entity name
      (setq anXrec
       (cdr (assoc -1 (dictsearch adict wallvar)))
      )
    )
   )
)
)
(defun getLAYSTDvars (/ vars varlist)
;;retrieve XRecord "wallvar" from dictionary "LAYSTD"
;;which in turn calls both functions above
(setq vars (get-or-make-Xrecord))

;;if our Xrecord is found, then get values in group code
(cond (vars
      (setq varlist(entget vars))
      (setq WALLname (cdr (assoc 1 varlist)))
      (setq WALLTHICK(cdr (assoc 40 varlist)))
       )

       ;;otherwise return nil
       (T nil)
)
)

mig20 发表于 2022-7-6 06:39:31

 
谢谢李,我已经在这个网站上潜伏了一段时间了,现在我决定“潜入”了。一段时间以来,我一直很欣赏你的作品,你在帖子中的Lisp程序和建议为我节省了无数的工作时间。
 
 
是的,我最初的想法是将PROJECTNAME(或绘图中的另一个变量)设置为CAD标准的名称-例如STD1、STD2等-或类似的名称。

mig20 发表于 2022-7-6 06:48:49

 
 
 
..谢谢你,比格尔
 
正如我对李所说,我的第一个想法是使用一个现有的变量,我知道它不是由我们的团队提供的(我的工作更少),但如果没有做到这一点,就无法生成代码能够识别的“swtich”。你的建议也给了我这个选择和一些需要调查的东西。
 
我从昨晚一片空白变成了今天要尝试的几个选项,还有你自己和李的有用回复。有时,只是提出一个问题,让旧的灰质工作得更好!!
 
 
非常感谢

Lee Mac 发表于 2022-7-6 07:01:37

 
我很高兴你终于冒险了。。。
感谢您的好评,我很高兴我的帖子和程序为您节省了工作时间。
 
 
我建议将我的Layer Director程序的第45-52行(包括第45-52行)替换为以下内容:
在这里,红色标记的部分是项目特定的图层设置,列表中的第一项等于PROJECTNAME系统变量的值。
 
以绿色标记的部分是默认图层设置,也就是说,如果PROJECTNAME系统变量的值与第一个列表中的项目不匹配。
 
我希望这有帮助!

mig20 发表于 2022-7-6 07:15:31

再次谢谢你,李,我来痛击一下
页: [1]
查看完整版本: 用于多CAD的LayerDirector