Author Topic: Entmake multi-line ATRIB  (Read 1194 times)

0 Members and 1 Guest are viewing this topic.

Logan

  • Newt
  • Posts: 41
Entmake multi-line ATRIB
« on: August 03, 2017, 04:52:00 PM »
Hello guys.
Could anyone tell me if it is possible to construct multi-line ATRIB by entmake?  :thinking:
I have not found this property in the DXF references.
https://www.autodesk.com/techpubs/autocad/acad2000/dxf/attrib_dxf_06.htm
https://www.autodesk.com/techpubs/autocad/acad2000/dxf/text_dxf_06.htm#XREF_23588_DXF_06

Using the entget function I also could not find the code responsible for this property.
I'm coming to the conclusion that I will have to create part of the block by entmake and use the AddAttribute method to complete.

I chose to use the entmake I think is the easiest way to create objects like these.
Code: [Select]
(defun c:test (/ blkTable blkObj)
  (if
    (and
     
      (entmake
(list
  '(0 . "BLOCK")
  '(2 . "TEST")
  '(100 . "AcDbEntity")
  '(100 . "AcDbBlockBegin")
  '(67 . 0)
  '(8 . "0")
  '(100 . "AcDbBlockReference")
  '(10 0.0 0.0 0.0)
  '(70 . 2)
) ;_ >list
      ) ;_ >entmake

      (entmake
(list
  '(0 . "LWPOLYLINE")
  '(100 . "AcDbEntity")
  '(67 . 0)
  '(8 . "0")
  '(100 . "AcDbPolyline")
  '(90 . 10)
  '(70 . 1)
  '(38 . 0.0)
  '(39 . 0.0)
  '(10 -14.7821 1.42109e-014)
  '(40 . 0.0)
  '(41 . 1.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -14.7821 3.06147)
  '(40 . 0.638135)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -10.4525 7.39104)
  '(40 . 0.0)
  '(41 . 0.638135)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -4.32957 7.39104)
  '(40 . 0.638135)
  '(41 . 1.5)
  '(42 . 0.0)
  '(91 . 0)
  '(10 1.77636e-015 3.06147)
  '(40 . 1.5)
  '(41 . 1.5)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -1.77636e-015 -3.06147)
  '(40 . 1.5)
  '(41 . 0.638135)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -4.32957 -7.39104)
  '(40 . 0.638135)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -10.4525 -7.39104)
  '(40 . 0.0)
  '(41 . 0.638135)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -14.7821 -3.06147)
  '(40 . 1.0)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -14.7821 1.42109e-014)
  '(40 . 0.638135)
  '(41 . 0.638135)
  '(42 . 0.0)
  '(91 . 0)
  '(210 0.0 0.0 1.0)
) ;_ >list
      ) ;_ >entmake

      (entmake
(list
  '(0 . "LWPOLYLINE")
  '(100 . "AcDbEntity")
  '(67 . 0)
  '(8 . "0")
  '(100 . "AcDbPolyline")
  '(90 . 4)
  '(70 . 1)
  '(38 . 0.0)
  '(39 . 0.0)
  '(10 -3.38524 2.28205)
  '(40 . 0.0)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -7.33787 4.26326e-014)
  '(40 . 0.0)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -3.38524 -2.28205)
  '(40 . 0.0)
  '(41 . 0.7)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -4.27563 1.42109e-014)
  '(40 . 0.7)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(210 0.0 0.0 1.0)
) ;_ >list
      ) ;_ >entmake

      (entmake
'(
  (0 . "ENDBLK")
  (100 . "AcDbBlockEnd")
  (8 . "0")
)
      ) ;_ >entmake
    ) ;_ >and
   
    (progn
      (setq blkTable (vla-get-blocks
       (vla-get-activedocument (vlax-get-acad-object))
     ) ;_ >vla-get-blocks
      ) ;_ >setq
      (if (not (vl-catch-all-error-p
(setq blkObj (vl-catch-all-apply
'vla-item
(list blkTable "TEST")
      ) ;_ >vl-catch-all-apply
) ;_ >setq
       ) ;_ >vl-catch-all-error-p
  ) ;_ >not
(progn
  (vla-put-explodable blkObj :vlax-false)
  (vla-put-blockscaling blkObj acUniform)
  (vlax-put-property blkObj "Units" 4)
) ;_ >progn
      ) ;_ >if
    ) ;_ >progn
  ) ;_ >if
) ;_ >defun

Best Regards
Luís Augusto

Rod

  • Newt
  • Posts: 185
Re: Entmake multi-line ATRIB
« Reply #1 on: August 03, 2017, 07:42:56 PM »
Looks like you are using a very old DXF reference.
I think this is the one you are after http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-7DD8B495-C3F8-48CD-A766-14F9D7D0DD9B
Sorry don't have time to help more now.

Cheers, Rod
"All models are wrong, some models are useful" - George Box

Logan

  • Newt
  • Posts: 41
Re: Entmake multi-line ATRIB
« Reply #2 on: August 04, 2017, 08:08:54 AM »
Ausrod, I'm very grateful for your help.
It was exactly what I needed.
Thank you very much.
Code: [Select]
(defun c:test (/ blkTable
blkObj
lstAtt
attName
attPromp
ocsY
lst10
lst11
      )
  (vl-load-com)

  (defun *error* (errmsg)
    (princ "error: ")
    (princ errmsg)
    (princ)
  ) ;_ >defun
 
  (setq lstAtt '("A" "B" "C" "D"))
 
  (if
    (and     
      (entmake
(list
  '(0 . "BLOCK")
  '(2 . "TEST")
  '(100 . "AcDbEntity")
  '(100 . "AcDbBlockBegin")
  '(67 . 0)
  '(8 . "0")
  '(100 . "AcDbBlockReference")
  '(10 0.0 0.0 0.0)
  '(70 . 2)
) ;_ >list
      ) ;_ >entmake
      (entmake
(list
  '(0 . "LWPOLYLINE")
  '(100 . "AcDbEntity")
  '(67 . 0)
  '(8 . "0")
  '(100 . "AcDbPolyline")
  '(90 . 10)
  '(70 . 1)
  '(38 . 0.0)
  '(39 . 0.0)
  '(10 -14.7821 1.42109e-014)
  '(40 . 0.0)
  '(41 . 1.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -14.7821 3.06147)
  '(40 . 0.638135)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -10.4525 7.39104)
  '(40 . 0.0)
  '(41 . 0.638135)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -4.32957 7.39104)
  '(40 . 0.638135)
  '(41 . 1.5)
  '(42 . 0.0)
  '(91 . 0)
  '(10 1.77636e-015 3.06147)
  '(40 . 1.5)
  '(41 . 1.5)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -1.77636e-015 -3.06147)
  '(40 . 1.5)
  '(41 . 0.638135)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -4.32957 -7.39104)
  '(40 . 0.638135)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -10.4525 -7.39104)
  '(40 . 0.0)
  '(41 . 0.638135)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -14.7821 -3.06147)
  '(40 . 1.0)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -14.7821 1.42109e-014)
  '(40 . 0.638135)
  '(41 . 0.638135)
  '(42 . 0.0)
  '(91 . 0)
  '(210 0.0 0.0 1.0)
) ;_ >list
      ) ;_ >entmake
      (entmake
(list
  '(0 . "LWPOLYLINE")
  '(100 . "AcDbEntity")
  '(67 . 0)
  '(8 . "0")
  '(100 . "AcDbPolyline")
  '(90 . 4)
  '(70 . 1)
  '(38 . 0.0)
  '(39 . 0.0)
  '(10 -3.38524 2.28205)
  '(40 . 0.0)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -7.33787 4.26326e-014)
  '(40 . 0.0)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -3.38524 -2.28205)
  '(40 . 0.0)
  '(41 . 0.7)
  '(42 . 0.0)
  '(91 . 0)
  '(10 -4.27563 1.42109e-014)
  '(40 . 0.7)
  '(41 . 0.0)
  '(42 . 0.0)
  '(91 . 0)
  '(210 0.0 0.0 1.0)
) ;_ >list
      ) ;_ >entmake

      (setq ocsY -3.0)

      (mapcar
(function
  (lambda (att)
    (setq attName  (cons 3 (strcat "AT_" att))
  attPromp (cons 2 (strcat "AT_" att))
  ocsY    (+ ocsY 3.0)
  lst10    (list 10 33.0 ocsY 0.0)
  lst11    (list 11 33.0 ocsY 0.0)
    ) ;_ >setq
    (entmake
     (list
       '(0 . "ATTDEF")
       '(100 . "AcDbEntity")
       '(8 . "0")
       '(100 . "AcDbText")
       lst10
       '(40 . 2.0)
       '(1 . "")
       '(50 . 0.0)
       '(41 . 1.0)
       '(51 . 0.0)
       '(7 . "STANDARD")
       '(71 . 0)
       '(72 . 0)
       lst11
       '(210 0.0 0.0 1.0)
       '(100 . "AcDbAttributeDefinition")
       '(280 . 0)
       attName
       attPromp
       '(70 . 1)
       '(73 . 0)
       '(74 . 3)
       '(280 . 0)
       '(71 . 4)
       '(72 . 0)
       lst11
       '(101 . "Embedded Object")
       lst10
       '(40 . 2.0)
       '(41 . 0.0)
       '(46 . 0.0)
       '(71 . 1)
       '(72 . 5)
       '(1 . "")
       '(7 . "STANDARD")
       '(210 0.0 0.0 1.0)
       lst11
       '(42 . 0.0)
       '(43 . 0.0)
       '(50 . 0.0)
       '(73 . 1)
       '(44 . 1.0)
     ) ;_ >list
    ) ;_ >entmake
  ) ;_ >lambda    
) ;_ >mapcar
lstAtt
      ) ;_ >mapcar
     
      (entmake
'(
  (0 . "ENDBLK")
  (100 . "AcDbBlockEnd")
  (8 . "0")
)
      ) ;_ >entmake
    ) ;_ >and
   
    (progn
      (setq blkTable (vla-get-blocks
       (vla-get-activedocument (vlax-get-acad-object))
     ) ;_ >vla-get-blocks
      ) ;_ >setq
      (if (not (vl-catch-all-error-p
(setq blkObj (vl-catch-all-apply
'vla-item
(list blkTable "TEST")
      ) ;_ >vl-catch-all-apply
) ;_ >setq
       ) ;_ >vl-catch-all-error-p
  ) ;_ >not
(progn
  (vla-put-explodable blkObj :vlax-false)
  (vla-put-blockscaling blkObj acUniform)
  (vlax-put-property blkObj "Units" 4)
) ;_ >progn
      ) ;_ >if
    ) ;_ >progn
  ) ;_ >if
) ;_ >defun
Best regards, Luís Augusto
« Last Edit: August 04, 2017, 08:57:10 AM by Logan »

efernal

  • Bull Frog
  • Posts: 206
Re: Entmake multi-line ATRIB
« Reply #3 on: August 04, 2017, 10:41:46 AM »
Code - Auto/Visual Lisp: [Select]
  1. (IF (NULL (TBLSEARCH "BLOCK" "PI-Mudança de seção do condutor de média tensão mesmo nível-C"))
  2.            (PROGN (ENTMAKE '((0 . "BLOCK")
  3.                              (2 . "PI-Mudança de seção do condutor de média tensão mesmo nível-C")
  4.                              (70 . 2)
  5.                              (10 0.0 0.0 0.0)
  6.                             )
  7.                   )
  8.                   (ENTMAKE '((0 . "TEXT")
  9.                              (100 . "AcDbEntity")
  10.                              (8 . "Textos em blocos Cepisa")
  11.                              (100 . "AcDbText")
  12.                              (10 -0.0915 -0.315 0.0)
  13.                              (40 . 0.09)
  14.                              (1 . "CE4")
  15.                              (50 . 0.0)
  16.                              (41 . 0.7)
  17.                              (51 . 0.0)
  18.                              (7 . "Textos em blocos Cepisa")
  19.                              (71 . 0)
  20.                              (72 . 1)
  21.                              (11 0.0 -0.27 0.0)
  22.                              (100 . "AcDbText")
  23.                              (73 . 2)
  24.                             )
  25.                   )
  26.                   (ENTMAKE '((0 . "ATTDEF")
  27.                              (100 . "AcDbEntity")
  28.                              (8 . "Textos em blocos Cepisa")
  29.                              (100 . "AcDbText")
  30.                              (10 -0.5755 -0.225 0.0)
  31.                              (40 . 0.09)
  32.                              (1 . "3x150+9.5")
  33.                              (50 . 0.0)
  34.                              (41 . 0.7)
  35.                              (51 . 0.0)
  36.                              (7 . "Textos em blocos Cepisa")
  37.                              (71 . 0)
  38.                              (72 . 1)
  39.                              (11 -0.55 -0.18 0.0)
  40.                              (100 . "AcDbAttributeDefinition")
  41.                              (280 . 0)
  42.                              (3 . "Especificação")
  43.                              (2 . "1")
  44.                              (70 . 0)
  45.                              (73 . 0)
  46.                              (74 . 2)
  47.                              (280 . 1)
  48.                             )
  49.                   )
  50.                   (ENTMAKE '((0 . "ATTDEF")
  51.                              (100 . "AcDbEntity")
  52.                              (8 . "Textos em blocos Cepisa")
  53.                              (100 . "AcDbText")
  54.                              (10 0.52 -0.225 0.0)
  55.                              (40 . 0.09)
  56.                              (1 . "3x70+9.5")
  57.                              (50 . 0.0)
  58.                              (41 . 0.7)
  59.                              (51 . 0.0)
  60.                              (7 . "Textos em blocos Cepisa")
  61.                              (71 . 0)
  62.                              (72 . 1)
  63.                              (11 0.55 -0.18 0.0)
  64.                              (100 . "AcDbAttributeDefinition")
  65.                              (280 . 0)
  66.                              (3 . "Especificação")
  67.                              (2 . "2")
  68.                              (70 . 0)
  69.                              (73 . 0)
  70.                              (74 . 2)
  71.                              (280 . 1)
  72.                             )
  73.                   )
  74.                   (ENTMAKE
  75.                     '((0 . "LINE") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbLine") (10 0.15 0.0 0.0) (11 0.9 0.0 0.0))
  76.                   )
  77.                   (ENTMAKE '((0 . "SOLID")
  78.                              (100 . "AcDbEntity")
  79.                              (8 . "0")
  80.                              (100 . "AcDbTrace")
  81.                              (10 0.15 0.0 0.0)
  82.                              (11 0.185355 0.0353553 0.0)
  83.                              (12 0.185355 -0.0353553 0.0)
  84.                              (13 0.185355 -0.0353553 0.0)
  85.                              (39 . 0.0)
  86.                             )
  87.                   )
  88.                   (ENTMAKE '((0 . "LINE")
  89.                              (100 . "AcDbEntity")
  90.                              (8 . "0")
  91.                              (100 . "AcDbLine")
  92.                              (10 -0.15 0.0 0.0)
  93.                              (11 -0.9 0.0 0.0)
  94.                             )
  95.                   )
  96.                   (ENTMAKE '((0 . "SOLID")
  97.                              (100 . "AcDbEntity")
  98.                              (8 . "0")
  99.                              (100 . "AcDbTrace")
  100.                              (10 -0.15 0.0 0.0)
  101.                              (11 -0.185355 0.0353553 0.0)
  102.                              (12 -0.185355 -0.0353553 0.0)
  103.                              (13 -0.185355 -0.0353553 0.0)
  104.                              (39 . 0.0)
  105.                             )
  106.                   )
  107.                   (ENTMAKE
  108.                     '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 0.15))
  109.                   )
  110.                   (ENTMAKE
  111.                     '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 0.075))
  112.                   )
  113.                   (ENTMAKE '((0 . "ENDBLK")))
  114.            )
  115.            nil
  116.          )
  117.  
e.fernal