<?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: Lisp to divide total selected dimensions by given amount in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060916#M28078</link>
    <description>&lt;P&gt;sure. find update above.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jun 2023 13:39:19 GMT</pubDate>
    <dc:creator>komondormrex</dc:creator>
    <dc:date>2023-06-26T13:39:19Z</dc:date>
    <item>
      <title>Lisp to divide total selected dimensions by given amount</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12055533#M28071</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a lisp below which can total the selected dimensions, but I would like to add the following feature, after the total is shown the user has the option to divide the total by the inputted amount and display that amount.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would also be nice to have the dimensions turn blue (as in selected) when selecting each dimension as currently you cant visibly see which dims are selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help much appreciated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;;;=======================[ Length.lsp ]=========================&lt;BR /&gt;;;; Author: Copyright© 2005-2008 Charles Alan Butler&lt;BR /&gt;;;; Version: 1.1 Mar. 04,2008&lt;BR /&gt;;;; Purpose: display the length of a selected objects&lt;BR /&gt;;;; and a running total, objects supported:&lt;BR /&gt;;;; LINE, LWPOLYLINE, POLYLINE, SPLINE, ARC, CIRCLE, DIMENSION&lt;BR /&gt;;;; Sub_Routines: put_txt add text to dwg&lt;BR /&gt;;;; Returns: -NA&lt;BR /&gt;;;;==============================================================&lt;BR /&gt;;|&lt;BR /&gt;I know there are many fine "Length" routines around.&lt;BR /&gt;This is my version and it allows the user to pick each object &amp;amp; displays&lt;BR /&gt;the length &amp;amp; a running total on the command line.&lt;BR /&gt;An option at start up lets the user optionally put the result in the drawing.&lt;BR /&gt;The text is placed at the user pick point and the current text style &amp;amp; layer are used.&lt;BR /&gt;The options for text insert are:&lt;BR /&gt;None - No text is inserted, this is the default&lt;BR /&gt;Each - Text is inserted after each object is selected&lt;BR /&gt;Total - Text is inserted only at the end of all selections &amp;amp; only the total is inserted.&lt;/P&gt;&lt;P&gt;Exit the routine by pressing Enter or picking nothing&lt;BR /&gt;Pressing C enter will clear the total&lt;BR /&gt;Pressing U enter will remove the last object&lt;BR /&gt;Pressing Enter while placing the text will skip the insert for that object.&lt;BR /&gt;|;&lt;BR /&gt;(defun c:length (/ en len pt txt ent_allowed total_len typ obj usercmd LenList NewTxt)&lt;BR /&gt;(vl-load-com)&lt;BR /&gt;(setq usercmd (getvar "CMDECHO"))&lt;BR /&gt;(setvar "CMDECHO" 0)&lt;BR /&gt;(defun put_txt (txt / pt)&lt;BR /&gt;;; Check if the drawing height is set to 0:&lt;BR /&gt;(if (setq pt (getpoint "\nPick Text Location..."))&lt;BR /&gt;(progn&lt;BR /&gt;(if (= 0 (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))&lt;BR /&gt;(command "text" "non" pt "" "0" txt)&lt;BR /&gt;(command "text" "non" pt "0" txt)&lt;BR /&gt;)&lt;BR /&gt;(entlast) ; return ename&lt;BR /&gt;)&lt;BR /&gt;(prompt "\n*** Text Insert skipped ***")&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;(initget "Each Total None" )&lt;BR /&gt;(setq txt_opt (getkword "\nPut text in drawing for [Each/Total/None]. &amp;lt;None&amp;gt;"))&lt;BR /&gt;(or txt_opt (setq txt_opt "None"))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;(setq ent_allowed '("LINE" "LWPOLYLINE" "POLYLINE" "SPLINE" "ARC" "CIRCLE" "DIMENSION")&lt;BR /&gt;total_len 0&lt;BR /&gt;)&lt;BR /&gt;(while (or (initget "Clear Undo")&lt;BR /&gt;(setq en (entsel "\nPick object for length, [Clear/Undo]."))&lt;BR /&gt;)&lt;BR /&gt;(cond&lt;BR /&gt;((= "Clear" en)&lt;BR /&gt;(if (member txt_opt '("Each" "Total"))&lt;BR /&gt;(put_txt (strcat "Total " (rtos total_len)))&lt;BR /&gt;)&lt;BR /&gt;(setq total_len 0 ; clear length total&lt;BR /&gt;LenList nil)&lt;BR /&gt;)&lt;BR /&gt;((= "Undo" en)&lt;BR /&gt;(if LenList&lt;BR /&gt;(progn&lt;BR /&gt;(setq total_len (- total_len (cadar LenList)))&lt;BR /&gt;(princ (strcat "\n** Removed " (caar LenList) " length = "&lt;BR /&gt;(rtos (cadar LenList)) " Running total is " (rtos total_len)))&lt;BR /&gt;(if (caddar LenList) (entdel (caddar LenList)))&lt;BR /&gt;(setq LenList (cdr LenList))&lt;BR /&gt;)&lt;BR /&gt;(prompt "\n** No more Undo possible.")&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(t&lt;BR /&gt;(setq en (car en)&lt;BR /&gt;obj (vlax-ename-&amp;gt;vla-object en)&lt;BR /&gt;)&lt;BR /&gt;(if (member (setq typ (cdr (assoc 0 (entget en)))) ent_allowed)&lt;BR /&gt;(progn&lt;BR /&gt;(cond&lt;BR /&gt;((vlax-property-available-p obj 'Measurement)&lt;BR /&gt;(setq len (vla-get-measurement obj))&lt;BR /&gt;)&lt;BR /&gt;((setq len (vlax-curve-getdistatparam en (vlax-curve-getendparam en))))&lt;BR /&gt;)&lt;BR /&gt;(setq total_len (+ len total_len))&lt;BR /&gt;(princ (strcat "\n" typ " length = " (rtos len)&lt;BR /&gt;" Running total is " (rtos total_len)))&lt;BR /&gt;(if (= txt_opt "Each")&lt;BR /&gt;(setq NewTxt (put_txt (rtos len)))&lt;BR /&gt;)&lt;BR /&gt;(if LenList&lt;BR /&gt;(setq LenList (cons (list typ len NewTxt) LenList))&lt;BR /&gt;(setq LenList (list (list typ len NewTxt)))&lt;BR /&gt;)&lt;BR /&gt;) ; progn&lt;BR /&gt;(alert "Not a valid object for length")&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;) ; while&lt;BR /&gt;(and (not (zerop total_len))&lt;BR /&gt;(princ (strcat "\nTotal length is " (rtos total_len)))&lt;BR /&gt;(if (member txt_opt '("Each" "Total"))&lt;BR /&gt;(put_txt (strcat "Total " (rtos total_len)))&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;(setvar "CMDECHO" usercmd)&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;BR /&gt;(prompt "\nGet Length loaded, Enter length to run")&lt;BR /&gt;(princ)&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 10:40:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12055533#M28071</guid>
      <dc:creator>paul9ZMBV</dc:creator>
      <dc:date>2023-06-23T10:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to divide total selected dimensions by given amount</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12056452#M28072</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4499694"&gt;@paul9ZMBV&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;.... after the total is shown the user has the option to divide the total by the inputted amount and display that amount.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;It would also be nice to have the dimensions turn blue (as in selected) when selecting each dimension as currently you cant visibly see which dims are selected.&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For the highlighting, try adding this [untested]:&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2" color="#999999"&gt;....&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2" color="#999999"&gt;&amp;nbsp; (if (member (setq typ (cdr (assoc 0 (entget en)))) ent_allowed)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2" color="#999999"&gt;&amp;nbsp; &amp;nbsp; (progn&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;STRONG style="color: #0000ff;"&gt;(redraw en 3)&lt;/STRONG&gt;&lt;FONT style="color: #0000ff;" color="#99CCFF"&gt;; highlight&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2" color="#999999"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (cond&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2" color="#999999"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ((vlax-property-available-p obj 'Measurement)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2" color="#999999"&gt;....&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to add a REGEN command at the end to wipe out all the highlighting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the dividing, would you want the result only displayed at the command line, or also added to the drawn Text when that's called for?&amp;nbsp; If the latter, what kind of extra wording would it entail, and would Mtext make more sense?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 16:50:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12056452#M28072</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2023-06-23T16:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to divide total selected dimensions by given amount</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060053#M28073</link>
      <description>&lt;P&gt;Thanks for the reply, being a complete Lisp newbie could you kindly add your wording to the original Lisp. (as i'm not sure of the position it should be within the Lisp)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would be nice to have the divide result &lt;SPAN&gt;added to the drawn Text please.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 06:45:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060053#M28073</guid>
      <dc:creator>paul9ZMBV</dc:creator>
      <dc:date>2023-06-26T06:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to divide total selected dimensions by given amount</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060490#M28074</link>
      <description>&lt;P&gt;hey,&lt;/P&gt;&lt;P&gt;if you need to totalize dimensions only, check this&amp;nbsp;&amp;nbsp;for the start .&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;LI-CODE lang="lisp"&gt;(defun c:dimension_total (/ ename_list total_string_point total_string)
	(prompt "Select dimensions")
	(setq divider (if (null divider) 1.0 divider)
		  ename_list (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "dimension"))))))
		  total_string_point "Total"
	)
	(while (= 'str (type total_string_point)) 
		(initget "Divider Reset")
		(cond 
			(
				(= "Divider"
			   		(setq total_string_point (getpoint (strcat "Pick the point to place total number = " 
			   												(setq total_string
			   														(rtos (/ (apply '+ 
			   																	(mapcar '(lambda (ename) (vla-get-measurement (vlax-ename-&amp;gt;vla-object ename))) 
			   																	   		 ename_list
			   																	)
			   															  	 )
			   																 divider
			   															  ) 
																		  (getvar 'dimlunit)
																		  ;(apply 'max (mapcar 'vla-get-primaryunitsprecision (mapcar 'vlax-ename-&amp;gt;vla-object ename_list))) 
																		  4
			   														) 
			   												)
			   												" [Divider/Reset]: "
			   										     )
			   							       )
			   		)
				)
					(setq init (initget 6)
						  divider (getreal (strcat "\nEnter divider for total number &amp;lt;" (rtos divider 2 2)  "&amp;gt;: "))
					)
			)
			(
				(= "Reset" total_string_point)
		  			(setq ename_list (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "dimension")))))))
			)
			(
				t
			)
		)
	)
	(entmake (list '(0 . "text")
			        (cons 10 total_string_point)
			        (cons 1 total_string)
			        (cons 40 (vla-get-textheight (vlax-ename-&amp;gt;vla-object (car ename_list))))
					(cons 7 (vla-get-textstyle (vlax-ename-&amp;gt;vla-object (car ename_list))))
			 )
	)
	(vla-put-color (vlax-ename-&amp;gt;vla-object (entlast)) (vla-get-color (vlax-ename-&amp;gt;vla-object (car ename_list)))) 
	(princ)
)&lt;/LI-CODE&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 13:39:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060490#M28074</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-06-26T13:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to divide total selected dimensions by given amount</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060517#M28075</link>
      <description>&lt;P&gt;Brilliant thanks, can you kindly change the format to be as many decimal places as per the original dimensions its taking the figure from.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example if one measurement is 23.879 and one is 16.67 the answer will be given as 40.549&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To have it in the same font as the dimensions would also be nice (but not essential)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Really appreciate your help with this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 10:43:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060517#M28075</guid>
      <dc:creator>paul9ZMBV</dc:creator>
      <dc:date>2023-06-26T10:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to divide total selected dimensions by given amount</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060711#M28076</link>
      <description>&lt;P&gt;check update above.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 12:23:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060711#M28076</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-06-26T12:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to divide total selected dimensions by given amount</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060816#M28077</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13423916" target="_self"&gt;&lt;SPAN class=""&gt;komondormrex&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;That's fantastic, sorry to be a pain, one little tweek please, having thought about it, could I kindly ask you change it to having 4 decimal places by default on all measurement including the divide result, (despite me saying otherwise)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Can the adding procedure be taken from the &lt;STRONG&gt;actual measurement (4 decimal places)&lt;/STRONG&gt; rather than the visable text measurement. (as the dim style is set to only show 1 decimal place, with rounding up and down)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Its great the font etc is the same thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Really appreciated Paul&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 12:59:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060816#M28077</guid>
      <dc:creator>paul9ZMBV</dc:creator>
      <dc:date>2023-06-26T12:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to divide total selected dimensions by given amount</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060916#M28078</link>
      <description>&lt;P&gt;sure. find update above.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 13:39:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060916#M28078</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-06-26T13:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Lisp to divide total selected dimensions by given amount</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060945#M28079</link>
      <description>&lt;P&gt;Thanks a lot, much appreciated.&lt;/P&gt;&lt;P&gt;Cant thank you enough.&lt;/P&gt;&lt;P&gt;Game changer for me.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 13:48:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-divide-total-selected-dimensions-by-given-amount/m-p/12060945#M28079</guid>
      <dc:creator>paul9ZMBV</dc:creator>
      <dc:date>2023-06-26T13:48:14Z</dc:date>
    </item>
  </channel>
</rss>

