Jump to content
dirkvandonkelaar

Annotative text style

Recommended Posts

dirkvandonkelaar

Hi guys,

 

I'm learning to use LISP functions and came across an problem.

Maybe it has been asked thousand times, but I couldn't find an relative thread here.

I want to create a function that checks if there is an text style named "Tekst 2.5".

 

Now, the problem is that i can't get the text style to be annotative

 

This is what I have:

(defun c:test (/)
   (if (null (tblsearch "style" "tekst 2.5"))
     (entmake
       (list
         '(0 . "STYLE")
         '(100 . "AcDbSymbolTableRecord")
         '(100 . "AcDbTextStyleTableRecord")
         '(2 . "Tekst 2.5")         ; Style name
         '(70 . 0)                  ; Standard flag values (bit-coded values)
         '(40 . 2.5)                ; text height
         '(41 . 1.0)                ; width factor
         '(50 . 0.0)                ; oblique angle
         '(71 . 1)                  ; text generation "0" normal text
         '(42 . 0)                  ; last height used
         '(3 . "Arial.ttf")         ; font file name
         '(4 . "")                  ; bigfont (blank for no)
       )                            ; end list
     )                              ; end entmake
   )                                ; end if
 (princ)                            
)                                    

 

Does any of you know hou to get it annotative using entmake?

Share this post


Link to post
Share on other sites
dirkvandonkelaar

Thanks Fixo,

 

You really helped me with my problem.

 

This is now my code:

(defun c:test (/)
   (if (null (tblsearch "style" "tekst 2.5"))
     (entmake
       (list
         '(0 . "STYLE")
         '(-3
           ("AcadAnnotative"
             (1000 . "AnnotativeData")
             (1002 . "{")
             (1070 . 1)
             (1070 . 1)
             (1002 . "}")
           )
          )
         '(100 . "AcDbSymbolTableRecord")
         '(100 . "AcDbTextStyleTableRecord")
         '(2 . "Tekst 2.5")     ;; Style name
         '(70 . 0)              ;; Standard flag values (bit-coded values)
         '(40 . 2.5)            ;; text height
         '(41 . 1.0)            ;; width factor
         '(50 . 0.0)            ;; oblique angle
         '(71 . 0)              ;; text generation "0" normal text
         '(42 . 0)              ;; last height used
         '(3 . "Arial.ttf")     ;; font file name
         '(4 . "")              ;; bigfont (blank for no)
       )                        ;; end list
     )                          ;; end entmake
   )                            ;; end if
 (princ)
)

Since i'm quite new to LISP, i want to know if my way of coding is the right way, so i won't learn coding the wrong way.

 

Thanks in advance

Share this post


Link to post
Share on other sites
fixo

I see nothing wrong with your code

Try to test it after entmakeing using this code snip:

 

(setvar "textstyle" "tekst 2.5")
(command "._-mtext" (getpoint "\nPick a mtext location: ") "J" "MC" "W" 0.0  "blah\\Pblah\\Pblah.." "")
(command "._objectscale" "L" "" "ADD" "100:1" "")
(command "._objectscale" "L" "" "DELETE" "1:1" "")
(command "._annoupdate" "L" "")
(command "._zoom" "O" "L" "")

Share this post


Link to post
Share on other sites
irneb

There was a discussion a while back about annotative text. I think it was on AUGI. To summarize:

 

The text height used in the DXF data list (code 40) adheres to the text hight as currently displayed. So if you set the text to be 2.0mm high but your current Anno Scale is 1:100 then the text you're creating will plot at 2.0mm high. If you later go and entget that same text you'll see its DXF code 40 would read 200.0 - as it displays the current visual height of the text.

 

This creates a problem when you're entmod'ing the text. As using that same 200.0 without changes would make the text bigger to 20000.0 high.

 

There's 3 ways of getting around this issue:

(1) omit the 40 code when using entmod so no changes happen to the text's height.

(2) Use the ActiveX methods to set the text's property instead of using entmod.

(3) Figure out which scale the text is displaying by searching though its XDictionary and comparing to CAnnoScale - if CAnno equals one of the scales listed in the XDictionary then that's the one displayed, else the 1st scale in the XDictionary is used.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...