Author Topic: Edit Block Attribute  (Read 1303 times)

0 Members and 1 Guest are viewing this topic.

amc.dicsac

  • Newt
  • Posts: 109
  • Autocad 2008
Edit Block Attribute
« on: December 12, 2017, 01:08:51 PM »
Hello, I have the following code that allows me to select polylines to save the distance and then insert a block with an attribute, but the problem is how I add the distance to the attribute.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:pee (/ s i e Long Cadena BlockEsc BlockName Msj_Bloque)
  2. (setvar "cmdecho" 0)
  3.          '((0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")
  4.            (-4 . "<NOT")
  5.            (-4 . "<AND")
  6.            (0 . "POLYLINE")
  7.            (-4 . "&")
  8.            (70 . 80)
  9.            (-4 . "AND>")
  10.            (-4 . "NOT>")
  11.           )
  12.        )
  13. )
  14. (setq i (sslength s))
  15. (setq e (ssname s (setq i (1- i))))
  16. (setq Cadena (strcat "L=" Long "m"))
  17. (setq BlockEsc "1")
  18. (setq BlockName "1-DZL-BLOCK PENDIENTE")
  19. (setq Msj_Bloque (strcat  "\n>> Especifica inserción del bloque [ " BlockName " ]: "))
  20. (princ Msj_Bloque)
  21. (command "._insert" BlockName "_s" BlockEsc Cadena)
  22. (while (= (logand (getvar "cmdactive") 1) 1)
  23. (command pause))
  24. (setvar "cmdecho" 1)
<a href="http:/http://axprogramlisp.blogspot.pe" class="bbc_link" target="_blank">By Alexander Castro</a>

BIGAL

  • Swamp Rat
  • Posts: 1419
  • 40 + years of using Autocad
Re: Edit Block Attribute
« Reply #1 on: December 13, 2017, 05:45:46 AM »
If you have say a block with a single attribute length then just
Code: [Select]
(command "-insert" Blockname pt 1 1 0 attributevalue)
A man who never made a mistake never made anything

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Edit Block Attribute
« Reply #2 on: December 13, 2017, 07:45:41 AM »
I belive you have to save the block in a seperete file to call if not exist in file.
filename should has file extention
Code - Auto/Visual Lisp: [Select]
  1. (setq BlockName "c:/MyBlocks/1-DZL-BLOCK PENDIENTE.dwg")

And this line changed too
Code - Auto/Visual Lisp: [Select]
  1. (command "._insert" BlockName Msj_Bloque BlockEsc BlockEsc BlockEsc Cadena)

Not Tested