<?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: AutoLisp loop not selecting block when looping in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8637079#M91829</link>
    <description>&lt;P&gt;My bad. Please see the the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun c:upd (/ _delFinder ss e a data b attrvalues)&lt;/P&gt;
&lt;P&gt;(foreach layout (layoutlist)&lt;BR /&gt;(setvar "ctab" layout)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;;;; pBe 21July2014 ;;; &lt;BR /&gt;(defun _delFinder (str md / d l str)&lt;BR /&gt;(while (setq d (vl-string-position md str nil T))&lt;BR /&gt;(setq l (cons (substr str (+ 2 d)) l)&lt;BR /&gt;str (substr str 1 d)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(cons str l)&lt;BR /&gt;)&lt;BR /&gt;(if (and (setq a nil&lt;BR /&gt;data nil&lt;BR /&gt;ss (ssget&lt;BR /&gt;"_:L:S"&lt;BR /&gt;'((0 . "INSERT") (2 . "INDESCO_A1A,`*U*"))&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(eq (vla-get-effectivename&lt;BR /&gt;(setq e (vlax-ename-&amp;gt;vla-object (ssname ss 0)))&lt;BR /&gt;)&lt;BR /&gt;"INDESCO_A1A"&lt;BR /&gt;)&lt;BR /&gt;(setq fn (findfile "RootData.csv"))&lt;BR /&gt;)&lt;BR /&gt;(progn&lt;BR /&gt;(setq of (open fn "r"))&lt;BR /&gt;(while (setq a (read-line of))&lt;BR /&gt;(setq data (cons (_delFinder a 44) data))&lt;BR /&gt;)&lt;BR /&gt;(close of)&lt;BR /&gt;(setq attrvalues&lt;BR /&gt;(vl-remove-if&lt;BR /&gt;'(lambda (v)&lt;BR /&gt;(member (Car v)&lt;BR /&gt;'("LOCATION_ID"&lt;BR /&gt;"PIPE_SIZE"&lt;BR /&gt;"LENGTH_(IN.)"&lt;BR /&gt;"FINISH"&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(mapcar '(lambda (at)&lt;BR /&gt;(list (strcase (vla-get-tagstring at))&lt;BR /&gt;(vla-get-textstring at)&lt;BR /&gt;at&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(vlax-invoke e 'Getattributes)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(if (setq b (assoc (cadr (assoc "DRAWING_NO" attrvalues)) data))&lt;BR /&gt;(mapcar '(lambda (j h)&lt;BR /&gt;(vla-put-textstring (last j) h)&lt;BR /&gt;)&lt;BR /&gt;(cdr attrvalues)&lt;BR /&gt;(cdr b)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(princ)&lt;/P&gt;
&lt;P&gt;);foreach&lt;BR /&gt;)&lt;BR /&gt;(vl-load-com)&lt;/P&gt;</description>
    <pubDate>Tue, 05 Mar 2019 12:41:54 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-03-05T12:41:54Z</dc:date>
    <item>
      <title>AutoLisp loop not selecting block when looping</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8637053#M91827</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I am very new to this and have got something that almost works but just one hiccup. I've got an excel spreadsheet to update the attribute block in multiple layouts but have to select the block for each layout for it to work.&lt;BR /&gt;&lt;BR /&gt;Whenever I run the AutoLisp, it will prompt me to select my block individually as it loops between the layout pages. I just want it to automatically select the block as they are named the same.&lt;BR /&gt;&lt;BR /&gt;Could anyone please help me on this? I have no knowledge in writing the code and can only make a little sense of it. I managed to get this far by just combining a few things I found. Hoping to slowly learn more.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:upd (/ _delFinder ss e a data b attrvalues)

(foreach layout (layoutlist)
  (setvar "ctab" layout)
  
  
;;;	pBe 21July2014	;;; 
  (defun _delFinder (str md / d l str)
    (while (setq d (vl-string-position md str nil T))
      (setq l	(cons (substr str (+ 2 d)) l)
	    str	(substr str 1 d)
      )
    )
    (cons str l)
  )
  (if (and (setq a    nil
		 data nil
		 ss   (ssget
			"_:L:S"
			'((0 . "INSERT") (2 . "INDESCO_A1A,`*U*"))
		      )
	   )
	   (eq (vla-get-effectivename
		 (setq e (vlax-ename-&amp;gt;vla-object (ssname ss 0)))
	       )
	       "INDESCO_A1A"
	   )
	   (setq fn (findfile "RootData.csv"))
      )
    (progn
      (setq of (open fn "r"))
      (while (setq a (read-line of))
	(setq data (cons (_delFinder a 44) data))
      )
      (close of)
      (setq attrvalues
	     (vl-remove-if
	       '(lambda	(v)
		  (member (Car v)
			  '("LOCATION_ID"
			    "PIPE_SIZE"
			    "LENGTH_(IN.)"
			    "FINISH"
			   )
		  )
		)
	       (mapcar '(lambda	(at)
			  (list	(strcase (vla-get-tagstring at))
				(vla-get-textstring at)
				at
			  )
			)
		       (vlax-invoke e 'Getattributes)
	       )
	     )
      )
      (if (setq b (assoc (cadr (assoc "DRAWING_NO" attrvalues)) data))
	(mapcar	'(lambda (j h)
		   (vla-put-textstring (last j) h)
		 )
		(cdr attrvalues)
		(cdr b)
	)
      )
    )
  )
  (princ)

  );foreach
)
(vl-load-com)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 12:54:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8637053#M91827</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-03-05T12:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: AutoLisp loop not selecting block when looping</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8637072#M91828</link>
      <description>&lt;P&gt;You didn't post any code to see...&lt;/P&gt;
&lt;P&gt;Anyway, did you try&amp;nbsp;&lt;A href="http://www.lee-mac.com/updatetitleblock.html" target="_blank" rel="noopener"&gt;THIS&lt;/A&gt;&amp;nbsp;Lee's code to update titleblocks?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 12:38:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8637072#M91828</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2019-03-05T12:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: AutoLisp loop not selecting block when looping</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8637079#M91829</link>
      <description>&lt;P&gt;My bad. Please see the the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(defun c:upd (/ _delFinder ss e a data b attrvalues)&lt;/P&gt;
&lt;P&gt;(foreach layout (layoutlist)&lt;BR /&gt;(setvar "ctab" layout)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;;;; pBe 21July2014 ;;; &lt;BR /&gt;(defun _delFinder (str md / d l str)&lt;BR /&gt;(while (setq d (vl-string-position md str nil T))&lt;BR /&gt;(setq l (cons (substr str (+ 2 d)) l)&lt;BR /&gt;str (substr str 1 d)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(cons str l)&lt;BR /&gt;)&lt;BR /&gt;(if (and (setq a nil&lt;BR /&gt;data nil&lt;BR /&gt;ss (ssget&lt;BR /&gt;"_:L:S"&lt;BR /&gt;'((0 . "INSERT") (2 . "INDESCO_A1A,`*U*"))&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(eq (vla-get-effectivename&lt;BR /&gt;(setq e (vlax-ename-&amp;gt;vla-object (ssname ss 0)))&lt;BR /&gt;)&lt;BR /&gt;"INDESCO_A1A"&lt;BR /&gt;)&lt;BR /&gt;(setq fn (findfile "RootData.csv"))&lt;BR /&gt;)&lt;BR /&gt;(progn&lt;BR /&gt;(setq of (open fn "r"))&lt;BR /&gt;(while (setq a (read-line of))&lt;BR /&gt;(setq data (cons (_delFinder a 44) data))&lt;BR /&gt;)&lt;BR /&gt;(close of)&lt;BR /&gt;(setq attrvalues&lt;BR /&gt;(vl-remove-if&lt;BR /&gt;'(lambda (v)&lt;BR /&gt;(member (Car v)&lt;BR /&gt;'("LOCATION_ID"&lt;BR /&gt;"PIPE_SIZE"&lt;BR /&gt;"LENGTH_(IN.)"&lt;BR /&gt;"FINISH"&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(mapcar '(lambda (at)&lt;BR /&gt;(list (strcase (vla-get-tagstring at))&lt;BR /&gt;(vla-get-textstring at)&lt;BR /&gt;at&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(vlax-invoke e 'Getattributes)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(if (setq b (assoc (cadr (assoc "DRAWING_NO" attrvalues)) data))&lt;BR /&gt;(mapcar '(lambda (j h)&lt;BR /&gt;(vla-put-textstring (last j) h)&lt;BR /&gt;)&lt;BR /&gt;(cdr attrvalues)&lt;BR /&gt;(cdr b)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(princ)&lt;/P&gt;
&lt;P&gt;);foreach&lt;BR /&gt;)&lt;BR /&gt;(vl-load-com)&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 12:41:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8637079#M91829</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-03-05T12:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: AutoLisp loop not selecting block when looping</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8637122#M91830</link>
      <description>&lt;P&gt;Try this.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:upd (/ _delFinder ss e a data b attrvalues)

(foreach layout (layoutlist)
  (setvar "ctab" layout)
  
  
;;;	pBe 21July2014	;;; 
  (defun _delFinder (str md / d l str)
    (while (setq d (vl-string-position md str nil T))
      (setq l	(cons (substr str (+ 2 d)) l)
	    str	(substr str 1 d)
      )
    )
    (cons str l)
  )
  (if (and (setq a    nil
		 data nil
		 ss   (ssget "_A" (list '(0 . "INSERT") '(2 . "INDESCO_A1A,`*U*")(cons 410 (getvar "ctab")))))
	   )
	   (eq (vla-get-effectivename
		 (setq e (vlax-ename-&amp;gt;vla-object (ssname ss 0)))
	       )
	       "INDESCO_A1A"
	   )
	   (setq fn (findfile "RootData.csv"))
      )
    (progn
      (setq of (open fn "r"))
      (while (setq a (read-line of))
	(setq data (cons (_delFinder a 44) data))
      )
      (close of)
      (setq attrvalues
	     (vl-remove-if
	       '(lambda	(v)
		  (member (Car v)
			  '("LOCATION_ID"
			    "PIPE_SIZE"
			    "LENGTH_(IN.)"
			    "FINISH"
			   )
		  )
		)
	       (mapcar '(lambda	(at)
			  (list	(strcase (vla-get-tagstring at))
				(vla-get-textstring at)
				at
			  )
			)
		       (vlax-invoke e 'Getattributes)
	       )
	     )
      )
      (if (setq b (assoc (cadr (assoc "DRAWING_NO" attrvalues)) data))
	(mapcar	'(lambda (j h)
		   (vla-put-textstring (last j) h)
		 )
		(cdr attrvalues)
		(cdr b)
	)
      )
    )
  )
  (princ)

  );foreach
)
(vl-load-com)&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2019 13:04:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8637122#M91830</guid>
      <dc:creator>dbhunia</dc:creator>
      <dc:date>2019-03-05T13:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: AutoLisp loop not selecting block when looping</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8639240#M91831</link>
      <description>&lt;P&gt;Sorry it my mistake, Try this.......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:upd (/ _delFinder ss e a data b attrvalues)

(foreach layout (layoutlist)
  (setvar "ctab" layout)
  
  
;;;	pBe 21July2014	;;; 
  (defun _delFinder (str md / d l str)
    (while (setq d (vl-string-position md str nil T))
      (setq l	(cons (substr str (+ 2 d)) l)
	    str	(substr str 1 d)
      )
    )
    (cons str l)
  )
  (if (and (setq a    nil
		 data nil
		 ss   (ssget
			"_A"
			(list '(0 . "INSERT") '(2 . "INDESCO_A1A,`*U*") (cons 410 (getvar "ctab")))
		      )
	   )
	   (eq (vla-get-effectivename
		 (setq e (vlax-ename-&amp;gt;vla-object (ssname ss 0)))
	       )
	       "INDESCO_A1A"
	   )
	   (setq fn (findfile "RootData.csv"))
      )
    (progn
      (setq of (open fn "r"))
      (while (setq a (read-line of))
	(setq data (cons (_delFinder a 44) data))
      )
      (close of)
      (setq attrvalues
	     (vl-remove-if
	       '(lambda	(v)
		  (member (Car v)
			  '("LOCATION_ID"
			    "PIPE_SIZE"
			    "LENGTH_(IN.)"
			    "FINISH"
			   )
		  )
		)
	       (mapcar '(lambda	(at)
			  (list	(strcase (vla-get-tagstring at))
				(vla-get-textstring at)
				at
			  )
			)
		       (vlax-invoke e 'Getattributes)
	       )
	     )
      )
      (if (setq b (assoc (cadr (assoc "DRAWING_NO" attrvalues)) data))
	(mapcar	'(lambda (j h)
		   (vla-put-textstring (last j) h)
		 )
		(cdr attrvalues)
		(cdr b)
	)
      )
    )
  )
  (princ)

  );foreach
)
(vl-load-com)&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Mar 2019 07:49:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8639240#M91831</guid>
      <dc:creator>dbhunia</dc:creator>
      <dc:date>2019-03-06T07:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: AutoLisp loop not selecting block when looping</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8643955#M91832</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could anyone please help me on this? I have no knowledge in writing the code and can only make a little sense of it. I managed to get this far by just combining a few things I found. Hoping to slowly learn more.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. We wont&amp;nbsp;use (layoutlist)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. We put the name of the TAG with the value after reading the CSV&lt;/P&gt;
&lt;P&gt;3. We will use the layout tab name to identify what values go with block "INDESCO_A1A"&lt;/P&gt;
&lt;P&gt;[ Note: Suggest to use field value CTAB for "DRAWING_NO" tag. if you decide&amp;nbsp;to go with that, we will need to change one item on the code ]&lt;/P&gt;
&lt;P&gt;This&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(setq f (assoc (vla-get-tagstring at) &lt;STRONG&gt;&lt;FONT color="#808000"&gt;Found&lt;/FONT&gt;&lt;/STRONG&gt;))&lt;/PRE&gt;
&lt;P&gt;To this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(setq f (assoc (vla-get-tagstring at) &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;(Cdr Found)&lt;/FONT&gt;&lt;/STRONG&gt;))&lt;/PRE&gt;
&lt;P&gt;Here you go [ using layout name as an identifier&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:upd (/ _delFinder fn ss e i of a data found layoutname)

;;;	pBe 21July2019	;;;   

(defun _delFinder (str md / d l str)
    (while (setq d (vl-string-position md str nil T))
      (setq l	(cons (substr str (+ 2 d)) l)
	    str	(substr str 1 d)
      )
    )
    (cons str l)
  )

	(if
          (and
            (setq data nil  fn (findfile "RootData.csv"))
            (setq ss  (ssget &lt;FONT color="#0000FF"&gt;"_X"&lt;/FONT&gt; '((0 . "INSERT") (2 . "INDESCO_A1A,`*U*")(410 . "~Model")))
		      )
              )
          (progn

	&lt;FONT color="#0000FF"&gt;;;;		Read the CSV file			;;;&lt;/FONT&gt;
            
      		(setq of (open fn "r"))
		      (while (setq a (read-line of))
			(setq data (cons (_delFinder a 44) data))
		      )
      		(close of)
            
	&lt;FONT color="#0000FF"&gt;;;;		Combine Tag and Value			;;;&lt;/FONT&gt;
            
            	(setq data (reverse data) tag  (car data) data  (Cdr data))
		(setq data (mapcar '(lambda (v)
                   		(mapcar 'list  tag v )) data))

	&lt;FONT color="#0000FF"&gt;;;;	Modify block as per layout tab name		;;;&lt;/FONT&gt;
                       	
            (repeat (setq i (sslength ss))              
              (setq layoutname (cdr (assoc 410 (entget
                                                 (setq e (ssname ss (setq i (1- i))))))))
              
              	(if (and
                      (eq (vla-get-effectivename
                            (setq e (vlax-ename-&amp;gt;vla-object e))) "INDESCO_A1A")
                      (setq Found (vl-some '(lambda (At)
                                  (if (assoc layoutname (mapcar 'reverse at))
						At)) data))
                      )
                  (Foreach at (vlax-invoke e 'Getattributes)
			  (if (setq f (assoc (vla-get-tagstring at) Found))
                            	(vla-put-textstring at (cadr f)))
			) 
	       	)
              )
            )
          )
            (princ)
            )&lt;/PRE&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 20:15:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-loop-not-selecting-block-when-looping/m-p/8643955#M91832</guid>
      <dc:creator>pbejse</dc:creator>
      <dc:date>2019-03-07T20:15:47Z</dc:date>
    </item>
  </channel>
</rss>

