BlackBox 发表于 2022-7-6 10:34:58

为了提高效率,我也建议您重新修改代码。
 
我的两分钱。。。
 


;;;--------------------------------------------------------------------;
;;; Load personal settings function:
(defun c:LPS(/ linList linetypesTable layerTable layerName layerItem
            layerColor layerLineType)
(vl-load-com)
(vla-startundomark
   (cond (*activeDoc*)
         ((setq *activeDoc*
               (vla-get-activedocument (vlax-get-acad-object))))))

;; Linetypes check
(foreach lin'("hidden"
               "hidden2"
               "hiddenx2"
               "center"
               "center2"
               "centerx2"
               "phantom"
               "phantom2"
               "phantomx2")
   (if (not (tblsearch "LTYPE" lin))
   (setq linList (cons lin linList))))
(if linList
    (foreach linlinList
      (vla-load
      (cond
          (linetypesTable)
          ((setq linetypesTable (vla-get-linetypes *activeDoc*))))
      lin
      "acad.lin")))

;; Layer check
(foreach lay'(("BALLOON" "15" "CONTINUOUS")
               ("BORDER" "33" "CONTINUOUS")
               ("BOTTOM" "31" "CONTINUOUS")
               ("CENTER" "35" "CENTER" "")
               ("CONSTRUCTION" "5" "PHANTOM")
               ("DIMENSION" "40" "CONTINUOUS")
               ("FRONT" "83" "CONTINUOUS")
               ("GHOST" "12" "CONTINUOUS")
               ("HATCH" "123" "CONTINUOUS")
               ("HIDDEN" "252" "HIDDEN2")
               ("PART" "7" "CONTINUOUS")
               ("REV" "1" "CONTINUOUS")
               ("SECTION" "5" "PHANTOM2")
               ("SIDE" "30" "CONTINUOUS")
               ("NOTES" "40" "CONTINUOUS")
               ("TOP" "6" "CONTINUOUS"))
   (setq layerTable (vla-get-layers *activeDoc*))
   (if (tblsearch "LAYER" (setq layerName (car lay)))
   (setq layerItem (vla-item layerTable layerName))
   (setq layerItem (vla-add layerTable layerName)))
   (if (/= (setq layerColor (cadr lay)) (vla-get-color layerItem))
   (vla-put-color layerItem layerColor))
   (if (/= (setq layerLineType (caddr lay))
         (vla-get-linetype layerItem))
   (vla-put-linetype layerItem layerLineType))
   ;; <- Additional layer checks go here, eg. freeze, description, etc.
   )
(vla-endundomark *activeDoc*)
(princ))
;;;--------------------------------------------------------------------;
(if (= 1 (getvar 'dwgtitled))                                           ; If drawing is named,
(c:LPS))                                                            ; Load personal settings
;;;--------------------------------------------------------------------;
(princ)

Jack_O'nei 发表于 2022-7-6 10:38:06

Diedesigner 发表于 2022-7-6 10:42:37

Thanks all!
 
I will study your revamped code examples and suggestions - it looks like the answer to my original post is in there.

MarcoW 发表于 2022-7-6 10:49:28

Hi Diedesigner,
 
I just happen to read this, maybe I can help because, one day, I had exactly the same problem.
 
It was caused by anin a lisp routine. Or so to say a "" too much. I cannot tell exactly how and where but I'd say somewhere at the end of a code.
 
What happens is when AutoCAD starts up, the routine is loaded, and anis given. Just the same as when starting up vanilla AutoCAD; when ready, hit enter and the help pops up.
 
My 2 cents.

CADkitt 发表于 2022-7-6 10:51:30

("center" "35" "center" "")
页: 1 [2]
查看完整版本: 启动Autoc时打开帮助