Define and insert blocks with attributes , using DXF codes and AutoLisp

Define and insert blocks with attributes , using DXF codes and AutoLisp

Anonymous
Not applicable
8,580 Views
60 Replies
Message 1 of 61

Define and insert blocks with attributes , using DXF codes and AutoLisp

Anonymous
Not applicable

Hello everyone !

 

I am trying to define a block with attributes with LockPosition = On , using DXF codes (280 . 1)  and AutoLisp (lisp c: TestPP attached below ) . For Visual Lisp , property LockPosition = Read Only , so can't be changed !

 

The problem is , this (280 . 1)  is having effect only if I introducing codes 100 in blue . But then , I have a problem with TextStyle (7 . "ArialT")  .

 

(defun c:TestPP ()
 (prinC "\n  TestPP  :  V  :  1 . 04 . 2019  ;")
 (setVar "TextStyle" "Standard")
 (vl-CmdF "_.Purge" "_A" "" "_N")

 (if (tblSearch "Block" "PxT")
  (princ "\n  Block  Existed !")
  (progn ; Define Block
   (command "_.Layer" "_N" "Name L" "_C" 1 "Name L" "")

;;;   (if (tblSearch "Style" "ArialT") T (vl-CmdF "_.Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ;
;;;   (if (not (tblobjname "Style" "ArialT")) (vl-CmdF "_.Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ;
;;;   (if (not (tblobjname "Style" "ArialT")) (vl-CmdF "-Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ;
   (if (not (tblSearch "Style" "ArialT")) (vl-CmdF "-Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ;


;;;   (cond ( (null (tblSearch "STYLE" "ELEV_ARIAL_1"))
;;;          (setq nw_style (vla-Add (vla-get-textStyles (vla-get-ActiveDocument (vlax-get-acad-Object))) "ArialT")
;;;                nw_font (strcat (getEnv "systemroot") "\\Fonts\\Arial.ttf")
;;;          ) ;end_setq
;;;          (mapcar '(lambda (pr val) (vlax-put-Property nw_style pr val))
;;;            (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
;;;            (list nw_font 0.0 (/ (* 0.0 pi) 180) 1.0 0.0)
;;;          ) ;end_mapcar
;;;        )
;;;   ) ;end_cond
  
   (entMake '((0 . "BLOCK") (2 . "PxT") (70 . 2) (8 . "0") (10 0 0 0) (6 . "ByLayer") (62 . 256) (4 . "Made by Me"))  ) ; end of e
   (entMake (list '(0 . "Circle") '(8 . "0") '(62 . 256) '(6 . "ByLayer") '(10 0 0 0) (cons 40 0.25) ) ) ; end of e

   (entMake (list '(0 . "AttDef") '(100 . "AcDbEntity") (cons 8 "Name L") '(62 . 256) '(6 . "ByLayer") ;'(67 . 0)
                  '(100 . "AcDbText") '(10 0 0 0) '(40 . 1.5) '(1 . "N") '(50 . 0) '(41 . 1) '(51 . 0) '(7 . "ArialT") '(71 . 0) '(72 . 0)
                            '(11 0.5 +1.0 0) '(210 0.0 0.0 1.0)
                  '(100 . "AcDbAttributeDefinition") '(280 . 0) '(3 . "Point Name") '(2 . "NAME") '(70 . 0) '(73 . 0) '(74 . 2) '(280 . 1) ) ) ; end of e  ;'(100 . "AcDbXrecord") 

   (entMake '((0 . "EndBlk") (8 . "0")) ) ; end of e
   (prinC "\n   Block  with  Attributes  DEFINED  :  PxT  ;") ; end of p
  ) ; else
 ) ; if

 (setq ;q (getString "\n   Attribute  Insertion  with  Codes  100  :  Any = NO  ;   <  Enter = YES  >  :  ")
       i 0)

 (repeat 10 ; Inserting 10 Blocks with Attribute
  (entMake (list '(0 . "Insert") '(2 . "PxT") '(8 . "0") '(66 . 1) (cons 10 (trans (list i i i) 1 0)) '(50 . 0) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0)) ) ; inserare Bloc

  (if (= (rem i 2) 0) ;(= q "")
  (entMake (list '(0 . "ATTRIB") '(100 . "AcDbEntity") '(8 . "Name L") '(67 . 0) ;'(6 . "ByLayer") ;'(62 . 256) '(67 . 0) ;0 = MSpace ;
                 '(100 . "AcDbText") (list 10 i i i) '(40 . 1) (cons 1 (ItoA i)) '(50 . 0) '(41 . 1.0) '(51 . 0.0)  '(7 . "ArialT")
                        '(71 . 0) '(72 . 0) (cons 11 (trans (list i i i) 1 0)) ;'(210 0.0 0.0 1.0)
                 '(100 . "AcDbAttribute") '(280 . 0) '(2 . "NAME") '(70 . 0) '(73 . 0) (cons 74 2) '(280 . 1) )  ) ; set Attribute


  (entMake (list '(0 . "ATTRIB") (list 10 i i i)  '(8 . "Name L") (cons 1 (ItoA i)) '(280 . 0) '(2 . "NAME") '(40 . 1) '(70 . 0)
             (cons 11 (trans (list i i i) 1 0)) (cons 72 0) (cons 74 2) '(6 . "ByLayer") '(7 . "ArialT") '(50 . 0) '(62 . 5) '(280 . 1) )  ) ; e
  ) ; if
  (entMake '((0 . "SeqEnd") (8 . "0")) ) ; End Insert Block !

  (setq i (1+ i))  
 ) ; r

 (setVar "TextStyle" "Standard") (command "zoom" "e")
 (prinC (strCat "\n   Inserted  :  " (ItoA i) "  ;"))
 (prinC "\n   TestPP  :  END  ;") (prinC)
) ; defun c:TestPP

I create a condition which is alternating the insertion of the attributes .

Open a new dwg , load and run the lisp . The only difference will be too many grips for blue and odd numbers , because (280 . 1) is not having any effect .

Delete all and run the lisp again . Only the blue and odd attributes are visible . 

 

For a manual insertion , TextStyle for attribute is Standard . 

So , at the same time , the same block can have different appearances / properties as : color , height , layer rotation , etc .

 

If I keep the TextStyle ArialT preserved in the drawing , as current Text Style or used somewhere else , are NO problems . 

 

Any idea ? 

 

Thanks in advance .

 

 

0 Likes
Accepted solutions (1)
8,581 Views
60 Replies
Replies (60)
Message 21 of 61

Anonymous
Not applicable
A priori in your code is the assignment of ArialT style when there is parity of the number that does not do well.

Which numbers ? Can you be more explicite ?

 

 

Yes CADaStroumph ,

 

in my opinion , the Text Style is not assigned to the Attributes , because .... ?

Something is going wrong . But what ?

 

And , why is working on the first time ? 

 

Why is not making any problem in the below code ? Is the same TextStyle = "AriaT" for both cases .

(entMake (list '(0 . "ATTRIB") (list 10 i i i)  '(8 . "Name L") (cons 1 (ItoA i)) '(280 . 0) '(2 . "NAME") '(40 . 1) '(70 . 0)
             (cons 11 (trans (list i i i) 1 0)) (cons 72 0) (cons 74 2) '(6 . "ByLayer") '(7 . "ArialT") '(50 . 0) '(62 . 5) '(280 . 1) )  )

So , that means (7 . "ArialT") should be in a different place or surrounded by a something special DXF code .

 

See the attached pdf file .

0 Likes
Message 22 of 61

Anonymous
Not applicable

Hello ,

 

I have attached 2 pictures from Block Editor  with Attribute properties :

 

First one , is BA 21.jpg , for the first run of lisp , where everything is fine .

The attribute is visible and the TextStyle = ArialT , as should be ;

 

The second picture , BA 22.jpg , it is for the second run of lisp , when the attributes have a problem . How can be seen , even in the definition of the Attribute , the TextStyle have a problem , is not appearing in the Properties pallet .

 

So , in the second time , the definition of Attribute from Block pxT , it is wrong .

Seams to appear a conflict between the TextStyle AriaT and Attribute definition .

 

AutoCAD DXF 2012 , pag 2 :

Object and Entity Codes
In the DXF™ format, the definition of objects differs from entities: objects
have no graphical representation and entities do. For example, dictionaries
are objects, and not entities. Entities are also referred to as graphical objects
while objects are referred to as nongraphical objects.
Entities appear in both the BLOCK and ENTITIES sections of the DXF file. The
use of group codes in the two sections is identical.
Some group codes that define an entity always appear; others are optional
and appear only if their values differ from the defaults.
Do not write programs that rely on the order given here. The end of an entity
is indicated by the next 0 group, which begins the next entity or indicates the
end of the section.
NOTE Accommodating DXF files from future releases of AutoCAD® will be easier
if you write your DXF processing program in a table-driven way, ignore undefined
group codes, and make no assumptions about the order of group codes in an
entity. With each new AutoCAD release, new group codes will be added to entities
to accommodate additional features.
2 |
0 Likes
Message 23 of 61

Anonymous
Not applicable

 

AutoCAD 2014 DXF . pdf

 

100 =

Subclass data marker (with derived class name as a string). Required for all objects and entity classes that are derived from another concrete class. The subclass data marker segregates data defined by different classes in the inheritance chain for the same object.
This is in addition to the requirement for DXF names for each distinct concrete class derived from ObjectARX (see Subclass Markers)
0 Likes
Message 24 of 61

Moshe-A
Mentor
Mentor

i'm sorry but i think some how i lost connection here, can you summarize all the details you have up till now.

you did not mention what is you goal?

you start with PxT block with 1 locked attribute than moved to PuncT block with 6 locked attributes.

this block serves what? what these numbers represent? you want to insert the block more than thousand times in 1 drawings? and the attributes positions would be locked any place around the insertion point? 

the user is not allowed to move attributes? but still have permission to change the value?

 i do not think text style name (ArialT) is a issue here (but the font is)

 

???

 

0 Likes
Message 25 of 61

Anonymous
Not applicable

The post is about a block with 1 Attribute , TextStyle =ArialT. 

 

Somebody else understood to align the attributes around the point . That is not an issue for me . I can do that already. 

 

Again,  the test program is TestPP and the visibility of his Attribute in the second run of the lisp, is the issue .

 

The font is Arial.ttf .

 

0 Likes
Message 26 of 61

Moshe-A
Mentor
Mentor

you mean the second time i run the lisp the issue is that the attribute is not seen?

0 Likes
Message 27 of 61

Anonymous
Not applicable

Yes, that it !

0 Likes
Message 28 of 61

Moshe-A
Mentor
Mentor
Accepted solution

i ran the lisp on "BA 2.DWG" (with PxT block)  5 times (one after another) and it insert the block 50 time with not issue (or i still do not understand what is the issue here???)

 

 

0 Likes
Message 29 of 61

Anonymous
Not applicable

Open a new dwg  . Load and run the lisp TestPP. Delete evening and run again. 

 

Then , the red attributes are not visible. 

 

This is the problem.

0 Likes
Message 30 of 61

Moshe-A
Mentor
Mentor

i sorry but i my test they all visible!!!

 

0 Likes
Message 31 of 61

Anonymous
Not applicable

Maybe you solved the problem .

 

How ?

0 Likes
Message 32 of 61

Moshe-A
Mentor
Mentor

add this code at the top of your command, this ensure ArialT text style is defined always.

 

 (if (null (tblSearch "Style" "ArialT"))
  (vl-cmdf "Style" "ArialT" "arial" 0 1 0 "_N" "_N")
  (setvar "TextStyle" "ArialT")
 )
0 Likes
Message 33 of 61

Anonymous
Not applicable

sorry , is not working .

 

(defun c:TestPP ()
 (prinC "\n  TestPP  :  V  :  1 . 04 . 2019  ;")
 (setVar "TextStyle" "Standard")
 (vl-CmdF "_.Purge" "_A" "" "_N")

 (if (tblSearch "Block" "PxT")
  (princ "\n  Block  Existed !")
  (progn ; Define Block
   (command "_.Layer" "_N" "Name L" "_C" 1 "Name L" "")

;;;   (if (tblSearch "Style" "ArialT") T (vl-CmdF "_.Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ;
;;;   (if (not (tblobjname "Style" "ArialT")) (vl-CmdF "_.Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ;
;;;   (if (not (tblobjname "Style" "ArialT")) (vl-CmdF "-Style" "ArialT" "Arial.ttf" 0 1 0 "_N" "_N") ) ;
;;;   (if (not (tblSearch "Style" "ArialT")) (vl-CmdF "-Style" "ArialT" "arial.ttf" 0 1 0 "_N" "_N") ) ;
;;;(if (not (tblSearch "Style" "ArialTopo")) (entMake (list '(0 . "STYLE") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbTextStyleTableRecord") '(2 . "ArialTopo") '(70 . 0) '(40 . 1.0) '(41 . 1.0) '(50 . 0.0) '(71 . 0) '(3 . "arial.ttf") '(4 . ""))) )
;;;(if (not (tblSearch "Style" "ArialT")) (entMake (list '(0 . "STYLE") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbTextStyleTableRecord") '(2 . "ArialT") '(70 . 0) '(40 . 1.0) '(41 . 1.0) '(50 . 0.0) '(71 . 0) '(3 . "arial.ttf") '(4 . ""))) )
;;;   (cond ( (null (tblSearch "STYLE" "ELEV_ARIAL_1"))
;;;          (setq nw_style (vla-Add (vla-get-textStyles (vla-get-ActiveDocument (vlax-get-acad-Object))) "ArialT")
;;;                nw_font (strcat (getEnv "SystemRoot") "\\Fonts\\Arial.ttf")
;;;          ) ;end_setq
;;;          (mapcar '(lambda (pr val) (vlax-put-Property nw_style pr val))
;;;            (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
;;;            (list nw_font 0.0 (/ (* 0.0 pi) 180) 1.0 0.0)
;;;          ) ;end_mapcar
;;;        )
;;;   ) ;end_cond

 (if (null (tblSearch "Style" "ArialT"))
  (vl-cmdf "Style" "ArialT" "arial" 0 1 0 "_N" "_N")
  (setvar "TextStyle" "ArialT")
 )
  
   (entMake '((0 . "BLOCK") (2 . "PxT") (70 . 2) (8 . "0") (10 0 0 0) (6 . "ByLayer") (62 . 256) (4 . "Made by Me"))  ) ; end of e
   (entMake (list '(0 . "Circle") '(8 . "0") '(62 . 256) '(6 . "ByLayer") '(10 0 0 0) (cons 40 0.25) ) ) ; end of e

   (entMake (list '(0 . "AttDef") '(100 . "AcDbEntity") (cons 8 "Name L") '(62 . 256) '(6 . "ByLayer") ;'(67 . 0) '(10 0 0 0)
                  '(100 . "AcDbText") '(10 0.5 +1.0 0) '(40 . 1.5) '(1 . "N") '(50 . 0) '(41 . 1) '(51 . 0) '(7 . "ArialT")
                  '(71 . 0) '(72 . 0)
                            '(11 0.5 +1.0 0) '(210 0.0 0.0 1.0)
                  '(100 . "AcDbAttributeDefinition") '(280 . 0) '(3 . "Point Name") '(2 . "NAME") '(70 . 0) '(73 . 0) '(74 . 2) '(280 . 1) ) ) ; end of e  '(100 . "AcDbXrecord") 

   (entMake '((0 . "EndBlk") (8 . "0")) ) ; end of e
   (prinC "\n   Block  with  Attributes  DEFINED  :  PxT  ;") ; end of p
  ) ; else
 ) ; if

 (setq ;q (getString "\n   Attribute  Insertion  with  Codes  100  :  Any = NO  ;   <  Enter = YES  >  :  ")
       i 0)

;;; (setVar "TextStyle" "ArialT")
 (repeat 10 ; Inserting 10 Blocks with Attribute
  (entMake (list '(0 . "Insert") '(2 . "PxT") '(8 . "0") '(66 . 1) (cons 10 (trans (list i i i) 1 0)) '(50 . 0) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0)) ) ; inserare Bloc

  (if (= (rem i 2) 0) ;(= q "")
  (entMake (list '(0 . "ATTRIB") '(100 . "AcDbEntity") '(8 . "Name L") '(67 . 0) ;'(6 . "ByLayer") ;'(62 . 256) '(67 . 0) ;0 = MSpace ;
                 '(100 . "AcDbText") (list 10 i i 0) '(40 . 1) (cons 1 (ItoA i)) '(50 . 0) '(41 . 1.0) '(51 . 0.0)  '(7 . "ArialT")
                        '(71 . 0) '(72 . 0) (cons 11 (list i i i)) ;'(210 0.0 0.0 1.0)
                 '(100 . "AcDbAttribute") '(280 . 0) '(2 . "NAME") '(70 . 0) '(73 . 0) (cons 74 2) '(280 . 1) )  ) ; set Attribute


  (entMake (list '(0 . "ATTRIB") (list 10 i i i)  '(8 . "Name L") (cons 1 (ItoA i)) '(280 . 0) '(2 . "NAME") '(40 . 1) '(70 . 0)
             (cons 11 (trans (list i i i) 1 0)) (cons 72 0) (cons 74 2) '(6 . "ByLayer") '(7 . "ArialT") '(50 . 0) '(62 . 5) '(280 . 1) )  ) ; e
  ) ; if
  (entMake '((0 . "SeqEnd") (8 . "0")) ) ; End Insert Block !

  (setq i (1+ i))  
 ) ; r

 (setVar "TextStyle" "Standard")
 (command "zoom" "e")
 (prinC (strCat "\n   Inserted  :  " (ItoA i) "  ;"))
 (prinC "\n   TestPP  :  END  ;") (prinC)
) ; 
0 Likes
Message 34 of 61

Moshe-A
Mentor
Mentor

basically i did not change anything essential that you don't aware of

but have my version

 

 

 

 

 

 

0 Likes
Message 35 of 61

Anonymous
Not applicable
(setVar "TextStyle" "Standard")
(vl-CmdF "_.Purge" "_A" "" "_N")

; redifine ArialT
(if (null (tblSearch "Style" "ArialT"))
  (vl-cmdf "Style" "ArialT" "arial" 0 1 0 "_N" "_N") )
  (setvar "TextStyle" "ArialT")
 )

This is the order .

 

your code is not doing  LockPosition for inserted Attributes , only for definition of block .

 

0 Likes
Message 36 of 61

Anonymous
Not applicable

The post was not Solved !

 

 

A temporary solution , is to preserve the TextStyle "ArialT" in the drawing , without to be necessary to redefine it .

 

But, if I need to set a new TextStyle current , and if I will purge the drawing , I will lose the TextStyle "ArialT" .

 

 

0 Likes
Message 37 of 61

Moshe-A
Mentor
Mentor

after exploring more on this issue (even found your thread  5 years ago) i came to the conclusion that there is something missing here to do it (cause we know battman\attsync does do it) i do not know what it is but my suggestion for you now is to open a thread in >> ObjectARX Forum << or even >> .NET Forum <<  tell your story maybe some one there will agree to write a small function in arx (or a dll) to cooperate with lisp i'm sure ObjARX\.NET are more powerful tools but remember that arx is platform specific meaning you have to get a compiled arx file for each AutoCAD version (about dll i think it's the same but never go to .NET)

 

by the way have you thought to lock the attribute layer and handle the whole case for users (attribute edit) on your own? for instance you could install a database reactor to watch layer properties and if the user unlock the layer, lock it immediately back but if they want to change the attribute value unlock it temporary?

 

moshe

 

 

 

 

 

 

 

 

 

0 Likes
Message 38 of 61

Anonymous
Not applicable

Sorry I gave you a headache Moshe !

 

1. I don't think we need to complicate the problem .

 

Why the next code is working :

(entMake (list '(0 . "ATTRIB") (list 10 i i i)  '(8 . "Name L") (cons 1 (ItoA i)) '(280 . 0) '(2 . "NAME") '(40 . 1) '(70 . 0)
             (cons 11 (trans (list i i i) 1 0)) (cons 72 0) (cons 74 2) '(6 . "ByLayer") '(7 . "ArialT") '(50 . 0) '(62 . 5) '(280 . 1) )  ) ; e
 

with no problem for "ArialT" , but with no effect for (280 . 1) .

 

Why the next code is working fine for (280 . 1)

(entMake (list '(0 . "ATTRIB") '(100 . "AcDbEntity") '(8 . "Name L") '(67 . 0) ;'(6 . "ByLayer") ;'(62 . 256) '(67 . 0) ;0 = MSpace ;
                 '(100 . "AcDbText") (list 10 i i 0) '(40 . 1) (cons 1 (ItoA i)) '(50 . 0) '(41 . 1.0) '(51 . 0.0)  '(7 . "ArialT")
                        '(71 . 0) '(72 . 0) (cons 11 (list i i i)) ;'(210 0.0 0.0 1.0)
                 '(100 . "AcDbAttribute") '(280 . 0) '(2 . "NAME") '(70 . 0) '(73 . 0) (cons 74 2) '(280 . 1)
                 )  )

but it is a problem for TextStyle "ArialT" ?

 

Should be a skip somewhere in this DXF code . 

 

It is not about .NET or ARX .

 

About Object and Entity Codes (DXF) AutoCAD 2014 : page 2 .
In the DXF™ format, the definition of objects differs from entities: objects have no graphical representation and entities do. For example, dictionaries are objects, and not entities. Entities are also referred to as graphical objects while objects are referred to as nongraphical objects. Entities appear in both the BLOCK and ENTITIES sections of the DXF file. The use of group codes in the two sections is identical. Some group codes that define an entity always appear; others are optional and appear only if their values differ from the defaults. Do not write programs that rely on the order given here. The end of an entity is indicated by the next 0 group, which begins the next entity or indicates the end of the section. NOTE Accommodating DXF files from future releases of AutoCAD® will be easier if you write your DXF processing program in a table-driven way, ignore undefined group codes, and make no assumptions about the order of group codes in an entity. With each new AutoCAD release, new group codes will be added to entities
to accommodate additional features.

 

2. I don't want to luck / unluck the Attributes contents . I just want the attributes to be LuckPosition , fewer grips on the screen .

 

3. I am expecting someone from AutoDesk , with more experience in DXF to guide us with the right code line for entMake for "Attrib" . I am very sure something like (xxx . 1) or (100 . "xxxx") somewhere it's missing and can do the difference . 

 

Because , when I added (100 . "AcDbAttribute") , (280 . 1)=LuckPosition , take effect .

 

Apropos , how it is working on the first time without no problem ?

 

Regards ,

 

Costin

 

 

 

 

0 Likes
Message 39 of 61

Moshe-A
Mentor
Mentor

 

Because , when I added (100 . "AcDbAttribute") , (280 . 1)=LuckPosition , take effect .

it does not work for me. adding dxf 100 causes the lisp to send bad argument type, if i disable dxf 100, it works but ignore the dxf 280

 

Apropos , how it is working on the first time without no problem ?

yes it works but ignore dxf 280

 

if you lock the layer, no grips will be show at all.

 

moshe

 

 

0 Likes
Message 40 of 61

Anonymous
Not applicable

Hello moshe ,

 

1. unfortunately , you need to use ALL 100 codes in red , as in my post , and then , (280 . 1) will have effect .

 

(100 . "AcDbEntity")
....
(100 . "AcDbText")
...
(100 . "AcDbAttributeDefinition")
...

2. I think you are using a different lisp for c:TestPP , see below :

(defun c:TestPP ()
 (prinC "\n  TestPP  :  V  :  1 . 04 . 2019  ;")
 (setVar "TextStyle" "Standard")
 (vl-CmdF "_.Purge" "_A" "" "_N")

 (if (tblSearch "Block" "PxT")
  (princ "\n  Block  Existed !")
  (progn ; else Define Block
   (command "_.Layer" "_N" "Name L" "_C" 1 "Name L" "")

   (if (null (tblSearch "Style" "ArialT"))
    (vl-cmdf "Style" "ArialT" "arial" 0.5 1 0 "_N" "_N")
    (princ "\n  ArialT  Existed !") ;(setvar "TextStyle" "ArialT")
   )
  
   (entMake '((0 . "BLOCK") (2 . "PxT") (70 . 2) (8 . "0") (10 0 0 0) (6 . "ByLayer") (62 . 256) (4 . "Made by Me"))  ) ; end of e
   (entMake (list '(0 . "Circle") '(8 . "0") '(62 . 256) '(6 . "ByLayer") '(10 0 0 0) (cons 40 0.25) ) ) ; end of e

   (entMake (list '(0 . "AttDef") '(100 . "AcDbEntity") (cons 8 "Name L") '(62 . 256) '(6 . "ByLayer") ;'(67 . 0) '(10 0 0 0)
                  '(100 . "AcDbText") '(10 0.5 +1.0 0) '(40 . 1.5) '(1 . "N") '(50 . 0) '(41 . 1) '(51 . 0) '(7 . "ArialT")
                  '(71 . 0) '(72 . 0) '(11 0.5 +1.0 0) '(210 0.0 0.0 1.0)
                  '(100 . "AcDbAttributeDefinition") '(280 . 0) '(3 . "Point Name") '(2 . "NAME") '(70 . 0) '(73 . 0) '(74 . 2) '(280 . 1) ) ) ; end of e  '(100 . "AcDbXrecord") 

   (entMake '((0 . "EndBlk") (8 . "0")) ) ; end of e
   (prinC "\n   Block  with  Attributes  DEFINED  :  PxT  ;") ; end of p
  ) ; else
 ) ; if

 (setq i 0)

;;; (setVar "TextStyle" "ArialT")
 (repeat 10 ; Inserting 10 Blocks with Attribute
  (entMake (list '(0 . "Insert") '(2 . "PxT") '(8 . "0") '(66 . 1) (cons 10 (trans (list i i i) 1 0)) '(50 . 0) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0)) ) ; inserare Bloc

  (if (= (rem i 2) 0) ;(= q "")
  (entMake (list '(0 . "ATTRIB") '(100 . "AcDbEntity") '(8 . "Name L") '(67 . 0) ;'(6 . "ByLayer") ;'(62 . 256) '(67 . 0) ;0 = MSpace ;
                 '(100 . "AcDbText") (list 10 i i 0) '(40 . 1) (cons 1 (ItoA i)) '(50 . 0) '(41 . 1.0) '(51 . 0.0)  '(7 . "ArialT")
                        '(71 . 0) '(72 . 0) (cons 11 (list i i i)) ;'(210 0.0 0.0 1.0)
                 '(100 . "AcDbAttribute") '(280 . 0) '(2 . "NAME") '(70 . 0) '(73 . 0) (cons 74 2) '(280 . 1) )  ) ; set Attribute


  (entMake (list '(0 . "ATTRIB") (list 10 i i i)  '(8 . "Name L") (cons 1 (ItoA i)) '(280 . 0) '(2 . "NAME") '(40 . 1) '(70 . 0)
             (cons 11 (trans (list i i i) 1 0)) (cons 72 0) (cons 74 2) '(6 . "ByLayer") '(7 . "ArialT") '(50 . 0) '(62 . 5) '(280 . 1) )  ) ; e
  ) ; if
  (entMake '((0 . "SeqEnd") (8 . "0")) ) ; End Insert Block !

  (setq i (1+ i))  
 ) ; r

 (setVar "TextStyle" "Standard")
 (command "zoom" "e")
 (prinC (strCat "\n   Inserted  :  " (ItoA i) "  ;"))
 (prinC "\n   TestPP  :  END  ;") (prinC)
) ; c:TestPP

And (280 . 1) will have an effect . Picture attached with results .

 

3. If you luck the Layer , how you can manipulate the blocks then ? 

 

Costin

0 Likes