Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

linetype load in autolisp

3 views
Skip to first unread message

David Millar

unread,
Jul 20, 1998, 3:00:00 AM7/20/98
to
I have a program that requires that linetype 'hidden2' be loaded, and if
the linetype isn't already loaded, it crashes.

I am looking for a way to load linetypes (perhaps from acad.lin). The
-linetype command brings up a dialogue box, and I wonder if anyone out
there has found a way to load linetypes transparantly in autolisp.

Thanks in advance for reading this.

Dave


Jon Fleming

unread,
Jul 20, 1998, 3:00:00 AM7/20/98
to


If you are using R14, the:

linetype

command is supposed to bring up a dialog box, and the:

-linetype

command is suppose to run without a dialog box. Are you saying that
typing "-linetype" at the "Command:" prompt brings up a dialog box for
you?

jrf


David Millar

unread,
Jul 20, 1998, 3:00:00 AM7/20/98
to
Yes

Dave

Ken Krupa

unread,
Jul 20, 1998, 3:00:00 AM7/20/98
to
(defun my_linetype_load (ltype)
(if (null (tblsearch "ltype" ltype))(progn
(command "_linetype" "_L" ltype "" "")
(if (null (tblsearch "ltype" ltype))(progn
(princ (strcat "\nCould not load linetype " ltype " - using
CONTINUOUS "))
(setq ltype "CONTINUOUS")
))
))
ltype
)
When called from lisp, the linetype command does not display a dialog. This
function loads the linetype if not already loaded, then returns the
linetype name ("CONTINUOUS" if the desired linetype could not be loaded).

Regards,

Ken Krupa


David Millar <d...@ica.net> wrote in article <35B3026B...@ica.net>...

David Millar

unread,
Jul 20, 1998, 3:00:00 AM7/20/98
to
Thanks Ken:

I know about tblsearch; however, the linetype that I want to load is not in the
table. We know that it exists in 'acad.lin'. Can we load linetype 'hidden2'
from 'acad.lin' in autolisp, if the linetype is not in the table?

Thanks

Dave

Ken Krupa

unread,
Jul 21, 1998, 3:00:00 AM7/21/98
to
Dave,

That's just what this function does. It uses tblsearch to determine if the
desired linetype is already in the drawing, because if it is you don't want
to keep reloading it. If it's not already in the drawing, then it uses the
linetype command to load it, from the default location of "acad.lin". The
second call of tblsearch is just to confirm that the linetype was indeed
successfully loaded (or give an error message if not). As long as you have
this function defined, your routine would then simply call
(my_linetype_load "hidden2").

Hope that helps.

Ken Krupa

David Millar <d...@ica.net> wrote in article <35B3FDE2...@ica.net>...

Steve Johnson

unread,
Jul 21, 1998, 3:00:00 AM7/21/98
to
Dave - Did you try or even read Ken's code? Looks to me like it does what you
want.

Steve Johnson
cad nauseam - http://ourworld.compuserve.com/homepages/SteveJohnson/
CADLock - http://www.cadlock.com/

David Millar

unread,
Jul 21, 1998, 3:00:00 AM7/21/98
to
thanks to all.

Re-read, I must do. p.s. since I've started using Vital Lisp, my learning curve has
been assisted greatly.

Dave

Michael Mann

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
Here's an example of what I have used in our company....
This code was compiled into an ARX and used in my acad.lsp file upon
startup...
In this particular case, I needed to load these linetypes from an AEC
linetype file...


;;; A_LTYPE

(defun c:ldlines ()
(prompt "\nLoading custom linetypes...")
(ltype:ld_type)
(princ)
) ;_ end of defun

(vl-acad-defun 'ltype:ld_type)
(defun ltype:ld_type (/ lts-sdsk)
(setvar "filedia" 0)
(setq
lts-sdsk
(list
"centerf" "centerf2" "boundary" "contour"
"phantom2" "invisible" "hidden" "hidden2"
"center2" "dashed2" "dashed"
) ;_ end of list
;_ end of list
) ;_ end of setq
(foreach n lts-sdsk
(if (tblsearch "LTYPE" n)
nil
(if (findfile "sdsk.lin")
(command "_.linetype" "_l" n "sdsk.lin" "")
) ;_ end of if
) ;_ end of if
) ;_ end of foreach
(setvar "filedia" 1)
(princ)
) ;_ end of defun

;;initialization
(c:ldlines)


David Millar wrote in message <35B3026B...@ica.net>...

Jon Fleming

unread,
Aug 6, 1998, 3:00:00 AM8/6/98
to
(defun ...) accepts a function name, argument / local variable list, and a set
of LISP function calls and creates a function by that name. In Visual LISP,
(vl-acad-defun ...) accepts a symbol name (which should be the name of a
function), creates the same symbol name in native AutoLISP, and links the
native AutoLISP symbol to the function in Visual LISP.

In other words, (defun ...) defines the function in and (vl-acad-defun ...)
makes it available in both environments.

Of course, (defun ...) is explained in both the AutoCAD and Visual LISP
documentation, and (vl-acad-defun ...) is explained in the Visual LISP
documentation.

jrf

In article <35c88316....@adesknews.autodesk.com>, Dave Lewis wrote:
> Why the vl-acad-defun and the regular defun?
> What's the difference?

0 new messages