<?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: Stairs numbering LISP in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279295#M79168</link>
    <description>&lt;P&gt;Then try to better explain your goal.&lt;/P&gt;
&lt;P&gt;Use smaller dwg.&lt;/P&gt;
&lt;P&gt;Illustrate the initial state, whats doing the routine now and what do you want to have.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jan 2020 12:16:34 GMT</pubDate>
    <dc:creator>ВeekeeCZ</dc:creator>
    <dc:date>2020-01-28T12:16:34Z</dc:date>
    <item>
      <title>Stairs numbering LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279002#M79165</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I'm looking for a LISP to number stairs blocks in a incremental order.&lt;BR /&gt;I'm trying to modify a LISP I found on the web. This LISP is good, it modify the attributes in incremental sequence by sorting the blocks by its posiotions.&lt;BR /&gt;The only problem is that it does it on both Y and X axis, while I need only one axis at a time.&lt;BR /&gt;I belive it should be an easy task, but I could not succeed making the necesery changes, as I'm new to LISPs.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Lee&lt;/P&gt;&lt;PRE&gt;(progn
(defun c:incr (/ ent obj x i ST_STR)
 (command "._undo" "_be")
 ;;(SETQ ST_STR1 (GETSTRING "\nENTER STARTING NUMBER OF THE SEQUENCE(ANY ALPHABET/WORD)"))
 (SETQ ST_STR1 "")
 (SETQ ST_STR (GETSTRING "\nENTER STARTING NUMBER OF THE SEQUENCE(ANY INTEGER)"))
 (vl-load-com)
 (setq i 0)
 (prompt "\nSelect blocks")
 (SETQ BLOCK_LIST (ssget '((0 . "INSERT")))) ;;;;;;;; Jef!
 (SETQ BLOCK_LIST (FORM_SSSET BLOCK_LIST))
 (while (&amp;lt; I (LENGTH BLOCK_LIST))
   (SETQ ST_STR (STRCAT "" ST_STR))
    (SETQ TEMP_ELE (NTH 0 (ATTRIBUTE_EXTRACT (NTH I BLOCK_LIST))))
   (SETQ TEMP_ATTRIBUTE (STRCAT ST_STR1 ST_STR))
   (SETQ TEMP_TAG (NTH 0 TEMP_ELE))
   (MODIFY_ATTRIBUTES (NTH I BLOCK_LIST) (LIST TEMP_TAG) (LIST TEMP_ATTRIBUTE))
   (SETQ ST_STR (ITOA (+ (ATOI ST_STR) 1)))
   (setq i (+ i 1))

 )
 (command "._undo" "_e")

 (princ)
)

(DEFUN FORM_SSSET (SSSET / I TEMP_ELE LIST1)
 (SETQ I 0)
 (SETQ TEMP_ELE NIL)
 (SETQ LIST1 NIL_)
 (WHILE (&amp;lt; I (SSLENGTH SSSET))
   (SETQ TEMP_ELE (SSNAME SSSET I))
   (SETQ LIST1 (CONS TEMP_ELE LIST1))
   (SETQ I (+ I 1))
 )
(setq LIST1 (VL-SORT LIST1
          '(LAMBDA (X Y) (&amp;gt; (caddr(assoc 10 (entget X))) (caddr(assoc 10 (entget Y)))))
	      ))
 (setq LIST1 (VL-SORT LIST1
          '(LAMBDA (X Y) (&amp;lt; (cadr(assoc 10 (entget X))) (cadr(assoc 10 (entget Y)))))
	      ))
 (REVERSE LIST1)
)

(DEFUN ATTRIBUTE_EXTRACT (ENTNAME / ENT_OBJECT SAFEARRAY_SET I LIST1)
 (SETQ SAFEARRAY_SET NIL)
 (SETQ ENT_OBJECT ENTNAME)
 (SETQ ENT_OBJECT (VLAX-ENAME-&amp;gt;VLA-OBJECT ENT_OBJECT))
 (IF (vlax-property-available-p ENT_OBJECT "HASATTRIBUTES")
 (PROGN
 (SETQ	SAFEARRAY_SET
 (VLAX-SAFEARRAY-&amp;gt;LIST
   (VLAX-VARIANT-VALUE
     (VLAX-INVOKE-METHOD ENT_OBJECT "GETATTRIBUTES")
   )
 )
 )
 (SETQ I 0)
 (SETQ LIST1 NIL)
 (WHILE (&amp;lt; I (LENGTH SAFEARRAY_SET))
   (SETQ
     LIST1 (CONS
      (LIST
	(VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TAGSTRING")
	(VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TEXTSTRING")
      )
      LIST1
    )
   )
   (SETQ I (+ I 1))
 )
 (SETQ LIST1 (REVERSE LIST1))
 (SETQ LIST1 (SORT_FUN LIST1 0 0)))
   (SETQ LIST1 NIL)
   )LIST1
)

(DEFUN MODIFY_ATTRIBUTES (ENTNAME IDENTIFIER VALUE / TEMP_ELE ENT_OBJECT SAFEARRAY_SET I J)
 (SETQ SAFEARRAY_SET NIL)
 (SETQ ENT_OBJECT ENTNAME)
 (SETQ ENT_OBJECT (VLAX-ENAME-&amp;gt;VLA-OBJECT ENT_OBJECT))
 (IF (vlax-property-available-p ENT_OBJECT "HASATTRIBUTES")
 (PROGN
 (SETQ	SAFEARRAY_SET
 (VLAX-SAFEARRAY-&amp;gt;LIST
   (VLAX-VARIANT-VALUE
     (VLAX-INVOKE-METHOD ENT_OBJECT "GETATTRIBUTES")
   )
 )
 )
 (SETQ I 0)
 (SETQ J 0)
 (SETQ LIST1 NIL)
 (WHILE (&amp;lt; I (LENGTH SAFEARRAY_SET))
   (SETQ TEMP_ELE (VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TAGSTRING"))
   (IF (/= (VL-POSITION TEMP_ELE IDENTIFIER) NIL) (PROGN (VLAX-PUT-PROPERTY (NTH I SAFEARRAY_SET) "TEXTSTRING" (NTH (VL-POSITION TEMP_ELE IDENTIFIER) VALUE)) ))
   (SETQ I (+ I 1))
 )  
)))

(DEFUN SORT_FUN	(LIST1 FLAG1 FLAG2 /)
 (IF (= NIL (VL-CONSP (CAR LIST1)))
   (PROGN (SETQ LIST1 (INDEX_ADD LIST1))
   (SETQ LIST1
	  (VL-SORT LIST1
		   '(LAMBDA (X Y) (&amp;gt; (CADR X) (CADR Y)))
	  )
   )
   (SETQ LIST1 (MAPCAR '(LAMBDA (X) (CADR X)) LIST1))
   )
   (PROGN
     (IF (NOT (ATOM (NTH FLAG1 (NTH 0 LIST1))))
(SETQ LIST1
       (VL-SORT
	 LIST1
	 '(LAMBDA (X Y)
	    (&amp;gt; (NTH FLAG2 (NTH FLAG1 X)) (NTH FLAG2 (NTH FLAG1 Y)))
	  )
       )
)
(PROGN (SETQ LIST1
	      (VL-SORT LIST1
		       '(LAMBDA (X Y) (&amp;gt; (NTH FLAG2 X) (NTH FLAG2 Y)))
	      )
       )
)
     )
   )
 )
 LIST1
)
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 09:48:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279002#M79165</guid>
      <dc:creator>leeUT3Y6</dc:creator>
      <dc:date>2020-01-28T09:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stairs numbering LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279134#M79166</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5056892"&gt;@leeUT3Y6&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;BR /&gt;I'm looking for a LISP to number stairs blocks in a incremental order.&lt;BR /&gt;I'm trying to modify a LISP I found on the web. This LISP is good, it modify the attributes in incremental sequence by sorting the blocks by its posiotions.&lt;BR /&gt;The only problem is that it does it on both Y and X axis, while I need only one axis at a time.&lt;BR /&gt;I belive it should be an easy task, but I could not succeed making the necesery changes, as I'm new to LISPs.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Lee&lt;/P&gt;
&lt;PRE&gt;(progn
(defun c:incr (/ ent obj x i ST_STR)
 (command "._undo" "_be")
 ;;(SETQ ST_STR1 (GETSTRING "\nENTER STARTING NUMBER OF THE SEQUENCE(ANY ALPHABET/WORD)"))
 (SETQ ST_STR1 "")
 (SETQ ST_STR (GETSTRING "\nENTER STARTING NUMBER OF THE SEQUENCE(ANY INTEGER)"))
 (vl-load-com)
 (setq i 0)
 (prompt "\nSelect blocks")
 (SETQ BLOCK_LIST (ssget '((0 . "INSERT")))) ;;;;;;;; Jef!
 (SETQ BLOCK_LIST (FORM_SSSET BLOCK_LIST))
 (while (&amp;lt; I (LENGTH BLOCK_LIST))
   (SETQ ST_STR (STRCAT "" ST_STR))
    (SETQ TEMP_ELE (NTH 0 (ATTRIBUTE_EXTRACT (NTH I BLOCK_LIST))))
   (SETQ TEMP_ATTRIBUTE (STRCAT ST_STR1 ST_STR))
   (SETQ TEMP_TAG (NTH 0 TEMP_ELE))
   (MODIFY_ATTRIBUTES (NTH I BLOCK_LIST) (LIST TEMP_TAG) (LIST TEMP_ATTRIBUTE))
   (SETQ ST_STR (ITOA (+ (ATOI ST_STR) 1)))
   (setq i (+ i 1))

 )
 (command "._undo" "_e")

 (princ)
)

(DEFUN FORM_SSSET (SSSET / I TEMP_ELE LIST1)
 (SETQ I 0)
 (SETQ TEMP_ELE NIL)
 (SETQ LIST1 NIL_)
 (WHILE (&amp;lt; I (SSLENGTH SSSET))
   (SETQ TEMP_ELE (SSNAME SSSET I))
   (SETQ LIST1 (CONS TEMP_ELE LIST1))
   (SETQ I (+ I 1))
 )
&lt;FONT color="#FF0000"&gt;;(setq LIST1 (VL-SORT LIST1
;         '(LAMBDA (X Y) (&amp;gt; (caddr(assoc 10 (entget X))) (caddr(assoc 10 (entget Y)))))
;	      ))&lt;/FONT&gt;
&lt;FONT color="#0000FF"&gt; (setq LIST1 (VL-SORT LIST1
          '(LAMBDA (X Y) (&amp;lt; (cadr(assoc 10 (entget X))) (cadr(assoc 10 (entget Y)))))
	      ))&lt;/FONT&gt;
 (REVERSE LIST1)
)

(DEFUN ATTRIBUTE_EXTRACT (ENTNAME / ENT_OBJECT SAFEARRAY_SET I LIST1)
 (SETQ SAFEARRAY_SET NIL)
 (SETQ ENT_OBJECT ENTNAME)
 (SETQ ENT_OBJECT (VLAX-ENAME-&amp;gt;VLA-OBJECT ENT_OBJECT))
 (IF (vlax-property-available-p ENT_OBJECT "HASATTRIBUTES")
 (PROGN
 (SETQ	SAFEARRAY_SET
 (VLAX-SAFEARRAY-&amp;gt;LIST
   (VLAX-VARIANT-VALUE
     (VLAX-INVOKE-METHOD ENT_OBJECT "GETATTRIBUTES")
   )
 )
 )
 (SETQ I 0)
 (SETQ LIST1 NIL)
 (WHILE (&amp;lt; I (LENGTH SAFEARRAY_SET))
   (SETQ
     LIST1 (CONS
      (LIST
	(VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TAGSTRING")
	(VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TEXTSTRING")
      )
      LIST1
    )
   )
   (SETQ I (+ I 1))
 )
 (SETQ LIST1 (REVERSE LIST1))
 (SETQ LIST1 (SORT_FUN LIST1 0 0)))
   (SETQ LIST1 NIL)
   )LIST1
)

(DEFUN MODIFY_ATTRIBUTES (ENTNAME IDENTIFIER VALUE / TEMP_ELE ENT_OBJECT SAFEARRAY_SET I J)
 (SETQ SAFEARRAY_SET NIL)
 (SETQ ENT_OBJECT ENTNAME)
 (SETQ ENT_OBJECT (VLAX-ENAME-&amp;gt;VLA-OBJECT ENT_OBJECT))
 (IF (vlax-property-available-p ENT_OBJECT "HASATTRIBUTES")
 (PROGN
 (SETQ	SAFEARRAY_SET
 (VLAX-SAFEARRAY-&amp;gt;LIST
   (VLAX-VARIANT-VALUE
     (VLAX-INVOKE-METHOD ENT_OBJECT "GETATTRIBUTES")
   )
 )
 )
 (SETQ I 0)
 (SETQ J 0)
 (SETQ LIST1 NIL)
 (WHILE (&amp;lt; I (LENGTH SAFEARRAY_SET))
   (SETQ TEMP_ELE (VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TAGSTRING"))
   (IF (/= (VL-POSITION TEMP_ELE IDENTIFIER) NIL) (PROGN (VLAX-PUT-PROPERTY (NTH I SAFEARRAY_SET) "TEXTSTRING" (NTH (VL-POSITION TEMP_ELE IDENTIFIER) VALUE)) ))
   (SETQ I (+ I 1))
 )  
)))

(DEFUN SORT_FUN	(LIST1 FLAG1 FLAG2 /)
 (IF (= NIL (VL-CONSP (CAR LIST1)))
   (PROGN (SETQ LIST1 (INDEX_ADD LIST1))
   (SETQ LIST1
	  (VL-SORT LIST1
		   '(LAMBDA (X Y) (&amp;gt; (CADR X) (CADR Y)))
	  )
   )
   (SETQ LIST1 (MAPCAR '(LAMBDA (X) (CADR X)) LIST1))
   )
   (PROGN
     (IF (NOT (ATOM (NTH FLAG1 (NTH 0 LIST1))))
(SETQ LIST1
       (VL-SORT
	 LIST1
	 '(LAMBDA (X Y)
	    (&amp;gt; (NTH FLAG2 (NTH FLAG1 X)) (NTH FLAG2 (NTH FLAG1 Y)))
	  )
       )
)
(PROGN (SETQ LIST1
	      (VL-SORT LIST1
		       '(LAMBDA (X Y) (&amp;gt; (NTH FLAG2 X) (NTH FLAG2 Y)))
	      )
       )
)
     )
   )
 )
 LIST1
)
)&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;The red part sorts by Y, the blue one by X. Just turn the one you don't need off by adding semicolons, as I did.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 10:56:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279134#M79166</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-01-28T10:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Stairs numbering LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279270#M79167</link>
      <description>&lt;P&gt;I did the change as you suggested and it's still not working...&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 12:05:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279270#M79167</guid>
      <dc:creator>leeUT3Y6</dc:creator>
      <dc:date>2020-01-28T12:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Stairs numbering LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279295#M79168</link>
      <description>&lt;P&gt;Then try to better explain your goal.&lt;/P&gt;
&lt;P&gt;Use smaller dwg.&lt;/P&gt;
&lt;P&gt;Illustrate the initial state, whats doing the routine now and what do you want to have.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 12:16:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279295#M79168</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-01-28T12:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Stairs numbering LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279453#M79169</link>
      <description>&lt;P&gt;Ok, I'll try to be more specific.&lt;BR /&gt;Please see the dwg file attached on the first comment.&lt;BR /&gt;There are over 112 stairs blocks, which I 'd like thier attributes to start from 1 on the first stair, till 112 on the last stair block.&lt;BR /&gt;The original script was build to set the attribute this way:&lt;BR /&gt;&lt;SPAN&gt;att01 att04 att07&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;att02 att05 att08&lt;/P&gt;&lt;P&gt;att03 att06 att09&lt;BR /&gt;&lt;BR /&gt;I'd like to ignore the Y axis so the stairs will be only incremented by the X position.&lt;BR /&gt;So the result will be as:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;att03&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;att02&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;att01 &lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 13:18:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279453#M79169</guid>
      <dc:creator>leeUT3Y6</dc:creator>
      <dc:date>2020-01-28T13:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Stairs numbering LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279491#M79170</link>
      <description>&lt;P&gt;OK, then my prior suggestion was good, just the other way around.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remove the semicolons from the red ones, add them prior to blue ones.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 13:28:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279491#M79170</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2020-01-28T13:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Stairs numbering LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279500#M79171</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5056892"&gt;@leeUT3Y6&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5056892"&gt;@leeUT3Y6&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;...start from 1 on the first stair, till 112 on the last stair block.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You say from 1 to 112, yet you have 224 blocks in your provided drawing?&lt;/P&gt;&lt;P&gt;Also, all of them have the same attributes and numbering in them..&lt;/P&gt;&lt;P&gt;Also, there are 2 different blocks in your provided drawing..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate you trying to explain for us, but I believe in this case that it would help us greatly if you could provide us with a drawing that depicts the BEFORE and AFTER states of what you want. We could help you come to a solution much more effectively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 13:31:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9279500#M79171</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2020-01-28T13:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Stairs numbering LISP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9281654#M79172</link>
      <description>&lt;P&gt;Yessss! It works!&lt;BR /&gt;Thanks&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 08:08:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stairs-numbering-lisp/m-p/9281654#M79172</guid>
      <dc:creator>leeUT3Y6</dc:creator>
      <dc:date>2020-01-29T08:08:11Z</dc:date>
    </item>
  </channel>
</rss>

