Author Topic: pass BYLAYER to entmake  (Read 2218 times)

0 Members and 1 Guest are viewing this topic.

curmudgeon

  • Newt
  • Posts: 194
pass BYLAYER to entmake
« on: August 20, 2009, 10:50:50 AM »
I am going to the block table to get the definitions for each entity in a block, and then I want to entmake each entity.
I am recreating the explode command so I can pass extended data from a block to some "undisclosed location".

first test, there are entities with linetype BYBLOCK, and some entities with a forced colour. I tried this:

Code: [Select]
(entmake (list '(0 . "LINE")
  '(100 . "AcDbEntity")
  (assoc 8 data)
  (if (assoc 62 data) (assoc 62 data))
  (assoc 6 data)
  '(100 . "AcDbLine")
  (cons 10 (tran 10))
  (cons 11 (tran 11))
  )
    )

so that if the colour is forced, it will recreate it correctly. but when it is bylayer in the block definition there is no (assoc 62 data), and it returns a nil in the middle of my list - which entmake really does not like so very much. obviously, the (assoc 6 data) will have the same problem.

...................... sometimes stating the problem is all I need. now I have:

Code: [Select]
(entmake (append (list '(0 . "LINE")
  '(100 . "AcDbEntity")
  (assoc 8 data))
  (if (assoc 62 data) (list(assoc 62 data)))
  (if (assoc 6 data) (list(assoc 6 data)))
  (list '(100 . "AcDbLine")
  (cons 10 (tran 10))
  (cons 11 (tran 11))
  ))
    )

because the append wipes the nils in my list.
but I would still like to know how to pass BYLAYER to entmake.

thanks.
Never express yourself more clearly than you are able to think.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: pass BYLAYER to entmake
« Reply #1 on: August 20, 2009, 11:35:10 AM »
Hi,

Try :
(cond ((assoc 62 data)) (T '(62 . 256)))
and
(cond ((assoc 6 data)) (T '(6 . "BYLAYER")))
Speaking English as a French Frog

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: pass BYLAYER to entmake
« Reply #2 on: August 20, 2009, 11:43:47 AM »
Like Gile said.
Code: [Select]
(entmake (append (list '(0 . "LINE")
 '(100 . "AcDbEntity")
 (assoc 8 data))
 (if (assoc 62 data) (assoc 62 data) '(62 . 256))
 (if (assoc 6 data) (assoc 6 data) '(6 . "BYLAYER"))
 (list '(100 . "AcDbLine")
 (cons 10 (tran 10))
 (cons 11 (tran 11))
 ))
   )
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.

curmudgeon

  • Newt
  • Posts: 194
Re: pass BYLAYER to entmake
« Reply #3 on: August 20, 2009, 12:47:16 PM »
Hi,

Try :
(cond ((assoc 62 data)) (T '(62 . 256)))
and
(cond ((assoc 6 data)) (T '(6 . "BYLAYER")))

just almost....
this works. even better, I can see why it works now.
apologies, Charles. I did not read the code you posted before I started playing with it.
here, an IF is just as good as a COND, and probably reads easier.

Code: [Select]
(entmake  (list '(0 . "LINE")
  '(100 . "AcDbEntity")
  (assoc 8 data)
  (cond ((assoc 62 data)(assoc 62 data))
(T '(62 . 256)))
  (cond ((assoc 6 data)(assoc 6 data))
(T '(6 . "BYLAYER")))
  '(100 . "AcDbLine")
  (cons 10 (tran 10))
  (cons 11 (tran 11))
 
    )
   
  )

very many thanks.
« Last Edit: August 20, 2009, 12:52:00 PM by curmudgeon »
Never express yourself more clearly than you are able to think.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: pass BYLAYER to entmake
« Reply #4 on: August 20, 2009, 01:16:14 PM »
Hi,

Try :
(cond ((assoc 62 data)) (T '(62 . 256)))
and
(cond ((assoc 6 data)) (T '(6 . "BYLAYER")))

Good code!
My cent: minus one letter...

Code: [Select]
(cond((assoc 62 data))('(62 . 256)))
(cond((assoc 6 data))('(6 . "BYLAYER")))

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: pass BYLAYER to entmake
« Reply #5 on: August 20, 2009, 01:23:00 PM »
Or:
Code: [Select]
(cond((assoc 62 data)) ((cons 62 256)))
(cond((assoc 6 data)) ((cons 6 "BYLAYER")))
Speaking English as a French Frog