Author Topic: make text entity by entmake  (Read 3750 times)

0 Members and 1 Guest are viewing this topic.

Robert98

  • Guest
make text entity by entmake
« on: November 21, 2010, 02:41:44 PM »
Hi dears
I want put many string like EX list in certain positions like ID list  , but when I run below codes I receive this error :

error: bad DXF group: (4663.01 5300.52 0.0)

please tell me that , what is my mistake at this routine ?  :|

Thanks

Code: [Select]

(setq EX  ("130.21" "Tree" "136.08" "House" "139.00"))
(setq ID  ((4663.01 5300.52 0.0) (4684.67 5274.09 0.0) (4701.29 5305.34 0.0) (4760.2 5324.73 0.0) (4775.05 5302.79 0.0)))
 
 
(foreach elem EX
  (setq pos (vl-position elem EX)
inspoint (nth pos id)
tx (nth pos EX)
  )
  (entmake
    (list
      '(0 . "text")
      '(100 . "AcDbEntity")
      '(67 . 0)
      '(410 . "Model")
      '(8 . "Notes")
      '(62 . 256)
      '(100 . "AcDbText")
      '(50 . 0.0)
      '(41 . 1.0)
      '(51 . 0.0)
      '(7 . "standard")
      '(71 . 0)
      '(72 . 1)
      '(73 . 2)
       (cdr(cons 10 inspoint))
       (cons 40 2.0)
       (cons 1 tx)
       (cons 210 (list 0.0 0.0 1.0))
    );list
  );entmak
) ;foreach


gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: make text entity by entmake
« Reply #1 on: November 21, 2010, 02:57:55 PM »
Hi,

You can use mapcar if you're dealing with more than one corresponding lists.
(cdr(cons 10 inspoint)) have to be : (cons 10 inspoint)
And while a 72 or 73 group is different from 0 you have to specify the alignment point (11 group)

Code: [Select]
(mapcar '(lambda (str ins)
   (entmake
     (list
       '(0 . "text")
       '(100 . "AcDbEntity")
       '(67 . 0)
       '(410 . "Model")
       '(8 . "Notes")
       '(62 . 256)
       '(100 . "AcDbText")
       '(50 . 0.0)
       '(41 . 1.0)
       '(51 . 0.0)
       '(7 . "standard")
       '(71 . 0)
       '(72 . 1)
       '(73 . 2)
       (cons 10 ins)
       (cons 11 ins)
       '(40 . 2.0)
       (cons 1 str)
       '(210 0.0 0.0 1.0)
     )
   )
)
ex
id
)
Speaking English as a French Frog

Robert98

  • Guest
Re: make text entity by entmake
« Reply #2 on: November 21, 2010, 03:42:55 PM »
Hi,

You can use mapcar if you're dealing with more than one corresponding lists.
(cdr(cons 10 inspoint)) have to be : (cons 10 inspoint)
And while a 72 or 73 group is different from 0 you have to specify the alignment point (11 group)

Code: [Select]
(mapcar '(lambda (str ins)
   (entmake
     (list
       '(0 . "text")
       '(100 . "AcDbEntity")
       '(67 . 0)
       '(410 . "Model")
       '(8 . "Notes")
       '(62 . 256)
       '(100 . "AcDbText")
       '(50 . 0.0)
       '(41 . 1.0)
       '(51 . 0.0)
       '(7 . "standard")
       '(71 . 0)
       '(72 . 1)
       '(73 . 2)
       (cons 10 ins)
       (cons 11 ins)
       '(40 . 2.0)
       (cons 1 str)
       '(210 0.0 0.0 1.0)
     )
   )
)
ex
id
)
Hi gile
thanks for your reply
I used your mapcar function , but I received this error :

error: bad DXF group: (10 . 4663.01)

why ! ? :-(

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: make text entity by entmake
« Reply #3 on: November 21, 2010, 04:04:12 PM »
I see your lists EX and ID aren't quoted.
Try like this:

Code: [Select]
(setq EX  '("130.21" "Tree" "136.08" "House" "139.00"))
(setq ID  '((4663.01 5300.52 0.0) (4684.67 5274.09 0.0) (4701.29 5305.34 0.0) (4760.2 5324.73 0.0) (4775.05 5302.79 0.0)))
Speaking English as a French Frog

Robert98

  • Guest
Re: make text entity by entmake
« Reply #4 on: November 21, 2010, 04:07:56 PM »
I see your lists EX and ID aren't quoted.
Try like this:

Code: [Select]
(setq EX  '("130.21" "Tree" "136.08" "House" "139.00"))
(setq ID  '((4663.01 5300.52 0.0) (4684.67 5274.09 0.0) (4701.29 5305.34 0.0) (4760.2 5324.73 0.0) (4775.05 5302.79 0.0)))
wow ... thanks gile
it works correctly , you're genius ...  :lol:
thanks

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: make text entity by entmake
« Reply #5 on: November 21, 2010, 08:29:05 PM »
Robert,

You could probably shorten the entmake statement to just:

Code: [Select]
(mapcar
  '(lambda ( str ins )
     (entmake
       (list
         (cons 0 "TEXT")
         (cons 8 "Notes")
         (cons 72 1)
         (cons 73 2)
         (cons 10 ins)
         (cons 11 ins)
         (cons 40 2.0)
         (cons 1 str)
       )
     )
   )
  ex
  id
)

As the other DXF group codes are optional and you were using their default values.

(And yeah, might be just me being OCD'ish, but I don't like mixing the 'cons' with with quoted dotted pairs, I always think it looks 'cleaner' going with one or the other... yeah, ignore me  :ugly:)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: make text entity by entmake
« Reply #6 on: November 22, 2010, 05:10:57 AM »
As the other DXF group codes are optional and you were using their default values.
Entmake doesn't use default values for missing group codes, it uses current values. For instance, if you leave out group code 62, the colo(u)r of the entity will be the current cecolor (which may not be ByLayer). The same goes for text style etc. So it can be a good idea to supply more group codes than the bare minimum.

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: make text entity by entmake
« Reply #7 on: November 22, 2010, 10:40:21 AM »
As the other DXF group codes are optional and you were using their default values.
Entmake doesn't use default values for missing group codes, it uses current values. For instance, if you leave out group code 62, the colo(u)r of the entity will be the current cecolor (which may not be ByLayer). The same goes for text style etc. So it can be a good idea to supply more group codes than the bare minimum.

Ah - thanks for the clarification Roy, I may have overlooked that in the past.  :oops:

Robert98

  • Guest
Re: make text entity by entmake
« Reply #8 on: November 22, 2010, 03:10:42 PM »
Hi all
special thanks Lee , Roy and gile
now , I think about mtext instead line text and there are many selections  :
If I want make mtext , so which one is better and easier for practice ?

1- use one of the above routines ( gile and Lee's routines) and replace mtext with text and change corresponding DXF group's codes
2- use vla-AddMtext instead entmake
I want make by use of 2 or 3 list a two line mtext and put them at specific points:
'(A1 B1 C1 D1);TXT1
'(200 300 400 500);TXT2
'((10 10 0) (20 10 0) (30 10 0 ) (40 10 0));INSERTION POINTS
I'm trying to start and Please if anyone has proposed , to express
thanks

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: make text entity by entmake
« Reply #9 on: November 22, 2010, 03:12:42 PM »
This old thread may help Robert:

http://www.theswamp.org/index.php?topic=32148.0

Robert98

  • Guest
Re: make text entity by entmake
« Reply #10 on: November 22, 2010, 03:49:39 PM »
This old thread may help Robert:

http://www.theswamp.org/index.php?topic=32148.0

Hi dear Lee
Thanks for your quick response Lee , your link is very informative for me and a few days doing my own will , I'll rummage it one line by one  ...! and you'll write tomorrow .

Special Thanks

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: make text entity by entmake
« Reply #11 on: November 22, 2010, 03:55:59 PM »
This old thread may help Robert:

http://www.theswamp.org/index.php?topic=32148.0

Hi dear Lee
Thanks for your quick response Lee , your link is very informative for me and a few days doing my own will , I'll rummage it one line by one  ...! and you'll write tomorrow .

Special Thanks

Thanks, I'm sure there is a lot I could add to it, but hopefully it will be of some assistance to you.