Author Topic: need a lisp to create a custom linetype with text in it.  (Read 8109 times)

0 Members and 1 Guest are viewing this topic.

STEVEDALLAS

  • Guest
need a lisp to create a custom linetype with text in it.
« on: February 11, 2008, 11:44:38 AM »
I know this has probably been posted a few times on here, but here goes.

I need a lisp that can create a new, custom linetype with text in it, per whatever text I type in (such as E or EM or TV)

I have one but it screws up time after time. My lines that I create are not consistent.

Can anyone help?

ronjonp

  • Needs a day job
  • Posts: 7052
Re: need a lisp to create a custom linetype with text in it.
« Reply #1 on: February 11, 2008, 03:30:20 PM »
Here is a quickie:

Code: [Select]
(defun c:makelt (/ str file fn exprt)
  (setq str   (getstring T "\n Enter string for linetype: ")
file  (strcat (getvar 'dwgprefix)
      (vl-filename-base (getvar 'dwgname))
      "_mylt.lin"
      )
fn    (open file "w")
exprt (getvar 'expert)
  )
  (write-line (strcat "*" str ", ---" str "---") fn)
  (write-line
    (strcat "A,0.5,-0.05,[\""
    str
    "\",STANDARD,S=0.1,R=0.0,X=-0.0,Y=-.05],"
    (rtos (* -0.1 (strlen str))2 3)
    )
    fn
  )
  (close fn)
  (setvar 'expert 5)
  (command ".-linetype" "load" "*" file "")
  (setvar 'expert exprt)
  (vl-file-delete file)
  (princ)
)
« Last Edit: February 12, 2008, 04:40:06 PM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

GDF

  • Water Moccasin
  • Posts: 2000
Re: need a lisp to create a custom linetype with text in it.
« Reply #2 on: February 12, 2008, 10:21:47 AM »
Here is a quickie:


It may be a quickie, but it sure is a goodie. Thanks for sharing it. I can make use of this one.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

ronjonp

  • Needs a day job
  • Posts: 7052
Re: need a lisp to create a custom linetype with text in it.
« Reply #3 on: February 12, 2008, 10:24:22 AM »
Glad you can use it Gary :)

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: need a lisp to create a custom linetype with text in it.
« Reply #4 on: February 12, 2008, 11:33:33 AM »
Very slick there Ron. 8-)
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.

ronjonp

  • Needs a day job
  • Posts: 7052
Re: need a lisp to create a custom linetype with text in it.
« Reply #5 on: February 12, 2008, 12:20:32 PM »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

STEVEDALLAS

  • Guest
Re: need a lisp to create a custom linetype with text in it.
« Reply #6 on: February 12, 2008, 01:38:24 PM »
NICE ONE, RON.
Just what I needed.

STEVEDALLAS

  • Guest
Re: need a lisp to create a custom linetype with text in it.
« Reply #7 on: February 12, 2008, 01:49:43 PM »
basic question:
How did you come up with the numbers in the linetype definition (such as S, R, X,Y, etc.)?
The look calculated/specific.

Thanks again.

ronjonp

  • Needs a day job
  • Posts: 7052
Re: need a lisp to create a custom linetype with text in it.
« Reply #8 on: February 12, 2008, 03:39:23 PM »
basic question:
How did you come up with the numbers in the linetype definition (such as S, R, X,Y, etc.)?
The look calculated/specific.

Thanks again.

I think I pulled the numbers from a similar linetype in the acad.lin file.

I updated the code above to adjust the gap so the text is always centered regardless of the string length.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

STEVEDALLAS

  • Guest
Re: need a lisp to create a custom linetype with text in it.
« Reply #9 on: February 12, 2008, 05:26:48 PM »
Thanks Ron

ronjonp

  • Needs a day job
  • Posts: 7052
Re: need a lisp to create a custom linetype with text in it.
« Reply #10 on: February 12, 2008, 05:29:06 PM »
You're welcome.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

STEVEDALLAS

  • Guest
Re: need a lisp to create a custom linetype with text in it.
« Reply #11 on: February 13, 2008, 10:57:35 AM »
Ron:
I reduced the text size on what you posted.
My original intent was to simply reduce the text scale in the linetype from 0.1 to 0.05
My efforts completely threw the centering off.

I can not seem to get it corrected.

Can you advise?


Thanks again.
« Last Edit: February 13, 2008, 11:26:33 AM by STEVEDALLAS »

ronjonp

  • Needs a day job
  • Posts: 7052
Re: need a lisp to create a custom linetype with text in it.
« Reply #12 on: February 13, 2008, 11:25:39 AM »
Try this:

  (write-line
    (strcat "A,0.5,-0.05,[\""
       str
       "\",STANDARD,S=0.05,R=0.0,X=-0.0,Y=-.025],"
       (rtos (* -0.05 (strlen str))2 3)
    )
    fn
  )
« Last Edit: February 13, 2008, 11:31:59 AM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

STEVEDALLAS

  • Guest
Re: need a lisp to create a custom linetype with text in it.
« Reply #13 on: February 13, 2008, 11:39:09 AM »
GOT IT THANKS.

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: need a lisp to create a custom linetype with text in it.
« Reply #14 on: March 03, 2008, 09:49:55 AM »
what if you change the text style, i switched it to the one my company uses and it screws up the centering of the text

LT-E (arial narrow with italics)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox