TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: drumbald on December 29, 2005, 01:34:55 PM
-
I have a linetype Ln.lin its in C:\l-type\
I want to load it with the following lisp file
Right now it will only load from the acad.lsp file
(defun C:LTLD ()
(setvar "CMDECHO" 0)
(foreach X '("hidden" "dashed" "batting" "center" "border" "dot"
"tracks" "phantom")
(LTLOAD X)
)
(setvar "CMDECHO" 1)
(princ)
)
(defun LTLOAD ( ltname )
(if (not (tblsearch "ltype" ltname))
(vl-cmdf "-linetype" "l" ltname "" "")
)
(setvar "CMDECHO" 1)
(princ)
)
-
Try something like this that specifies the file to load from:
(defun C:LTLD ()
(setvar "CMDECHO" 0)
;;adjust path/filename as needed
(foreach X '(("hidden" . "acad.lin") ("dashed" . "acad.lin") ("batting" . "acad.lin")
("center" . "acad.lin") ("border" . "acad.lin") ("dot" . "acad.lin")
("tracks" . "C:\\l-type\\Ln.lin") ("phantom" . "C:\\l-type\\Ln.lin"))
(LTLOAD X)
)
(setvar "CMDECHO" 1)
(princ)
)
(defun LTLOAD ( ltname )
(if (not (tblsearch "ltype" (car ltname)))
(vl-cmdf "-linetype" "l" (car ltname) (cdr ltname) "")
)
)
-
Jeff
I like that method. Here is taking it one step further.
(defun c:ltld (/ lt_data ltypes fname ltname usercmd)
(setq usercmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(vl-load-com)
(setq ltypes (vla-get-linetypes
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
;; load the linetypes
(foreach lt_data '(("hidden" . "acad.lin")
("dashed" . "acad.lin")
("batting" . "acad.lin")
("center" . "acad.lin")
("border" . "acad.lin")
("dot" . "acad.lin")
("tracks" . "C:\\l-type\\Ln.lin")
("phantom" . "C:\\l-type\\Ln.lin")
("xyz" . "cab.lin")
)
(setq ltname (car lt_data)
fname (cdr lt_data)
)
(cond
((tblsearch "ltype" ltname)
(prompt (strcat "\nLinetype " ltname " already loaded."))
)
((not (findfile fname))
(prompt (strcat "\nCan not find file " fname))
)
(t
(setq err (vl-catch-all-apply 'vla-load (list ltypes ltname fname)))
(cond
((vl-catch-all-error-p err)
(prompt (strcat "\n" (vl-catch-all-error-message err) " " ltname " from file " fname))
)
((vla-item ltypes ltname)
(prompt (strcat "\nLinetype " ltname " loaded from file " fname "."))
)
(t
(prompt (strcat "\nError Linetype " ltname " not loaded, file " fname "."))
)
)
)
)
)
(setvar "CMDECHO" usercmd)
(princ)
)
-
Thanks Alan. I was going to do something similar to what you did but didn't have time. I would like to know why you would need to fine a file though......possibly for misbehaving?
(prompt (strcat "\nCan not fine file " fname))
:-)
-
spelling error, again :-o
I think its a typo, e key next to d key and no proof reader. :-)
Thanks for the catch.
-
Just came across this quote, and thought of you .. well me too actually ..
My spelling is wobbly. It's good spelling but it wobbles and the letters get in the wrong places.
... Winnie the Pooh
-
:-) :-) :-)
-
Here is my feable approach. I first did it to play around with dcl, really don't use it that much.
Sorry I went down that dark path and the LNU dialog based routine is not a standalone version.
Gary