Jump to content
dirkvandonkelaar

Variable in DXF code

Recommended Posts

dirkvandonkelaar

Hi all,

 

I have a problem with my list, according to the code below.

   (if (null (tblsearch "style" teksthoogte))
     (entmake
       (list
         '(0 . "STYLE")
  '(-3                                     ;; Make the style annotative
           ("AcadAnnotative"
             (1000 . "AnnotativeData")
             (1002 . "{")
             (1070 . 1)
             (1070 . 1)
             (1002 . "}")
           )
  )
         '(100 . "AcDbSymbolTableRecord")
         '(100 . "AcDbTextStyleTableRecord")
         '(2 . teksthoogte)                       ;; Style name
         '(70 . 0)                                ;; Standard flag values (bit-coded values)
         '(40 . 1.                              ;; 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

 

When I run this LISP, AutoCAD says:

; error: bad DXF group: (2 . TEKSTHOOGTE)

 

So, my question is: how can i get the variable "teksthoogte" working in this list?

Share this post


Link to post
Share on other sites
fuccaro

I can not test this right now, but try to use some quotation marks around the name.

Share this post


Link to post
Share on other sites
GP_

(cons 2 teksthoogte); Style nome

Edited by GP_

Share this post


Link to post
Share on other sites
dirkvandonkelaar

That's not the solution, when you wrap quotes arrount it, AutoCAD sees it as text, while it needs to be an variable which is set earlier in the LISP.

Share this post


Link to post
Share on other sites
fixo

Why not?

See if this works (possible problems is non-english letters,

if I remember that right, I have a got same problem once with

german "A" umlaut letter)

Copy paste this snip:

 

(setq teksthoogte "ANNO-Tekst 2.5")
(if (not (tblsearch "style" teksthoogte))
     (entmake
       (list
         '(0 . "STYLE")
  '(-3                                     ;; Make the style annotative
           ("AcadAnnotative"
             (1000 . "AnnotativeData")
             (1002 . "{")
             (1070 . 1)
             (1070 . 1)
             (1002 . "}")
           )
  )
         '(100 . "AcDbSymbolTableRecord")
         '(100 . "AcDbTextStyleTableRecord")
         (cons 2  teksthoogte)                       ;; Style name
         '(70 . 0)                                ;; Standard flag values (bit-coded values)
         '(40 . 1.                              ;; 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

Share this post


Link to post
Share on other sites
Lee Mac

This may help with your understanding:

 

http://www.cadtutor.net/forum/showpost.php?p=258390&postcount=20

Share this post


Link to post
Share on other sites
dirkvandonkelaar

Hi all,

 

Thanks for the replies.

Lee Mac, your thread did not really helped me understanding (maybe 'cause my English is not great).

 

BUT, i've found a solution for my problem.

This is my code now:

   (if (null (tblsearch "style" teksthoogte))
     (entmake
       (list
         '(0 . "STYLE")
  '(-3                                     ;; Make the style annotative
           ("AcadAnnotative"
             (1000 . "AnnotativeData")
             (1002 . "{")
             (1070 . 1)
             (1070 . 1)
             (1002 . "}")
           )
  )
         '(100 . "AcDbSymbolTableRecord")
         '(100 . "AcDbTextStyleTableRecord")
         '(2 . (strcat teksthoogte))              ;; Style name
         '(70 . 0)                                ;; Standard flag values (bit-coded values)
         '(40 . 1.                              ;; 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

 

The one thing i did was just replace

'(2 . teksthoogte)

with

'(2 . (strcat teksthoogte))

 

Now, i just wanted to know if it's the right wat to do this.

Share this post


Link to post
Share on other sites
Lee Mac
The one thing i did was just replace

'(2 . teksthoogte)

with

'(2 . (strcat teksthoogte))

 

The strcat expression will not be evaluated (although strcat is no actually required) since the list is quoted and hence not evaluated (as explained in my thread).

 

Instead, use:

 

(cons 2 teksthoogte)

Share this post


Link to post
Share on other sites
dirkvandonkelaar
Instead, use:
(cons 2 teksthoogte)

Haven't tried that yet, will try it monday at the office.

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...