Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Load Line types with Lisp

9 REPLIES 9
Reply
Message 1 of 10
dwk1204
11236 Views, 9 Replies

Load Line types with Lisp

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)
)

9 REPLIES 9
Message 2 of 10
BlackBox_
in reply to: dwk1204

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."

Message 3 of 10
hmsilva
in reply to: dwk1204

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

EESignature

Message 4 of 10
marko_ribar
in reply to: hmsilva

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

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 5 of 10
m.deleurere
in reply to: dwk1204

(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")

 

 

Message 6 of 10
alanjt_
in reply to: dwk1204

(defun _loadAllLinetypes (linFile)
  (if (setq linFile (findfile linFile))
    (progn
      (command "_.-linetype" "_l" "*" linFile)
      (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (command ""))
      T
    )
  )
)

 

Message 7 of 10
3dwannab
in reply to: m.deleurere

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.

 

  1. Type GR (Opens options dialog box)
  2. Files tab
  3. Add your path to the Support File search path
Message 8 of 10

A what is the Macro?
Message 9 of 10

Hi,

I'm a beginner in the lisp command,

I want to have an Lisp routine to load all line type in a linetype file (.lin) with a Macro
Does this command is good? If, yes, what is the Macro?

(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)


Thanks
Message 10 of 10
ad_sherratt
in reply to: m.deleurere

Kudos m.deleurere on the 'EXPERT' setting solution. Simple and effective. Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost