<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to insert and edit attributes of a block in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7289530#M116548</link>
    <description>&lt;P&gt;Hello. I've tried to use your code, but I am a beginner in lisp taks, so guess what ... I was not succesful. I am sending a simple block as example, so supposing that I want to insert it at coordinates x=100 and y=12, with the attribute NUMBER=01 and CODE=9887, how can I indicate these number in the lisp. I've tried to perform it using your example but I really do not have enough knolegment with autolisps to make it work. I think I am forgeting something. Could you please help me ?&lt;/P&gt;</description>
    <pubDate>Thu, 10 Aug 2017 05:18:23 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-08-10T05:18:23Z</dc:date>
    <item>
      <title>how to insert and edit attributes of a block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7288941#M116545</link>
      <description>&lt;P&gt;Hello. I would like to create a lisp routine to insert a block in specific coordinates and edit the attributes of this block.&amp;nbsp;Do you have any exemples to help me in this task? Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 21:23:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7288941#M116545</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-09T21:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert and edit attributes of a block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7289015#M116546</link>
      <description>&lt;P&gt;Take a look at the TransAtts.lsp posted &lt;STRONG&gt;&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-with-a-routine-lisp-routine-that-will-make-life-easier-for/td-p/7275838" target="_blank"&gt;here&lt;/A&gt;.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It should give you plenty of ideas.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 22:05:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7289015#M116546</guid>
      <dc:creator>john.uhden</dc:creator>
      <dc:date>2017-08-09T22:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert and edit attributes of a block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7289454#M116547</link>
      <description>&lt;P&gt;Here's another way,&amp;nbsp;[ Not as complete as Johns offering&amp;nbsp;]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:demo  (/ _Insert&amp;amp;AddValue str p)
(defun _Insert&amp;amp;AddValue  (bname p attvalue / blk)
    (setq blk  (vlax-invoke
                     (vlax-get
                           (vla-get-ActiveLayout
                                 (vla-get-activedocument
                                       (vlax-get-acad-object)))
                           'Block)
                     'InsertBlock p
                     bname 1 1 1 0))
    (mapcar '(lambda (a b)
                   (vla-put-textstring a b))
            (vlax-invoke blk 'Getattributes)
            attvalue)
    (princ)
    )
      (_Insert&amp;amp;AddValue
            "YourBlockname"
            "Yourcoordinates"
            '("list of values" "for your attribute"));&amp;lt;-- order of attribute prompt
      (princ)
      )&lt;/PRE&gt;
&lt;P&gt;HTH&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 04:09:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7289454#M116547</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2017-08-10T04:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert and edit attributes of a block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7289530#M116548</link>
      <description>&lt;P&gt;Hello. I've tried to use your code, but I am a beginner in lisp taks, so guess what ... I was not succesful. I am sending a simple block as example, so supposing that I want to insert it at coordinates x=100 and y=12, with the attribute NUMBER=01 and CODE=9887, how can I indicate these number in the lisp. I've tried to perform it using your example but I really do not have enough knolegment with autolisps to make it work. I think I am forgeting something. Could you please help me ?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 05:18:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7289530#M116548</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-10T05:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert and edit attributes of a block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7289583#M116549</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Hello. I've tried to use your code, but I am a beginner in lisp taks, so guess what ... I was not succesful. I am sending a simple block as example, so supposing that I want to insert it at coordinates x=100 and y=12, with the attribute NUMBER=01 and CODE=9887, how can I indicate these number in the lisp. I've tried to perform it using your example but I really do not have enough knolegment with autolisps to make it work. I think I am forgeting something. Could you please help me ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course, we will help you jean_rossini&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep in mind that this is a demonstration code,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:demo  (/ _Insert&amp;amp;AddValue str p)
(defun _Insert&amp;amp;AddValue  (bname p attvalue / blk)
    (setq blk  (vlax-invoke
                     (vlax-get
                           (vla-get-ActiveLayout
                                 (vla-get-activedocument
                                       (vlax-get-acad-object)))
                           'Block)
                     'InsertBlock p
                     bname 1 1 1 0))
    (mapcar '(lambda (a b)
                   (vla-put-textstring a b))
            (vlax-invoke blk 'Getattributes)
            attvalue)
    (princ)
    )
      (_Insert&amp;amp;AddValue
            &lt;FONT color="#0000FF"&gt;"dt"&lt;/FONT&gt;  &lt;FONT color="#0000FF"&gt;(list 100.00 12.00 0.0)&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;(list "9887" "01")&lt;/FONT&gt;)
      (princ)
      )&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are planning to use for real, it may look something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:&lt;FONT color="#0000FF"&gt;demo2&lt;/FONT&gt;  (/ _Insert&amp;amp;AddValue str p)
 
(defun _Insert&amp;amp;AddValue  (bname p attvalue / blk)
    (setq blk  (vlax-invoke
                     (vlax-get
                           (vla-get-ActiveLayout
                                 (vla-get-activedocument
                                       (vlax-get-acad-object)))
                           'Block)
                     'InsertBlock p
                     bname 1 1 1 0))
    (mapcar '(lambda (a b)
                   (vla-put-textstring a b))
            (vlax-invoke blk 'Getattributes)
            attvalue)
    (princ)
    )

;;;			DATA			;;;
&lt;FONT color="#0000FF"&gt;(setq blockname "dt")
(setq pointsforinsertion '(	(129.341 88.4354 0.0)
			(109.854 115.512 0.0)
		        (75.4478 96.6498 0.0)
		        (71.1851 134.375 0.0)
		        (33.4296 95.1286 0.0)))

(setq code 	'("123" "75675" "687" "2345" "okidoki"))
(setq counter  '("01""02" "03" "04" "05"))&lt;/FONT&gt;

;;;		   END of DATA			;;;

;;; Pass the value to _Insert&amp;amp;AddValue function	;;;
 
&lt;FONT color="#0000FF"&gt;(mapcar '(lambda (x y z)
               (_Insert&amp;amp;AddValue blockname x (list y z)))
 			pointsforinsertion
 			code
 			counter)&lt;/FONT&gt;
 
;;;		 END of function		;;;
(princ)
 
 )&lt;/PRE&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 05:49:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7289583#M116549</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2017-08-10T05:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert and edit attributes of a block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7291528#M116550</link>
      <description>&lt;P&gt;Hello. The code demo2 is exactly what I was looking for, I am really grateful for your help. I intend to use your code (demo2) together with my code gdt, but I have one last question. The code gdt reads a txt file that contains the attributes for the block dt (NUMBER, CODE and coordinates x and y). I've created four lists to insert these data according to your code demo2, however I was not sucessful. I think I am inserting data in a wrong format, but I really don't know how to solve it. Could you please help me again?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:gdt ()
  (setq NOME (getfiled "Open file" "" "TXT" (+ 2 4)))

    (setq FD (open NOME "r")); open the file "data"
		  
  		  
	    (while (setq REG (read-line FD)); it reads the file line by line


			  (setq a (substr REG 1 2)); in the file: initial position 1, length 2
			  (setq a1 (read a)); it is the attribute NUMBER 

			  (setq nox (substr REG 4 10)); in the file: initial position 4, length 10
			  (setq nox1 (read nox)); it is the x coordinate

			  (setq noy (substr REG 15 10)); in the file: initial position 15, length 10
			  (setq noy1 (read noy)); it is the y coordinate
    
	   		  (setq CD (substr REG 27 4)); in the file: initial position 27, length 4
	                  (setq CD1 (read CD)); it is the attribute CODE


;; list creation 
		  	  (setq counter (append counter (list a1))); NUMBER list
		      (setq coordx (append coordx (list nox1))); x coordinates list
		      (setq coordy (append coordy (list noy1))); y coordinates list
	          (setq code (append code (list CD1))); CODE list


;; just printing to evaluate 
	          (princ counter) (terpri)
	          (princ coordx) (terpri)
		  (princ coordy) (terpri)
	          (princ code) (terpri)
;;;;

		); while

	(close FD)
);defun&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Aug 2017 18:03:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7291528#M116550</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-10T18:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert and edit attributes of a block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7291650#M116551</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;... Could you please help me again?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course, we'll help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest you include a check for existence of block name and data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#0000FF"&gt;(if&lt;/FONT&gt;
      &lt;FONT color="#0000FF"&gt;(and&lt;/FONT&gt;
	(setq NOME (getfiled "Open file" "" "TXT" (+ 2 4)))
        &lt;FONT color="#0000FF"&gt;(tblsearch "BLOCK" (setq blockname "DT"))&lt;/FONT&gt;
        &lt;FONT color="#0000FF"&gt;)&lt;/FONT&gt;
      &lt;FONT color="#0000FF"&gt;(progn&lt;/FONT&gt;
            (setq FD (open NOME "r"))
            ......

            (close FD)
      
&lt;FONT color="#0000FF"&gt;	(mapcar '(lambda (x y z a)
	               (_Insert&amp;amp;AddValue
	                     blockname
	                     (list x y 0.0)
	                     (list (itoa z) (itoa a)))
	               ) coordx  coordy code counter)
            );progn
      )&lt;/FONT&gt;&lt;BR /&gt;)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to convert the items in&amp;nbsp;&lt;EM&gt;code&lt;/EM&gt; and &lt;EM&gt;counter&lt;/EM&gt;&amp;nbsp;list to a string before passing them &amp;nbsp;to &lt;EM&gt;_Insert&amp;amp;AddValue &amp;nbsp;&lt;/EM&gt;unless of course yourre planning to&amp;nbsp;use the values for something else that requires a number&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also do it this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;.... &lt;BR /&gt;(setq CD1 (read CD))				; it is the attribute CODE

&lt;FONT color="#0000FF"&gt;	(_Insert&amp;amp;AddValue
                     blockname
                     (list nox1 noy1 0.0)
                     (list (itoa CD1) (itoa a1)))
		); while&lt;/FONT&gt;
      
          (close FD)&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;);progn&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;or even&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;...&lt;BR /&gt;(_Insert&amp;amp;AddValue
                     blockname
                     (list &lt;FONT color="#993300"&gt;(read nox)&lt;/FONT&gt; &lt;FONT color="#993300"&gt;(read noy)&lt;/FONT&gt; 0.0)
                     (list (itoa &lt;FONT color="#993300"&gt;(read CD)&lt;/FONT&gt;) (itoa &lt;FONT color="#993300"&gt;(read a)&lt;/FONT&gt;)))&lt;BR /&gt;...&lt;/PRE&gt;
&lt;P&gt;You know what i mean...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck&amp;nbsp;&lt;SPAN&gt;jean_rossini&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 18:50:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7291650#M116551</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2017-08-10T18:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert and edit attributes of a block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7292564#M116552</link>
      <description>&lt;P&gt;It works perfectly. Thanks for all the support and advices, I've learned a bunch of new approaches with your codes. I am really grateful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 02:46:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7292564#M116552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-11T02:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert and edit attributes of a block</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7292661#M116553</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;It works perfectly. Thanks for all the support and advices, I've learned a bunch of new approaches with your codes. I am really grateful.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You are welcome&amp;nbsp;&lt;SPAN&gt;jean_rossini, &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;We're happy to help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 04:34:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-insert-and-edit-attributes-of-a-block/m-p/7292661#M116553</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2017-08-11T04:34:34Z</dc:date>
    </item>
  </channel>
</rss>

