To make an attribute constant, change dxf code 70 to 2.
(setq ent (entget (nentsel)))
(entmod (subst (cons 70 2) (assoc 70 ent) ent))
You can still change the contents with code.
(entmod (subst (cons 1 "test") (assoc 1 ent) ent))
Hope that helps.
If you want to insert a block with attributes, then you have to create all the items with dxf codes. If you want it easier, then you can use the ActiveX way to insert, then just edit the attributes with dxf codes after. Ron just posted a routine to create a block within a drawing, as block I mean insert.
[
http://www.theswamp.org/index.php?topic=33237.0 ]
Edit: Add the bit code for code 70 of attributes.
70
Attribute flags:
1 = Attribute is invisible (does not appear)
2 = This is a constant attribute
4 = Verification is required on input of this attribute
8 = Attribute is preset (no prompt during insertion)