Linetype w/text lisp?

Discussion in 'AutoCAD' started by Jeff S, Apr 22, 2004.

  1. Jeff S

    Jeff S Guest

    Is there a way or has someone all ready created a routine that will create a linetype with text. I am looking for something that will allow me to input at the beginning of the command the text to be used, the font to be used, and the text height to be used.
     
    Jeff S, Apr 22, 2004
    #1
  2. Jeff S

    hawkeye2 Guest

    Have you tried the Express Tool "Make Linetype"?
     
    hawkeye2, Apr 22, 2004
    #2
  3. Jeff S

    jberry50 Guest

    Here is a lisp I have been using. It allows you to specify the text to be used, but not the font or size. It just uses standard text style. It creates a temp .lin file that if you need the linetype you can copy if from there. Let me know if you come across something allowing you to use a differnt font.

    (defun c:ltxt ()
    (setvar "cmdecho" 0)
    (setq v:clayer (getvar "clayer"))
    (setq v:expert (getvar "expert"))
    (if (not v:linet)
    (setq v:linet "XX")
    ) ;if
    (setq v:linet_x (getstring (strcat "\n \n \nEnter line text: <" v:linet ">")))
    (if (/= v:linet_x "")
    (setq v:linet (strcase v:linet_x))
    ) ;if
    (setq v:linet (strcase v:linet))
    (setvar "expert" 4)
    (setq v:linet_l (strlen v:linet))
    (setq v:linet_w (rtos (* v:linet_l 0.1) 2 1))
    (setq v:lt_file "s:\\Line Types\\lt_temp.lin")
    (setq v:lt_var1 (open v:lt_file "w"))
    (setq v:lt_textl1 (strcat "*" v:linet "," v:linet "----" v:linet "----" v:linet
    "----" v:linet
    ));setq
    (setq v:lt_textl2 (strcat "A,.5,-.3,[" (chr 34) v:linet (chr 34)
    ",standard,S=.1,R=0.0,X=-0.1,Y=-.05],-" v:linet_w
    ));setq
    (setq v:lt_var2 (write-line v:lt_textl1 v:lt_var1))
    (setq v:lt_var3 (write-line v:lt_textl2 v:lt_var1))
    (close v:lt_var1)
    (command "-linetype" "l" v:linet v:lt_file "")
    (setvar "expert" v:expert)
    (command ".celtype" v:linet)
    (princ (strcat "\n \n \nCurrent Entity linetype set to:" v:linet))
    (princ)
    (setq v:pnt1 (getpoint "\nPick start point:"))
    (command "pline" v:pnt1)
    (while (setq v:pt (getpoint (getvar "lastpoint")
    "\nNext point or <Return to terminate>:"
    ));getpoint, setq
    (command v:pt)
    ) ;while
    (command)
    (command)
    (setvar "celtype" "bylayer")
    (princ)
    (princ "\n \nLine-Text terminated. Linetype set to BYLAYER:")
    (princ)
    ) ;defun
    (princ)
    (princ " Line-Text Loaded...")
    (princ (strcat "\n \n" (chr 34) "LTXT" (chr 34) " to execute:"))
    (princ)
     
    jberry50, Apr 23, 2004
    #3
  4. If you want the line to be a continuous polyline with embedded text,
    you could write a LISP program to add a NEW linetype to linetype file, then
    load that linetype.

    The program would need to -
    check if the linetype exists in the drawing
    then don't do anything
    else check if the linetype exists in the linetype file
    then set the linetype
    else get user input of values, write data to linetype file, load
    linetype, set linetype

    Linetype Example -
    *WATER,--W--W--
    A,1,-.05,["W",romans,S=0.06,X=-0.03,Y=-0.03],-0.05

    WATER = linetype name (must be unique in linetype file)
    1 = length of line
    -.05 = length of dash before text
    "W" = text in linetype
    romans = text style
    S= = text height
    X= = X offset from middle of text
    Y= = X offset from middle of text
    -0.05 = length of dash after text

    Note - for more characters in text the the X= offset will have to change.
     
    Alan Henderson, Apr 23, 2004
    #4
  5. Jeff S

    Jeff S Guest

    Thanks! I just purchased Express tools. Most of the routines in there I already have something similar but two routines I will use will be mkshape and mklinetype. That is exactly what I need. An extremely easy way to make custom linetypes.
     
    Jeff S, Apr 23, 2004
    #5
  6. Jeff S

    Jeff S Guest

    Thanks! I copied this routine but I get an error when running it. I really don't have the time to trouble shoot it either. But I did get the express tools. It works great. I already made 5 new linetypes today. A little costly for what I wanted but I like it.
     
    Jeff S, Apr 23, 2004
    #6
  7. Jeff S

    jberry50 Guest

    I don't know what type of text you were putting in the linetype. But you have to make sure to not put something that is not allowed in a linetype ie. If you were to make a linetype with 10" pipe in it you must put 10 and two apostrophes instead of a quote.
     
    jberry50, Apr 24, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.