Author Topic: (entmake) an INSERT With XDATA  (Read 2663 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
(entmake) an INSERT With XDATA
« on: March 15, 2013, 10:21:48 AM »
I don't think that I've ever tried to do this before, ( and it shows )

Code - Auto/Visual Lisp: [Select]
  1. (defun ar2_litel (x y z)
  2. (regapp "RT_RJH")
  3. (entmake (list (cons 0 "BLOCK")(cons 2 "LT_LINE")(cons 70 0)(cons 10 (list 0 0 0))))
  4. (entmake (list (cons 0 "CIRCLE")(cons 8 "0")
  5.                (cons 10 (list 0 0 -12))
  6.                (cons 39 24)
  7.                (cons 40 0.25)
  8.                (cons 210 (list 1 0 0))))
  9. (entmake (list (cons 0 "ENDBLK")))
  10. (entmake (list (cons 0 "INSERT")
  11.                (cons 8 "RT_LIGHTS")
  12.                (cons 2 "LT_LINE")
  13.                (cons 10 (list (* x 0.5) y z))
  14.                (cons 41 (/ x 24.))
  15.                (cons 42 (/ x 24.))
  16.                (cons 43 (/ x 24.))
  17.                '((-3 ("RT_RJH"
  18.                          (1070 . 200) (1000 . "L48")
  19.                          (1070 . 100) (1010 1.0 1.0 1.0)
  20.                          (1070 . 111) (1040 . 1.0)
  21.                          (1070 . 110) (1040 . 100.0)
  22.                          (1070 . 105) (1040 . 0.0)
  23.                          (1070 . 103) (1040 . 0.25)
  24.                          (1070 . 99)  (1070 . 1)
  25.                          (1070 . 101) (1011 0.0 0.0 0.0))))
  26. ))
  27. )
  28.  

It is a linear light in Accurender. 

  • x is the length of the light
  • y & z are in the insert values
  • the XDATA is static

In errors out as 'bad entmake  list'

Any insights as to what I'm doing wrong would be very helpful.  -David
R12 Dos - A2K

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: (entmake) an INSERT With XDATA
« Reply #1 on: March 15, 2013, 10:42:09 AM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun ar2_litel ( x y z )
  2.     (regapp "RT_RJH")
  3.     (entmake
  4.        '(
  5.             (0 . "BLOCK")
  6.             (2 . "LT_LINE")
  7.             (70 . 0)
  8.             (10 0.0 0.0 0.0)
  9.         )
  10.     )
  11.     (entmake
  12.        '(
  13.             (0 . "CIRCLE")
  14.             (8 . "0")
  15.             (10 0.0 0.0 -12.0)
  16.             (39 . 24.0)
  17.             (40 . 0.25)
  18.             (210 1.0 0.0 0.0)
  19.         )
  20.     )
  21.     (entmake '((0 . "ENDBLK")))
  22.     (entmake
  23.         (list
  24.            '(0 . "INSERT")
  25.            '(8 . "RT_LIGHTS")
  26.            '(2 . "LT_LINE")
  27.             (list 10 (* x 0.5) y z)
  28.             (cons 41 (/ x 24.0))
  29.             (cons 42 (/ x 24.0))
  30.             (cons 43 (/ x 24.0))
  31.            '(-3
  32.                 ("RT_RJH"
  33.                     (1070 . 200) (1000 . "L48")
  34.                     (1070 . 100) (1010 1.0 1.0 1.0)
  35.                     (1070 . 111) (1040 . 1.0)
  36.                     (1070 . 110) (1040 . 100.0)
  37.                     (1070 . 105) (1040 . 0.0)
  38.                     (1070 . 103) (1040 . 0.25)
  39.                     (1070 . 99)  (1070 . 1)
  40.                     (1070 . 101) (1011 0.0 0.0 0.0)
  41.                 )
  42.             )
  43.         )
  44.     )
  45. )

You received the error because you had an extra set of parentheses enclosing the DXF -3 Group.

I tend to quote static data since no expressions or variables need to be evaluated and so the expression can be taken at 'face-value' as a literal expression (similar to your xData list); lists can also be clearer when quoted (where possible), and there is of course a very minor performance gain since the fewer functions need to be evaluated.

Finally, note that:
Code - Auto/Visual Lisp: [Select]
  1. (cons 1 (list 2 3 4)) == (1 2 3 4) == (list 1 2 3 4)
« Last Edit: March 15, 2013, 10:48:51 AM by Lee Mac »

David Bethel

  • Swamp Rat
  • Posts: 656
Re: (entmake) an INSERT With XDATA
« Reply #2 on: March 15, 2013, 11:03:34 AM »
Thanks!  I didn't catch that.

I have a program that exports entities data in entmake format in either all '( or (cons .  So I build 1 base unit and then export and create the lsp file.  Lazy but really helpful with large numbers of entities / vertices etc

I tend to use the (cons    )  format simply for consistency and readabilty ( mine )

Thanks again!  -Daivd

PS I'll post an image with the lights on
R12 Dos - A2K

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: (entmake) an INSERT With XDATA
« Reply #3 on: March 15, 2013, 11:16:41 AM »
You're very welcome David, each to their own  :-)

David Bethel

  • Swamp Rat
  • Posts: 656
Re: (entmake) an INSERT With XDATA
« Reply #4 on: March 15, 2013, 11:18:05 AM »
The light is under the top glass.  Thanks
R12 Dos - A2K

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: (entmake) an INSERT With XDATA
« Reply #5 on: March 15, 2013, 11:30:35 AM »
Nice render David!  8-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: (entmake) an INSERT With XDATA
« Reply #6 on: March 15, 2013, 07:06:38 PM »
Ditto  :-)
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.