Author Topic: Reload Linetype in accadoc.lsp ?  (Read 3352 times)

0 Members and 1 Guest are viewing this topic.

Zykl0

  • Guest
Reload Linetype in accadoc.lsp ?
« on: July 20, 2015, 12:27:02 PM »
Hello,

I am trying to reload every linetype automaticly when I open a drawing according to the drawing measurement units.
The two first line (insunits and snapunit) work flawlessly, however the reload linetype doesn't work.

Any workaround?

Code: [Select]
(cond ((= (getvar "MEASUREMENT") 0) ;MEASUREMENT=0 (inches)
            (setvar "insunits" 1)
            (command "snapunit" "12,12")
            (command "._linetype" "_load" "*" "acad" "")
           )
           ((= (getvar "MEASUREMENT") 1) ;MEASUREMENT=1 (millimeters)
            (setvar "insunits" 4)
            (command "snapunit" "300,300")
            (command "._linetype" "_load" "*" "acadiso" "")
           )
     ) ;_ cond

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Reload Linetype in accadoc.lsp ?
« Reply #1 on: July 20, 2015, 12:34:02 PM »
You will have to loop over the line types that are already defined.
You can use the (tblnext "ltype" ...) for that.

Zykl0

  • Guest
Re: Reload Linetype in accadoc.lsp ?
« Reply #2 on: July 20, 2015, 12:39:34 PM »
Doesn't work, maybe I do it wrong?

Code: [Select]
(cond ((= (getvar "MEASUREMENT") 0) ;MEASUREMENT=0 (inches)
            (tblnext "ltype")
            (command "._linetype" "_load" "*" "acad" "")
           )
           ((= (getvar "MEASUREMENT") 1) ;MEASUREMENT=1 (millimeters)
            (tblnext "ltype")
            (command "._linetype" "_load" "*" "acadiso" "")
           )
     ) ;_ cond

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Reload Linetype in accadoc.lsp ?
« Reply #3 on: July 20, 2015, 12:44:10 PM »
Coding is more than copy+paste. Why don't you study the mentioned function first.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Reload Linetype in accadoc.lsp ?
« Reply #4 on: July 20, 2015, 12:45:12 PM »
I use this

Code - Auto/Visual Lisp: [Select]
  1. (COMMAND "EXPERT" 5 "LINETYPE" "L" "*" "ACADiso" "" )
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Zykl0

  • Guest
Re: Reload Linetype in accadoc.lsp ?
« Reply #5 on: July 20, 2015, 12:49:02 PM »
the command (command "._linetype" "_load" "*" "acadiso" "") or (COMMAND "EXPERT" 5 "LINETYPE" "L" "*" "ACADiso" "" ) work flawlessly in a macro, in another lisp or directly in the command prompt. I don't get it why it doesn't work in acadoc.lsp

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Reload Linetype in accadoc.lsp ?
« Reply #6 on: July 20, 2015, 12:54:54 PM »
the command (command "._linetype" "_load" "*" "acadiso" "") or (COMMAND "EXPERT" 5 "LINETYPE" "L" "*" "ACADiso" "" ) work flawlessly in a macro, in another lisp or directly in the command prompt. I don't get it why it doesn't work in acadoc.lsp
(command "._linetype" "_load" "*" "acadiso" "")  will only work if you're not redefining existing linetypes ... otherwise it will prompt "Linetype "SomeLineTypeName" is already loaded.  Reload it? <Y> y". Use Kerry's suggestion.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Reload Linetype in accadoc.lsp ?
« Reply #7 on: July 20, 2015, 01:04:25 PM »
Try the following in your acaddoc.lsp:

Code - Auto/Visual Lisp: [Select]
  1. (defun ltredef ( / lin val var )
  2.     (setq var '(cmdecho expert)
  3.           val  (mapcar 'getvar var)
  4.           lin  (if (zerop (getvar 'measurement)) "acad" "acadiso")
  5.     )
  6.     (mapcar 'setvar var '(0 5))
  7.     (command "_.-linetype" "_L" "*" lin "")
  8.     (mapcar 'setvar var val)
  9.     (princ)
  10. )
  11. (if (= 'list (type s::startup))
  12.     (setq s::startup (append s::startup '((ltredef))))
  13.     (defun-q s::startup nil (ltredef))
  14. )

The above is untested.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Reload Linetype in accadoc.lsp ?
« Reply #8 on: July 20, 2015, 01:09:11 PM »
<...> I don't get it why it doesn't work in acadoc.lsp

That exact (my) code is from a file that is used daily by several offices and has been for at least 10 years.

I just now added it to an acaddoc.lsp and it works without fail on several test drawings


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Reload Linetype in accadoc.lsp ?
« Reply #9 on: July 20, 2015, 01:22:05 PM »
I use this

Code - Auto/Visual Lisp: [Select]
  1. (COMMAND "EXPERT" 5 "LINETYPE" "L" "*" "ACADiso" "" )

Hate stepping on toes but if going the simplified route may I suggest:

(command "cmdecho" 0 "expert" 5 ".linetype" "_L" "*" "ACADiso" "" "expert" 0 "cmdecho" 1)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Reload Linetype in accadoc.lsp ?
« Reply #10 on: July 20, 2015, 01:36:52 PM »
Hi Michael,
No fear !

I do all my housekeeping before and after that call ... but yes, housekeeping is needed.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Reload Linetype in accadoc.lsp ?
« Reply #11 on: July 20, 2015, 01:54:02 PM »
I do all my housekeeping before and after that call ...

I've no doubt, I recognize the snip is but one line from likely hundreds or more.

Cheers!
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Reload Linetype in accadoc.lsp ?
« Reply #12 on: July 21, 2015, 03:24:35 AM »
I didn't know about the use of "EXPERT" in this context. But I have also misinterpreted the word 'reload' in the OP. So there actually are people out there who want ALL linetypes from acad(iso).lin in their drawings... :-o