Is it possible to load a lin file using lisp (still learning)? I have come up with the following, but seems to crash on my path.
Thanks in advance for the help...
(defun c:LoadLinetypes ( )
(setvar 'CMDECHO 0)
(command "-linetype" "_Load" "" "C:\Users\Public\Autodesk\R19.1\linetypes\company.lin" "")
(*error* nil)
(princ "\nLinetypes have been loaded ")
(princ)
)
Consider:
(command "._linetype" "load" "FileName.lin" "LineTypeName")
... Vs.:
(vl-load-com) (vla-load (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object))) "LineTypeName" "FileName.lin" )
... More on the vla-Load Method.
"How we think determines what we do, and what we do determines what we get."
dwk1204 wrote:
"but seems to crash on my path."
for the path try
"C:\\Users\\Public\\Autodesk\\R19.1\\linetypes\\company.lin"
or
"C:/Users/Public/Autodesk/R19.1/linetypes/company.lin"
Henrique
This works for me :
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Load all Linetypes from acadiso.lin file ;; ;; from: ribarm ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:Loadltypes ( / fn f rl ltname ltypes ) (setq fn (open (setq f (findfile "acadiso.lin")) "r")) (while (setq rl (read-line fn)) (if (eq "*" (substr rl 1 1)) (setq ltname (substr rl 1 (vl-string-position (ascii ",") rl)))) (if ltname (progn (setq ltname (vl-string-left-trim "*" ltname)) (setq ltypes (cons ltname ltypes)) ) ) ) (foreach ln ltypes (command "_.linetype" "l" f "" "s" ln "") ) (command "_.linetype" "s" "ByLayer" "") (princ) )
Marko Ribar, d.i.a.
ribarm@gmail.com
(setvar "expert" 3)
(command "-linetype" "load" "*" "company.lin" "")
remember to include the asterisk for the "Enter linetype(s) to load:" prompt to load all linetypes in the .lin file. You can also choose specific linetypes within your .lin file to load.
You will not need to include the full path as long as the folder that contains company.lin is mapped in the support file search path. This will save you from rewriting your code if the file is ever moved. To check: (findfile "company.lin")
(defun _loadAllLinetypes (linFile) (if (setq linFile (findfile linFile)) (progn (command "_.-linetype" "_l" "*" linFile) (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (command "")) T ) ) )
Thanks very much for the code.
My Code:
(defun c:LT_LoadAll () (setvar "expert" 3) (command "-linetype" "load" "*" "Company name Linetypes.lin" "") (princ) ) (prompt "\n:: LT_LoadAll.lsp loaded ::") (princ) (prompt "\n:: Invoke by typing 'LT_LoadAll' ::") (princ)
Just replace 'Company name Linetypes' with your file and as michael.deleurere mentioned just add the path of your .lin file in the support path.
Kudos m.deleurere on the 'EXPERT' setting solution. Simple and effective. Thanks!