Author Topic: Loading a custom linetype with lsp  (Read 2302 times)

0 Members and 1 Guest are viewing this topic.

drumbald

  • Guest
Loading a custom linetype with lsp
« 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)
)

Jeff_M

  • King Gator
  • Posts: 3944
  • C3D user & customizer
Re: Loading a custom linetype with lsp
« Reply #1 on: December 29, 2005, 02:18:04 PM »
Try something like this that specifies the file to load from:
Code: [Select]
(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) "")
    )
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10365
Re: Loading a custom linetype with lsp
« Reply #2 on: December 29, 2005, 04:30:40 PM »
Jeff
I like that method. Here is taking it one step further.
Code: [Select]
(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)
)
« Last Edit: December 29, 2005, 06:02:43 PM by CAB »
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Jeff_M

  • King Gator
  • Posts: 3944
  • C3D user & customizer
Re: Loading a custom linetype with lsp
« Reply #3 on: December 29, 2005, 05:52:47 PM »
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?
Quote
(prompt (strcat "\nCan not fine file " fname))
:-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10365
Re: Loading a custom linetype with lsp
« Reply #4 on: December 29, 2005, 06:05:13 PM »
spelling error, again :-o
I think its a typo, e key next to d key and no proof reader. :-)
Thanks for the catch.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Loading a custom linetype with lsp
« Reply #5 on: December 29, 2005, 08:51:41 PM »
Just came across this quote, and thought of you .. well me too actually ..
Quote
My spelling is wobbly. It's good spelling but it wobbles and the letters get in the wrong places.
...  Winnie the Pooh 
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

CAB

  • Global Moderator
  • Seagull
  • Posts: 10365
Re: Loading a custom linetype with lsp
« Reply #6 on: December 29, 2005, 10:38:34 PM »
 :-) :-) :-)
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 1992
Re: Loading a custom linetype with lsp
« Reply #7 on: December 30, 2005, 09:35:03 AM »
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
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64