<?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: ATTOUT help in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8910829#M86484</link>
    <description>&lt;P&gt;&lt;FONT size="4"&gt;I do not know if I understand correctly,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt; but here you change your selection set&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;(vla-startundomark adoc)

   &lt;FONT color="#FF0000"&gt;(setq ss (ssget '((0 . "INSERT")(2 . "&lt;STRONG&gt;TEST1&lt;/STRONG&gt;")))) ;;&amp;lt;&amp;lt;-here&lt;/FONT&gt;

    (setq axss (vla-get-activeselectionset adoc))&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT size="4"&gt;And here you can choose the directory of your file.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;&lt;FONT color="#FF0000"&gt;(setq fn (vl-filename-base ;|(getvar "dwgname")|; &lt;STRONG&gt;&amp;nbsp;"c:\\Desktop\DATA TEST\JUNK"&amp;nbsp;&lt;/STRONG&gt;)) ;;&amp;lt;&amp;lt;-here&lt;/FONT&gt; 
    (setq fname (strcat (getvar "dwgprefix") fn ".xls&lt;/FONT&gt;"))&lt;/PRE&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>Tue, 16 Jul 2019 00:15:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-07-16T00:15:05Z</dc:date>
    <item>
      <title>ATTOUT help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8910683#M86483</link>
      <description>&lt;P&gt;I'v modified this routine to fit my needs and as always i got stuck at filtering a specific block.&amp;nbsp; &amp;nbsp;I want the lisp to filter a specific block name &lt;STRONG&gt;"TEST1"&lt;/STRONG&gt;. at the moment it's selecting all blocks withing a window.&amp;nbsp; &amp;nbsp;also is there a way to change the path to open the excel file location? at the moment the default is to my document but i want it to default to a folder on my desktop&lt;STRONG&gt;&amp;nbsp;"Desktop\DATA TEST\JUNK".&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;;;  Groups elements in sublist by criteria

(defun subtrack (test lst)
(apply 'append (mapcar '(lambda (x)
(if (eq (car x) test)(list x))) lst)))

;;  Counts equivalent subs in list

(defun countsub	(lst sub)
  (cond	((null lst) 0)
	((and (equal (caar lst) (car sub) 0.00001)
	      (equal (cadar lst) (cadr sub) 0.00001)
	 )
	 (1+ (countsub (cdr lst) sub))
	)
	(T (countsub (cdr lst) sub))
  )
)
;;  Get info from block include from constant attributes in following form:
;; (("TAG1" . "VALUE1") ("TAG2" . "VALUE2") ...("*CONSTANT*: TAGN" . "VALUEN"))

  (defun get-all-atts (obj / atts att_list const_atts const_list ent)
    (and
	 (if (and obj 
		  (vlax-property-available-p obj 'Hasattributes)
		  (eq :vlax-true (vla-get-hasattributes obj))
	     )
	   (progn
	     (setq atts (vlax-invoke obj 'Getattributes))
	     (foreach att atts
	       (setq att_list
		      (cons (cons (vla-get-tagstring att)
				  (vla-get-textstring att)
			    )
			    att_list
		      )
	       )
	     )
	   )
	 )
    )
    (cond ((vlax-method-applicable-p obj 'Getconstantattributes)
	   (setq const_atts (vlax-invoke obj 'Getconstantattributes))
	   (foreach att	const_atts
	     (setq const_list
		    (cons (cons	(vla-get-tagstring att)
				(vla-get-textstring att)
			  )
			  const_list
		    )
	     )
	   )
	   (setq att_list (reverse (append const_list att_list)))
	  )
	  (T (reverse att_list))
    )
  )

;;			Main part			;;
  (defun C:ATOUT (/	 acsp	  adoc	   aexc	    awb	     axss
		bname	 cll	  colm	   com_data csht     data
		exc_data fname	  header_list	    info     nwb
		osm	 row	  sht	   ss	    str1     str2
		subtot	 tmp_data tmp_get  tmp_snip tot
	       )

    (vl-load-com)
    (setq adoc (vla-get-activedocument
		 (vlax-get-acad-object)
	       )
	  acsp (vla-get-modelspace adoc)
    )
    (setq osm (getvar "osmode"))
    (setvar "osmode" 0)
    (setvar "cmdecho" 0)
    (vla-endundomark adoc)
    (vla-startundomark adoc)

    ;;    variations of the selection
    ;;  All blocks :
        (setq ss (ssget (list (cons 0 "INSERT")(cons 66 1))))
    ;;	Selected on screen:
;;;(setq ss (ssget '((0 . "INSERT"))))
    ;; All blocks by name:
;;;    (setq bname (getstring "\n	***	Block name:\n"))
;;;    (setq ss (ssget "_X" (list (cons 0 "INSERT")(cons 66 1) (cons 2 bname))))
    (setq axss (vla-get-activeselectionset adoc))
    (setq com_data nil)				  ;for debug only

    (vlax-for a	axss
      (setq tmp_get (get-all-atts a))
      (setq tmp_data (append (list (vla-get-name a)(vla-get-handle a)) tmp_get))
      (setq com_data (cons tmp_data com_data))
      (setq tmp_data nil)
    )						  ;ok
    (setq tot (length com_data))
    (setq exc_data nil)				  ;for debug only
    (while com_data
      (setq tmp_snip
	     (subtrack (caar com_data) com_data)
      )
      (setq str1 (strcat "Subtotal blocks "
			 "\"" (caar com_data) "\""
                         ": "
		 )
	    str2
		 (itoa (length tmp_snip))
      )
      (setq exc_data (append exc_data
			     (list (append tmp_snip (list (list str2 str1))))
		     )
	    com_data (vl-remove-if
		       (function not)
		       (mapcar (function (lambda (x)
					   (if (not (member x tmp_snip))
					     x
					   )
					 )
			       )
			       com_data
		       )
		     )
	    tmp_snip nil
      )
    )
    (setq exc_data
           (mapcar (function (lambda (x)
               (mapcar (function (lambda (y)                
                   (append (list (cadr y)(car y))(cddr y))))
                       x
                       )
                               )
                             )
                   exc_data)
                   )
    ;;		Eof calc part		;;

    ;;	***	Excel part	***	;;
    (setq fn (vl-filename-base (getvar "dwgname")))
    (setq fname (strcat (getvar "dwgprefix") fn ".xls"))
    
    (setq fname (open fname "W"))
    (close fname)
    (alert (strcat "Select file " "\"" (strcat fn ".xls") "\""))
    (setq fname (getfiled "Excel Spreadsheet File" "" "XLS" 8))
    (setq fname (findfile fname))
    ;;; Excel part written by  ALEJANDRO LEGUIZAMON -  http://arquingen.tripod.com.co  
    (setq aexc (vlax-get-or-create-object "Excel.Application")
	  awb  (vlax-get-property aexc "Workbooks")
	  nwb  (vlax-invoke-method awb "Open" fname)
	  sht  (vlax-get-property nwb "Sheets")
	  csht (vlax-get-property sht "Item" 1)
	  cll  (vlax-get-property csht "Cells")
    )
    (vlax-put-property csht 'Name "AttOut-AttIn")
    (vla-put-visible aexc :vlax-true)
    (setq row 1
	  colm 1
    )
    (setq header_list
           '("HANDLE"
             "BLOCK NAME"
             "TAG1"
             "TAG2"
             "TAG3"
             "TAG4"
             "TAG5"
             "TAG6"
             "TAG7"
             "TAG8"
             "TAG9"
             "TAG10"
            )
    ) ;_ end of setq
    (repeat (length header_list)
      (vlax-put-property
	cll
	"Item"
	row
	colm
	(vl-princ-to-string (car header_list))
      )
      (setq colm (1+ colm)
	    header_list
	     (cdr header_list)
      )
    )
    (setq row 2
	  colm 1
    )
    (repeat (length exc_data)
      (setq data   (reverse (cdr (reverse (car exc_data))))
	    subtot (last (car exc_data))
      )
      (repeat (length data)
	(setq info (car data))
	(repeat	(length info)
	  (vlax-put-property
	    cll
	    "Item"
	    row
	    colm
            (if (&amp;lt; colm 3)
	    (vl-princ-to-string (car info))
            (vl-princ-to-string (cdar info)))
	  )
	  (setq colm (1+ colm))
	  (setq info (cdr info))
	)
        (setq data (cdr data))
	(setq row  (1+ row)
	      colm 1
	)
      )

      (vlax-put-property
	cll
	"Item"
	row
	colm
	(vl-princ-to-string (car subtot))
      )
      (setq colm (1+ colm))
      (vlax-put-property
	cll
	"Item"
	row
	colm
	(vl-princ-to-string (cadr subtot))
      )

      (setq exc_data (cdr exc_data))
      (setq row	 (1+ row)
	    colm 1
      )
    )

    (setq row  (1+ row)
	  colm 1
    )
    (vlax-put-property
      cll
      "Item"
      row
      colm
      (vl-princ-to-string "TOTAL BLOCKS:")
    )
    (setq colm (1+ colm))
    (vlax-put-property
      cll
      "Item"
      row
      colm
      (vl-princ-to-string tot)
    )
   (setq fcol (vlax-get-property csht "Range" "A:Z"))
   (vlax-put-property fcol "NumberFormat" "@")
;;;        Columns("A:A").Select
;;;    Range("A394").Activate
;;;    Selection.NumberFormat = "@"
    (vlax-invoke (vlax-get-property csht "Columns") "AutoFit")
    (vlax-release-object cll)
    (vlax-release-object fcol)
    (vlax-release-object csht)
    (vlax-release-object sht)
    (vlax-release-object nwb)
    (vlax-release-object awb)
    (vlax-release-object aexc)
    (setq aexc nil)
    (setvar "osmode" osm)
    (setvar "cmdecho" 1)
    (vla-clear axss)
    (vlax-release-object axss)
    (vla-regen adoc acactiveviewport)
    (vla-endundomark adoc)
    (gc)
    (gc)
    (alert "Save Excel manually")
    (princ)
    )
(princ "\n\t\t***\tStart command with ATOUT...\t***")
(princ)&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jul 2019 21:28:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8910683#M86483</guid>
      <dc:creator>3arizona</dc:creator>
      <dc:date>2019-07-15T21:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: ATTOUT help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8910829#M86484</link>
      <description>&lt;P&gt;&lt;FONT size="4"&gt;I do not know if I understand correctly,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt; but here you change your selection set&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;(vla-startundomark adoc)

   &lt;FONT color="#FF0000"&gt;(setq ss (ssget '((0 . "INSERT")(2 . "&lt;STRONG&gt;TEST1&lt;/STRONG&gt;")))) ;;&amp;lt;&amp;lt;-here&lt;/FONT&gt;

    (setq axss (vla-get-activeselectionset adoc))&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT size="4"&gt;And here you can choose the directory of your file.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;&lt;FONT color="#FF0000"&gt;(setq fn (vl-filename-base ;|(getvar "dwgname")|; &lt;STRONG&gt;&amp;nbsp;"c:\\Desktop\DATA TEST\JUNK"&amp;nbsp;&lt;/STRONG&gt;)) ;;&amp;lt;&amp;lt;-here&lt;/FONT&gt; 
    (setq fname (strcat (getvar "dwgprefix") fn ".xls&lt;/FONT&gt;"))&lt;/PRE&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>Tue, 16 Jul 2019 00:15:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8910829#M86484</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-16T00:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: ATTOUT help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8911054#M86485</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4825508"&gt;@3arizona&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I'v modified this routine to fit my needs and as always i got stuck at filtering a specific block.&amp;nbsp; &amp;nbsp;I want the lisp to filter a specific block name &lt;STRONG&gt;"TEST1"&lt;/STRONG&gt;. at the moment it's selecting all blocks withing a window.&amp;nbsp; &amp;nbsp;also is there a way to change the path to open the excel file location? at the moment the default is to my document but i want it to default to a folder on my desktop&lt;STRONG&gt;&amp;nbsp;"Desktop\DATA TEST\JUNK".&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. For First part, Specific Block selection go as per&amp;nbsp;@Anonymous&amp;nbsp;.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. For Second Part I think you can try with this changes.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;.......
    ;;	***	Excel part	***	;;
    (setq fn (vl-filename-base (getvar "dwgname")))
    ;(setq fname (strcat (getvar "dwgprefix") fn ".xls"))
    (setq fname (strcat "&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;C:/Users/XXXXXXX/Desktop/DATA/TEST/JUNK/&lt;/FONT&gt;&lt;/STRONG&gt;" fn ".xls"))&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;; Put the Path of Destination Folder for *.xls File&lt;/STRONG&gt;&lt;/FONT&gt;
    (setq fname (open fname "W"))
    (close fname)
    (alert (strcat "Select file " "\"" (strcat fn ".xls") "\""))
    (setq fname (getfiled "Excel Spreadsheet File" "&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;C:/Users/XXXXXXX/Desktop/DATA/TEST/JUNK/&lt;/FONT&gt;&lt;/STRONG&gt;" "XLS" 8))&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;; Put the Path of that Folder containing that *.xls File&lt;/STRONG&gt;&lt;/FONT&gt;
    ;(setq fname (findfile fname))
    ;;; Excel part written by  ALEJANDRO LEGUIZAMON -  http://arquingen.tripod.com.co  &lt;BR /&gt;.......&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 16 Jul 2019 05:10:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8911054#M86485</guid>
      <dc:creator>dbhunia</dc:creator>
      <dc:date>2019-07-16T05:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: ATTOUT help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8912533#M86486</link>
      <description>&lt;P&gt;&amp;nbsp;dbhunia&lt;/P&gt;&lt;P&gt;is there a way change the path for other USERS (xxxxxx)?&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;C:/Users/other users/Desktop/DATA TEST/JUNK/&lt;/FONT&gt;&lt;/STRONG&gt;"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 17:35:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8912533#M86486</guid>
      <dc:creator>3arizona</dc:creator>
      <dc:date>2019-07-16T17:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: ATTOUT help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8912539#M86487</link>
      <description>&lt;DIV class="lia-message-author-with-avatar"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Advisor lia-component-message-view-widget-author-username"&gt;&amp;nbsp;Frjuniornogueira,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-message-author-with-avatar"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-message-author-with-avatar"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Advisor lia-component-message-view-widget-author-username"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-message-author-with-avatar"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-message-author-with-avatar"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Block selection part works perfect!!!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 17:39:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8912539#M86487</guid>
      <dc:creator>3arizona</dc:creator>
      <dc:date>2019-07-16T17:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: ATTOUT help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8913495#M86488</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4825508"&gt;@3arizona&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&amp;nbsp;dbhunia&lt;/P&gt;&lt;P&gt;is there a way &lt;FONT color="#FF0000"&gt;change the path for other USERS&lt;/FONT&gt; (xxxxxx)?&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;C:/Users/other users/Desktop/DATA TEST/JUNK/&lt;/FONT&gt;&lt;/STRONG&gt;"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try with this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;............&lt;BR /&gt;    ;;	***	Excel part	***	;;
    (setq fn (vl-filename-base (getvar "dwgname")))
    &lt;FONT color="#0000FF"&gt;(setq path (strcat "C:/Users/" (getenv "UserName") "/Desktop/DATA TEST/JUNK/"))&lt;/FONT&gt;
    (setq fname (strcat &lt;FONT color="#0000FF"&gt;path&lt;/FONT&gt; fn ".xls"))
    (setq fname (open fname "W"))
    (close fname)
    (alert (strcat "Select file " "\"" (strcat fn ".xls") "\""))
    (setq fname (getfiled "Excel Spreadsheet File" &lt;FONT color="#0000FF"&gt;path&lt;/FONT&gt; "XLS" 8))
    ;;; Excel part written by  ALEJANDRO LEGUIZAMON -  http://arquingen.tripod.com.co  &lt;BR /&gt;............&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jul 2019 05:26:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8913495#M86488</guid>
      <dc:creator>dbhunia</dc:creator>
      <dc:date>2019-07-17T05:26:05Z</dc:date>
    </item>
    <item>
      <title>Re: ATTOUT help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8915776#M86489</link>
      <description>&lt;P&gt;Works, thanks!!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 21:58:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/attout-help/m-p/8915776#M86489</guid>
      <dc:creator>3arizona</dc:creator>
      <dc:date>2019-07-17T21:58:48Z</dc:date>
    </item>
  </channel>
</rss>

