Author Topic: annotation text lisp  (Read 6583 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
annotation text lisp
« on: November 15, 2015, 03:27:12 AM »
Hi I am using Lee Mac code for text .I want to update this code to work with annotation text. The only commands i know to do this is

Code - Auto/Visual Lisp: [Select]
  1. (COMMAND "_layer" "_m" "_KEIM" "_c" "7" "" "")
  2. (command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
  3.  

Can any one help me to update the code

Code - Auto/Visual Lisp: [Select]
  1. (defun c:txt (/ *error* varlist oldvars pt1 tval)
  2.     (defun *error* (msg)
  3.     (mapcar 'setvar varlist oldvars)
  4.     (if (= msg "")
  5.         (princ "\nText Inserted.")
  6.         (princ "\nEsc or Error Pressed...")
  7.     ) ;_  end if
  8.     (princ)
  9.     ) ;_  end defun
  10.     (setq varlist (list "CMDECHO" "CLAYER")
  11.       oldvars (mapcar 'getvar varlist)
  12.     ) ;_  end setq
  13.     (while (and    (/= (setq pt1 (getpoint "\nSelect Insertion Point: ")) nil)
  14.         (/= (setq tval (getstring t "\nSpecify Text: ")) "")
  15.        ) ;_  end and
  16.     (if (not (tblsearch "Layer" "TEXT"))
  17.         (command "-layer" "m" "TEXT" "")
  18.     ) ;_  end if
  19.     (entmake (list '(0 . "TEXT")
  20.                '(8 . "_KEIM")
  21.                (cons 10 pt1)
  22.                (cons 40 (getvar "TEXTSIZE"))
  23.                (cons 1 tval)
  24.                '(50 . 0.0)
  25.                '(7 . "_KEIM")
  26.                '(71 . 0)
  27.                '(72 . 0)
  28.                '(73 . 0)
  29.          ) ;_  end list
  30.     ) ;_  end entmake
  31.     ) ;_  end while
  32.     (*error* "")
  33.     (princ)
  34. ) ;_  end defun
  35.  

Thanks
« Last Edit: November 15, 2015, 10:13:19 AM by Topographer »

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #1 on: November 15, 2015, 10:13:03 AM »
No one ?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: annotation text lisp
« Reply #2 on: November 15, 2015, 01:08:26 PM »
Hey, it's the weekend. We're all watching football & drinking beer.
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.

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #3 on: November 15, 2015, 01:18:36 PM »
Ok CAB  :-D

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: annotation text lisp
« Reply #4 on: November 15, 2015, 02:27:16 PM »
It is much easier with visual lisp:
Code - Auto/Visual Lisp: [Select]
  1.   (setvar 'textstyle "_KEIM")
  2.     <current space>;; ModelSpace or PaperSpace
  3.     <text>;;; your text
  4.     (vlax-3d-point <point>) ;;; insertion point
  5.     (/
  6.       (cdr (assoc 40 (tblsearch "style" "_KEIM")))
  7.       (getvar 'cannoscalevalue)
  8.     )
  9.   )

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: annotation text lisp
« Reply #5 on: November 15, 2015, 03:27:28 PM »
This topic (also started by the OP) is quite similar:
http://www.theswamp.org/index.php?topic=50075.0
« Last Edit: November 15, 2015, 03:32:48 PM by roy_043 »

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #6 on: November 16, 2015, 05:12:22 AM »
any other option ?

ChrisCarlson

  • Guest
Re: annotation text lisp
« Reply #7 on: November 16, 2015, 08:02:58 AM »
Are you just trying to make annotative text?

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #8 on: November 16, 2015, 09:27:24 AM »
Hi  ChrisCarlson
I am using the lisp in post 1 to write text in specific layer and text style. I want now to use the same lisp or same like this lisp to write an annotation text in specific text style and layer

Code - Auto/Visual Lisp: [Select]
  1. (COMMAND "_layer" "_m" "_KEIM" "_c" "7" "" "")
  2. (command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
  3.  

Thanks

ChrisCarlson

  • Guest
Re: annotation text lisp
« Reply #9 on: November 16, 2015, 09:41:11 AM »
Hi  ChrisCarlson
I am using the lisp in post 1 to write text in specific layer and text style. I want now to use the same lisp or same like this lisp to write an annotation text in specific text style and layer

Code - Auto/Visual Lisp: [Select]
  1. (COMMAND "_layer" "_m" "_KEIM" "_c" "7" "" "")
  2. (command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
  3.  

Thanks

This doesn't create text, that just simply creates a layer and text style. Just shooting off the hip..

Code - Auto/Visual Lisp: [Select]
  1.         (list
  2.                 (cons 0 "TEXT")
  3.                 (cons 8 "_KEIM") ; layer name
  4.                 (list 10 0.0 0.0 0.0) ; insertion point
  5.                 (cons 1 textstring) ; text string to pass
  6.                 (cons 50 0)
  7.                 (cons 7 "_KEIM") ; text style
  8.         )
  9. )
  10.  



pedroantonio

  • Guest
Re: annotation text lisp
« Reply #10 on: November 16, 2015, 09:46:22 AM »
I try this but is not working

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ *error* varlist oldvars pt1 tval)
  2.     (COMMAND "_layer" "_m" "_KEIM" "_c" "7" "" "")
  3. (command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
  4.      (defun *error* (msg)
  5.     (mapcar 'setvar varlist oldvars)
  6.     (if (= msg "")
  7.         (princ "\nText Inserted.")
  8.         (princ "\nEsc or Error Pressed...")
  9.     ) ;_  end if
  10.     (princ)
  11.     ) ;_  end defun
  12.     (setq varlist (list "CMDECHO" "CLAYER")
  13.       oldvars (mapcar 'getvar varlist)
  14.     ) ;_  end setq
  15.     (while (and    (/= (setq pt1 (getpoint "\nSelect Insertion Point: ")) nil)
  16.         (/= (setq tval (getstring t "\nSpecify Text: ")) "")
  17.        ) ;_  end and
  18.     (if (not (tblsearch "Layer" "_KEIM"))
  19.         (command "-layer" "m" "_KEIM" "")
  20.     ) ;_  end if
  21.     ) ;_  end while
  22.     (*error* "")
  23.     (princ)
  24. ) ;_  end defun
  25.  

ChrisCarlson

  • Guest
Re: annotation text lisp
« Reply #11 on: November 16, 2015, 09:49:17 AM »
Ok, what line does it error out on?

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #12 on: November 16, 2015, 09:50:47 AM »
I can not see any text.Create only the layer

ChrisCarlson

  • Guest
Re: annotation text lisp
« Reply #13 on: November 16, 2015, 09:52:29 AM »
So it creates the layer then breaks? Based on that I would assume something is wrong with this line. Copy and paste it into the CAD command line.

Code - Auto/Visual Lisp: [Select]
  1. (command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #14 on: November 16, 2015, 09:54:43 AM »
I use the same line in other lisp files . is correct

ChrisCarlson

  • Guest
Re: annotation text lisp
« Reply #15 on: November 16, 2015, 09:59:49 AM »
Are you sure about that?

Quote
Command: (command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
_.-style Enter name of text style or [?] <Title-Normal>: _KEIM
New style.
Specify font name or font filename (for SHX) <txt>: arial.ttf Specify height of text or [Annotative] <0'-0">: _annotative Create annotative text style [Yes/No] <Yes>: _yes Match text orientation to layout? [Yes/No] <No>: _no Specify height of text or [Annotative] <0'-0">: 2.500000000000000 Specify width factor <1.00000000>: 1.000000000000000
Specify obliquing angle <0>: 0.000000000000000 Display text backwards? [Yes/No] <No>: _no Display text upside-down? [Yes/No] <No>: _no
"_KEIM" is now the current text style.

Command: _no Unknown command "NO".  Press F1 for help.

Command: nil

Please follow this
http://www.lee-mac.com/debugvlide.html

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #16 on: November 16, 2015, 10:04:38 AM »
Yes . This is an example from another lisp i use

Code - Auto/Visual Lisp: [Select]
  1. (command "_.-style" "_diast" "wgsimpl.shx" "_annotative" "_yes" "_no" 1.75 1.0 0.0 "_no" "_no" "_no")

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: annotation text lisp
« Reply #17 on: November 16, 2015, 10:12:32 AM »
@ Topographer:
Only if the font is an .shx font is the 'Draw text vertically?' option available. So the problem that Chris has mentioned does exist.
I think you should reread the other topic and change your code accordingly.

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #18 on: November 16, 2015, 10:15:05 AM »
I have use a *.ttf again. I don't think tha the problem is there

ChrisCarlson

  • Guest
Re: annotation text lisp
« Reply #19 on: November 16, 2015, 10:16:40 AM »
It's not a fatal issue but an issue none the less. Until you step through the code in VLIDE or create checkpoints it will be hard to trouble shoot without going line by line and finding issues.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: annotation text lisp
« Reply #20 on: November 16, 2015, 10:18:44 AM »
Well, I am out.

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #21 on: November 16, 2015, 10:29:23 AM »
Any other ideas?

ChrisCarlson

  • Guest
Re: annotation text lisp
« Reply #22 on: November 16, 2015, 10:35:05 AM »
Not until you step through the code and let me know which line is breaking the routine...

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #23 on: November 16, 2015, 10:38:14 AM »
I run the code and gives me no errors.I type "test "  then Select Insertion Point and then nothing. In the layers the _KEIM layer is created the _KEIM text style is created but no text.

ChrisCarlson

  • Guest
Re: annotation text lisp
« Reply #24 on: November 16, 2015, 10:40:56 AM »
If this is the code you are running, the issue is you are not creating a text entity.

I try this but is not working

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ *error* varlist oldvars pt1 tval)
  2.     (COMMAND "_layer" "_m" "_KEIM" "_c" "7" "" "")
  3. (command "_.-style" "_KEIM" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
  4.      (defun *error* (msg)
  5.     (mapcar 'setvar varlist oldvars)
  6.     (if (= msg "")
  7.         (princ "\nText Inserted.")
  8.         (princ "\nEsc or Error Pressed...")
  9.     ) ;_  end if
  10.     (princ)
  11.     ) ;_  end defun
  12.     (setq varlist (list "CMDECHO" "CLAYER")
  13.       oldvars (mapcar 'getvar varlist)
  14.     ) ;_  end setq
  15.     (while (and    (/= (setq pt1 (getpoint "\nSelect Insertion Point: ")) nil)
  16.         (/= (setq tval (getstring t "\nSpecify Text: ")) "")
  17.        ) ;_  end and
  18.     (if (not (tblsearch "Layer" "_KEIM"))
  19.         (command "-layer" "m" "_KEIM" "")
  20.     ) ;_  end if
  21.     ) ;_  end while
  22.     (*error* "")
  23.     (princ)
  24. ) ;_  end defun
  25.  

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #25 on: November 16, 2015, 10:42:27 AM »
After test no error look

Code - Auto/Visual Lisp: [Select]
  1. visual lisp console
  2.  
  3. ; 1 form loaded from #<editor "<Untitled-0> loading...">
  4.  
  5. Build output
  6.  
  7. [CHECKING TEXT <Untitled-0> loading...]
  8. .
  9. ; Check done.
  10.  
  11.  
  12.  

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #26 on: November 16, 2015, 10:44:03 AM »
Yes this is the code

ChrisCarlson

  • Guest
Re: annotation text lisp
« Reply #27 on: November 16, 2015, 10:49:27 AM »
You need to add lines to your function in order to create the text, all you are doing is getting variables, making layers/styles and prompting for insertion / text.

pedroantonio

  • Guest
Re: annotation text lisp
« Reply #28 on: November 16, 2015, 10:51:12 AM »
i am confused .Can you add this lines please?

Thanks