Author Topic: How to get max of repeated variable?  (Read 1594 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
How to get max of repeated variable?
« on: July 24, 2014, 05:01:47 AM »
I am coding a lisp with repeat
Code: [Select]
(repeat (- columnscount 1)
    (collectdata)
    (drft)
    )
(defun collectdata ( /  )
    (setq *W  (cond ( (getint (strcat "\nWhats is column  C" (itoa ColumnNo) "  Width <" (itoa (setq *w  (cond ( *w  ) ( 300 )))) ">: "))) ( *w  )))
    (setq *L  (cond ( (getint (strcat "\nWhats is column  C" (itoa ColumnNo) "  Length <" (itoa (setq *l  (cond ( *l  ) ( 600 )))) ">: "))) ( *l  )))
    )
and there is a variable.
How to get the max of variable
Code: [Select]
(setq *L  (cond ( (getint (strcat "\nWhats is column  C" (itoa ColumnNo) "  Length <" (itoa (setq *l  (cond ( *l  ) ( 600 )))) ">: "))) ( *l  )))

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get max of repeated variable?
« Reply #1 on: July 24, 2014, 06:46:08 AM »
Please clarify ?

You have a quantity of "Columns"

You want to build a datalist of the column width and height for each column.


What is function (drft) for ?

I'm not sure of your real intention.
What is the MAX function meant to be applied to ??

Have a play:

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun collectdata (ColumnNo / )
  3.   (setq
  4.     *W (cond
  5.          ((getint (strcat "\nWhats is column  C"
  6.                           (itoa ColumnNo)
  7.                           "  Width <"
  8.                           (itoa (setq *w (cond (*w)
  9.                                                (300)
  10.                                          )
  11.                                 )
  12.                           )
  13.                           ">: "
  14.                   )
  15.           )
  16.          )
  17.          (*w)
  18.        )
  19.   )
  20.   (setq
  21.     *L (cond
  22.          ((getint (strcat "\nWhats is column  C"
  23.                           (itoa ColumnNo)
  24.                           "  Length <"
  25.                           (itoa (setq *l (cond (*l)
  26.                                                (600)
  27.                                          )
  28.                                 )
  29.                           )
  30.                           ">: "
  31.                   )
  32.           )
  33.          )
  34.          (*l)
  35.        )
  36.   )
  37.   (list *W *L)
  38. )
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. (defun c:doit (/ add local variables)
  46.   (setq columnCount 3
  47.         ColumnData nil
  48.         index 1
  49.   )
  50.   (while (<= index columnCount)
  51.     (while (<= index columncount)
  52.       (setq data (collectData index))
  53.       (princ data)
  54.       (setq columndata (cons data columndata))
  55.       (setq index (1+ index))
  56.     )
  57.   )
  58.   (setq columndata (reverse columndata))
  59.   (princ "\n")
  60.   (princ (vl-princ-to-string columndata))
  61.   (princ)
  62. )
  63.  
  64.  

Quote
Command:
Command: DOIT
Whats is column  C1  Width <300>: 100
Whats is column  C1  Length <350>: 150
(100 150)
Whats is column  C2  Width <100>: 200
Whats is column  C2  Length <150>: 250
(200 250)
Whats is column  C3  Width <200>: 300
Whats is column  C3  Length <250>: 350
(300 350)
((100 150) (200 250) (300 350))
« Last Edit: July 24, 2014, 07:11:00 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to get max of repeated variable?
« Reply #2 on: July 24, 2014, 07:26:55 AM »
I am trying to draft column section

the next step is to copy all to make new row of columns
So I want to know the max column length to to avoid overlaping of objects

Code - Auto/Visual Lisp: [Select]
  1. ;|----------- COLUMNSCHEDULE -------------------
  2.             q_|_|| _\|| q_|| _\|               
  3.                                                
  4.   To Draw Column Section, vertical bars        
  5.   and adding dimensions                        
  6.                                                
  7. ------------------------------------------------
  8.   Author: Hasan M. Asous, 2014                 
  9.         ALL RIGHT RESERVED TO ALL              
  10.                                                
  11.   Contact: HasanCAD @ TheSwamp.org,            
  12.            asos2000 @ CADTutor.net             
  13.            HasanCAD@gmail.com                  
  14. ------------------------------------------------
  15.   Version: 1      2014 07 20 1st version       
  16. ________________________________________________
  17.                                               |;
  18.  
  19.  
  20.         ;     q_|_|| _\|| q_|| _\|     ;
  21.         ;       Mainroutine Start      ;
  22.  
  23. (defun c:COLUMNSCHEDULE () (c:CSD))
  24. (DEFUN c:CSD ( / cmd cvr cvr2 doc dym dyp i ix ixx iy osm spc)
  25.  
  26.   (setq *acad (cond (*acad) ((vlax-get-acad-object))))
  27.         spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc)))
  28.   (setq uFlag (not (vla-StartUndoMark doc)))
  29.  
  30.   (makelay "S-OPEN"             3       "Continuous")           ; CREATE LAYERS
  31.   (makelay "S-BARS"             4       "Continuous")
  32.   (makelay "S-ANNO-TEXT"        3       "Continuous")
  33.   (makelay "S-ANNO-LEGN1"       4       "Continuous")
  34.   (makelay "S-BARS-SECT-VERT"   4       "Continuous")
  35.   (makelay "S-STRP"             220     "Continuous")
  36.   (makelay "S-ANNO-DIMS"        15      "Continuous")
  37.   (_makefonts '(("SDC-TEXT" . "Arial.ttf")))                    ; CREATE TSTYLE
  38.   (scaledel_create_scales '( ("1:25" "1:25") ))                 ; CREATE annotation
  39.   (vl-cmdf "cannoscale" "1:25"  )
  40.   (setq osm (getvar "osmode"    ))  
  41.   (setq dym (getvar "dynmode"   ))      (setvar "dynmode" 1)
  42.   (setq dyp (getvar "dynprompt" ))      (setvar "dynprompt" 1)
  43.   (setq cmd (getvar "cmdecho"   ))      (setvar "cmdecho" 0)
  44.   (Blk T)
  45.   (setq cvr 25.0        )                                       ; column cover
  46.   (setq cvr2 (* 2 cvr)  )
  47.   (vl-cmdf "_.-insert" "R:/SDC_LIBRARIES/CAD_LIBRARY/BLOCKS/S/Stirrup.dwg" "0,0,0" "1" "1" "0")         ; inser stirrup block
  48.   (vl-cmdf "_.erase" "last" "")
  49.   (vl-cmdf "_.-purge" "blocks" "Stirrup" "n")
  50.   (vl-cmdf "_.-DIMSTYLE" "Restore" "SDC_DIM")
  51.  
  52.   (setq ColumnsCount (getint "\nHow many column you want to draw?"))
  53.   (setq ColumnCuts (getint "\nHow many cut in columns"))
  54.   (setq ColumnNo 1)
  55.  
  56.   (collectdata)
  57.   (setq i (getpoint "\n Pick insertion point") iX (nth 0 i) iXX (nth 0 i) iY (nth 1 i))
  58.   (drft)
  59.  
  60.   (repeat (- columnscount 1)
  61.     (setq ColumnNo (1+ ColumnNo))
  62.     (setq iX (+ 1300 iX))
  63.     (collectdata)
  64.     (drft)
  65.     )
  66.   (makeline i (list (+ iX 1300) iY 0.0) "Continuous" "S-ANNO-LEGN1" )                                   ; CREATE LINES
  67.   (makeline (list iXX (+ iY 500) 0.0) (list (+ iX 1300) (+ iY 500) 0.0) "Continuous" "S-ANNO-LEGN1" )
  68.   (vl-cmdf "_.zoom" (list (- iXX 200) (- iY 200)) (list (+ (+ iX 650) (* 0.5 *w) 500 ) (+ iY 1500 *l)))
  69.   (setq Lmax (max *Llst))
  70.  
  71.   (setvar "osmode"      osm     )
  72.   (setvar "dynmode"     dym     )
  73.   (setvar "dynprompt"   dyp     )
  74.   (setvar "cmdecho"     cmd     )
  75.   (setq uFlag (vla-EndUndoMark doc))
  76.   )
  77.    
  78.         ;     q_|_|| _\|| q_|| _\|     ;
  79.         ;       Mainroutine End        ;
  80.  
  81.  
  82.         ;     q_|_|| _\|| q_|| _\|     ;
  83.         ;       Subroutine Start       ;
  84.  
  85. (defun collectdata ( / *Llst )
  86.     (setq *w  (cond ( (getint (strcat "\nWhats is column  C" (itoa ColumnNo) "  Width <"        (itoa (setq *w  (cond ( *w  ) ( 300 )))) ">: "))) ( *w  )))
  87.     (setq *l  (cond ( (getint (strcat "\nWhats is column  C" (itoa ColumnNo) "  Length <"       (itoa (setq *l  (cond ( *l  ) ( 600 )))) ">: "))) ( *l  )))
  88.     (setq *tb (cond ( (getint (strcat "\nHow many bar at top and bottom <"                      (itoa (setq *tb (cond ( *tb ) (   3 )))) ">? "))) ( *tb )))
  89.     (setq *sd (cond ( (getint (strcat "\nHow many bar at side <"                                (itoa (setq *sd (cond ( *sd ) (   5 )))) ">? "))) ( *sd )))
  90.     (setq *d  (cond ( (getint (strcat "\nWhats BARS dia <"                                      (itoa (setq *d  (cond ( *d  ) (  20 )))) ">? "))) ( *d  )))
  91.     (setq vb  (- (* 2 (+ *tb *sd)) 4)) ; total number of BARS
  92.     (setq *str (cond (*str) ("T10@200")))
  93.     (setq *str (if (= "" (setq tmp (strcase (getstring (strcat "\nWhat is Stirrup Dia And repeatation? <" *str  ">: "))))) *str tmp))
  94.   (setq *Llst (cons *l *Llst))
  95.     )
  96.  
  97. (defun drft ( / )
  98.     (setq p1a (list (+ (- (+ iX 650) (* 0.5 *w)) cvr2) (+ (+ iY 1000)    cvr2) 0.0 ))   ;POINTS FOR BARS
  99.     (setq p2a (list (- (+ (+ iX 650) (* 0.5 *w)) cvr2) (+ (+ iY 1000)    cvr2) 0.0 ))
  100.     (setq p3a (list (- (+ (+ iX 650) (* 0.5 *w)) cvr2) (- (+ iY 1000 *l) cvr2) 0.0 ))
  101.     (setq p4a (list (+ (- (+ iX 650) (* 0.5 *w)) cvr2) (- (+ iY 1000 *l) cvr2) 0.0 ))
  102.     (DVD p1a p2a *tb *d)
  103.     (DVD p2a p3a *sd *d)
  104.     (DVD p4a p3a *tb *d)
  105.     (DVD p1a p4a *sd *d)
  106.     (Insert p1a "SS" *d)
  107.     (Insert p2a "SS" *d)
  108.     (Insert p3a "SS" *d)
  109.     (Insert p4a "SS" *d)
  110.     (setq pts (list
  111.                 (- (+ iX 650) (* 0.5 *w)) (+ iY 1000)   0.0
  112.                 (+ (+ iX 650) (* 0.5 *w)) (+ iY 1000)   0.0
  113.                 (+ (+ iX 650) (* 0.5 *w)) (+ iY 1000 *l)        0.0
  114.                 (- (+ iX 650) (* 0.5 *w)) (+ iY 1000 *l)        0.0     ))                      ;POINTS FOR COLUMN AS LIST
  115.  
  116.     (vla-put-closed (vla-addPolyline Spc (setq pts (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (1- (length pts)))) pts))))  :vlax-true)                  ; DRAW COLUMN
  117.     (setq clm (vlax-ename->vla-object (entlast)))
  118.     (vla-put-layer clm "S-OPEN")
  119.     (vla-put-color clm 256)
  120.  
  121.     (setq p1 (list (+ (+ iX 650) (* 0.5 *w)) (+ iY 1000 *l) 0.0 ))
  122.     (vl-catch-all-error-p (setq strp (vl-catch-all-apply (function vla-InsertBlock) (list spc (vlax-3D-point p1) "STRP-01" 1.0 1.0 1.0 0))))
  123.     (vla-put-layer STRP "S-STRP")
  124.     (LM:setdynprops STRP (list (cons "X Distance1" *w) (cons "Y Distance1" *l)))                ; MODIFY STIRRUP PROPERTIES TO BE MODIFIED AFTER
  125.     (vl-cmdf "_.zoom" (list (- (+ iX 650) (* 0.5 *w)) (+ iY 750) 0.0 ) (list (+ (+ iX 650) (* 0.5 *w)) (+ iY 1250 *l) 0.0 ))
  126.     (initget "Yes No")
  127.     (setq *str2 (cond ( (getkword (strcat "\nDo you want to add additional stirrup [Yes/No] <" (setq *str2 (cond ( *str2 ) ( "Yes" )))  ">: "))) ( *str2 )))
  128.     (if (= *str2 "Yes")
  129.       (progn
  130.         (setq *str-no (cond ( (getint (strcat "\nHow many addtional STIRRUP should be added  <" (itoa (setq *str-no (cond ( *str-no ) ( 2 )))) ">: "))) ( *str-no )))
  131.         (setvar "osmode" 64)
  132.         (repeat *str-no
  133.           (setq ap1 (getpoint "\nPick First bar"))
  134.           (setq ap2 (getpoint "\nPick Second bar"))
  135.           (setq aap1 (list (max (nth 0 ap1) (nth 0 ap2)) (max (nth 1 ap1) (nth 1 ap2)) (max (nth 2 ap1) (nth 2 ap2))))
  136.           (setq aap2 (list (min (nth 0 ap1) (nth 0 ap2)) (min (nth 1 ap1) (nth 1 ap2)) (min (nth 2 ap1) (nth 2 ap2))))
  137.           (vl-catch-all-error-p (setq strp2 (vl-catch-all-apply (function vla-InsertBlock) (list spc (vlax-3D-point aap1) "STRP-02" 1.0 1.0 1.0 0))))
  138.           (vla-put-layer STRP2 "S-STRP")
  139.           (LM:setdynprops STRP2 (list (cons "X Distance1" (- (max (nth 0 ap1) (nth 0 ap2)) (min (nth 0 ap1) (nth 0 ap2)))) (cons "Y Distance1" (- (max (nth 1 ap1) (nth 1 ap2)) (min (nth 1 ap1) (nth 1 ap2))))))))
  140.       (vl-cmdf "_.zoom" "Previous"))
  141.      
  142.   (MakeText (strcat "C" (itoa ColumnNo))                        4       (list (+ iX 650) (+ iY 250) 0.0 ) "S-ANNO-TEXT" 100  0 "SDC-TEXT" 1 2 T)                                ; CREATE TEXT
  143.   (MakeText (strcat "(" (itoa (1+ *str-no)) " PER SET)")        256     (list (+ iX 650) (+ iY 650) 0.0 ) "S-ANNO-TEXT" 62.5 0 "SDC-TEXT" 1 2 T)
  144.   (MakeText (strcat "WITH " *str " TIES")                       256     (list (+ iX 650) (+ iY 750) 0.0 ) "S-ANNO-TEXT" 62.5 0 "SDC-TEXT" 1 2 T)
  145.   (MakeText (strcat (itoa vb) "T" (itoa *d) " VERTICAL BARS")   256     (list (+ iX 650) (+ iY 850) 0.0 ) "S-ANNO-TEXT" 62.5 0 "SDC-TEXT" 1 2 T)
  146.  
  147.   (setq pc1 (list (- (+ iX 650) (* 0.5 *w)) (+ iY 1000)         0.0))
  148.   (setq pc2 (list (+ (+ iX 650) (* 0.5 *w)) (+ iY 1000)         0.0))
  149.   (setq pc3 (list (+ (+ iX 650) (* 0.5 *w)) (+ iY 1000 *l)      0.0))
  150.   (setq pc4 (list (- (+ iX 650) (* 0.5 *w)) (+ iY 1000 *l)      0.0))
  151.  
  152.   (apply (function vla-AddDimRotated) (append (list spc) (mapcar (function vlax-3D-point) (list pc3 pc4 (polar pc4 (angle (trans pc1 1 0) pc4) 250))) '(0.)))
  153.   (vl-cmdf "CHPROP" "L" "" "Annotative" "Yes" "")
  154.   (setq dim (vlax-ename->vla-object (entlast)))
  155.   (vla-put-layer dim "S-ANNO-DIMS")
  156.   (vla-put-color dim 256)
  157.    
  158.   (apply (function vla-AddDimRotated) (append (list spc) (mapcar (function vlax-3D-point) (list pc1 pc4 (polar pc1 (angle (trans pc1 1 0) pc1) -250))) (list (/ pi 2.))))
  159.   (vl-cmdf "CHPROP" "L" "" "Annotative" "Yes" "")
  160.   (setq dim (vlax-ename->vla-object (entlast)))
  161.   (vla-put-layer dim "S-ANNO-DIMS")
  162.   (vla-put-color dim 256)
  163.   (vl-cmdf "cannoscale" "1:25"  )
  164.   ;(setq cut (cons (+ 500 p3) cut)
  165.   )
  166.  
  167.  
  168.  
  169. (defun *error* (msg) (and uFlag (vla-EndUndoMark doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ))
  170.  
  171. (defun Insert   (pt Nme scl) (entmakex (list (cons 0 "INSERT") (cons 2 Nme) (cons 8 "S-BARS-SECT-VERT") (cons 10 pt) (cons 41 scl) (cons 42 scl) (cons 43 scl))))
  172.  
  173. ;; Set Dynamic Block Properties  -  Lee Mac
  174. ;; Modifies values of Dynamic Block properties using a supplied association list.
  175. ;; blk - [vla] VLA Dynamic Block Reference object
  176. ;; lst - [lst] Association list of ((<Property> . <Value>) ... )
  177. ;; Returns: nil
  178. (defun LM:setdynprops ( blk lst / itm ) (setq lst (mapcar '(lambda ( x ) (cons (strcase (car x)) (cdr x))) lst)) (foreach x (vlax-invoke blk 'getdynamicblockproperties) (if (setq itm (assoc (strcase (vla-get-propertyname x)) lst)) (vla-put-value x (vlax-make-variant (cdr itm) (vlax-variant-type (vla-get-value x)))))))
  179.  
  180. (defun DVD ( dp1 dp2 n sc / l dsd i o k la sc)  ;(DVD dp1 dp2 n sc)
  181.   (setq la (getvar "CLayer"))
  182.   (setvar "CLayer" "S-BARS-SECT-VERT")
  183.   (command "_.Line" "_non" dp1 "_non" dp2 "")
  184.   (setq o (entlast))
  185.   (setq n (- n 1))
  186.   (setq dsd (/ (distance dp1 dp2) n))
  187.   (setq i dsd)
  188.   (repeat n (entmake (append (list '(0 . "INSERT")'(2 . "SS")(cons 10 (vlax-curve-getpointatdist o i))) (mapcar '(lambda (k) (cons k sc)) (list 41 42 43)))) (setq i (+ dsd i)))
  189.   (command "_.Erase" "last" "")
  190.   (command "_.Erase" o "")
  191.   (setvar "CLayer" la))
  192.  
  193. (defun Blk (ex / blks)
  194.     (if (not (tblsearch "BLOCK" "SS"))
  195.       (progn
  196.         (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockReference") (2 . "SS") (10 0.0 0.0 0.0) (70 . 0)))
  197.         (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 7) (72 . 1) (73 . 1) (93 . 2) (10 0.5 0.0 0.0) (42 . 1.0) (10 -0.5 0.0 0.0) (42 . 1.) (97 . 0) (75 . 0) (76 . 1) (47 . 0.01) (98 . 1) (10 0.1 -0.1 0.0) (450 . 0) (451 . 0) (460 . 0.0) (461 . 0.0) (452 . 1) (462 . 1.0) (453 . 2) (463 . 0.0) (63 . 5) (421 . 255) (463 . 1.0) (63 . 7) (421 . 16777215) (470 . "LINEAR")))
  198.         (entmake '((0 . "ENDBLK")       (100 . "AcDbBlockEnd")  (8 . "0")))))
  199.   (if ex
  200.     (progn
  201.       (vla-put-explodable        (vla-item blks "SS") :vlax-false)
  202.       (vla-put-BlockScaling      (vla-item blks "SS") acUniform)
  203.       ))
  204.     (princ)
  205.   )
  206.  
  207. (defun makelay (LName LColor LType)    ; (makelay LName LColor LType)
  208. ;  CAB
  209.   (if (not (tblsearch "LTYPE" LType)) (vla-load (vla-get-Linetypes (vla-get-ActiveDocument (vlax-get-acad-object))) LType "acadiso.lin"))
  210.   (if (not(tblsearch "LAYER" LName))
  211.     (entmake (list
  212.                '(0 . "LAYER")
  213.                '(100 . "AcDbSymbolTableRecord")
  214.                '(100 . "AcDbLayerTableRecord")
  215.                (cons 2  LName)       ;layer name
  216.                (cons 6  (if (and ltype(tblobjname "ltype" ltype)) ltype  "Continuous")) ;linetype
  217.                (cons 62  LColor) ;layer color
  218.                '(70 . 0) ; on, unlocked, thawed
  219.              ))))
  220.  
  221.   ;;by VovKa  http://www.theswamp.org/index.php?to...4927#msg384927
  222. (defun _makefonts (listoffonts / doc font fntdir st)
  223.         fntdir (strcat (getenv "windir") "\\Fonts\\"))
  224.   (foreach f listoffonts
  225.     (cond ((or (setq font (findfile (cdr f)))
  226.                (and (setq font (findfile (strcat fntdir (cdr f)))) (findfile font)))
  227.            (setq st (vla-add (vla-get-textstyles doc) (car f)))
  228.            (vlax-put-property st 'fontfile font)
  229.            (vlax-put-property st 'width 1.0)
  230.            (vlax-put-property st 'height 0.0)))) (princ))
  231. ;; Usage (_makefonts '(("SDC-TEXT" . "Arial.ttf")))
  232.  
  233. (defun MakeText (str c pt lyr ht ro TSyl G72 G73 an)
  234.   (entmakex (list (cons 0 "TEXT")       ;***
  235.                  (cons 1 str)           ;* (the string itself)
  236.                  (cons 6 "BYLAYER")     ; Linetype name
  237.                  (cons 7 TSyl)          ;* Text style name, defaults to STANDARD, not current
  238.                  (cons 8 lyr)           ; layer
  239.                  (cons 10 pt)           ;* First alignment point (in OCS)
  240.                  (cons 11 pt)           ;* Second alignment point (in OCS)
  241.                  (cons 39 0.0)          ; Thickness (optional; default = 0)
  242.                  (cons 40 ht)           ;* Text height
  243.                  (cons 41 1.0)          ; Relative X scale factor, Width Factor, defaults to 1.0
  244.                  (cons 50 ro)           ; Text rotation angle
  245.                  (cons 51 0.0)          ; Oblique angle
  246.                  (cons 62 c)            ; color
  247.                  (cons 71 0)            ; Text generation flags
  248.                  (cons 72 G72)          ; Horizontal text justification type
  249.                  (cons 73 G73)          ; Vertical text justification type
  250.                  (cons 210 (list 0.0 0.0 1.0))))
  251.   (if an (vl-cmdf "CHPROP" "L" "" "Annotative" "Yes" "")))
  252. ;Group 73       | Group 72
  253. ;               |   0       1                2              3               4             5    
  254. ;3 (top)        | TLeft | TCenter       | TRight                                               
  255. ;2 (middle)     | MLeft | MCenter       | MRight                                               
  256. ;1 (bottom)     | BLeft | BCenter       | BRight                                               
  257. ;0 (baseline)   | Left  | Center        | Right         | Aligned       | Middle        | Fit  
  258.  
  259. (defun makeline (str end Ltp lyr )
  260.   (entmake (list (cons 0 "LINE")        ; ***
  261.                (cons 6 Ltp)             ; Linetype name (present if not BYLAYER)
  262.                (cons 8 lyr)             ; Layer
  263.                (cons 10 str)            ; Start Point
  264.                (cons 11 end)            ; End Point
  265.                (cons 39 0.0)            ; Thickness (optional) default = 0
  266.                (cons 62 256)            ; Color number (present if not BYLAYER);
  267.                (cons 210 (list 0.0 0.0 1.0)))))
  268.  
  269. (defun scaledel_create_scales (SCALES / scale-list-all cmdecho)
  270.   (setq scale-list-all (scaledel_get_scalelist)
  271.         cmdecho (getvar "CMDECHO"))
  272.   (setvar "CMDECHO" 0)
  273.   (command "_.-SCALELISTEDIT")
  274.   (foreach scale SCALES (if (not (member (strcase (car scale)) scale-list-all)) (command "_A" (car scale) (cadr scale))))
  275.   (command "_E")
  276.   (setvar "CMDECHO" cmdecho)) ; End scaledel_create_scales
  277.  
  278. (defun scaledel_get_scalelist (/ scale-list)
  279.       (foreach item (dictsearch (namedobjdict) "ACAD_SCALELIST")
  280.         (if (= 350 (car item))
  281.           (setq scale-list (cons (strcase (cdr (assoc 300 (entget (cdr item))))) scale-list))))
  282.       scale-list) ; End scaledel_get_scalelist
  283.  
  284. (princ "\n      q_|_|| _\\|| q_|| _\\|")
  285. (princ "\n  Type  CSD  to invoke the lisp")
  286.  
  287.         ;     q_|_|| _\|| q_|| _\|     ;
  288.         ;        Subroutine End        ;
« Last Edit: July 24, 2014, 08:31:32 AM by HasanCAD »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get max of repeated variable?
« Reply #3 on: July 24, 2014, 07:30:13 AM »
I'm not interested in trying to read your code.
The code is your answer (which you are unhappy with) to the question'
I want to know the question.
Just explain what you want.

What is the MAX function meant to be applied to ??

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get max of repeated variable?
« Reply #4 on: July 24, 2014, 07:33:42 AM »

Code - Auto/Visual Lisp: [Select]
  1. ;;;------------------------------------------------------------------
  2. ;;;------------------------------------------------------------------
  3. ;;;
  4. ;;; min max X Y Z
  5. (defun kdub:minx (pointlist)
  6.   (apply (function min) (mapcar (function car) pointlist))
  7. )
  8. (defun kdub:miny (pointlist)
  9.   (apply (function min) (mapcar (function cadr) pointlist))
  10. )
  11. (defun kdub:minz (pointlist)
  12.   (apply (function min) (mapcar (function caddr) pointlist))
  13. )
  14.  
  15. (defun kdub:maxx (pointlist)
  16.   (apply (function max) (mapcar (function car) pointlist))
  17. )
  18. (defun kdub:maxy (pointlist)
  19.   (apply (function max) (mapcar (function cadr) pointlist))
  20. )
  21. (defun kdub:maxz (pointlist)
  22.   (apply (function max) (mapcar (function caddr) pointlist))
  23. )
  24.  
  25. ;;; min XY max XY
  26. (defun kdub:minxy (pointlist)
  27.   (list (kdub:minx pointlist) (kdub:miny pointlist))
  28. )
  29. (defun kdub:maxxy (pointlist)
  30.   (list (kdub:maxx pointlist) (kdub:maxy pointlist))
  31. )
  32.  
  33. ;;; min XYZ max XYZ
  34. (defun kdub:minxyz (pointlist)
  35.   (list (kdub:minx pointlist) (kdub:miny pointlist) (kdub:minz pointlist))
  36. )
  37. (defun kdub:maxxyz (pointlist)
  38.   (list (kdub:maxx pointlist) (kdub:maxy pointlist) (kdub:maxz pointlist))
  39. )
  40.  
  41.  
  42.  

( kdub:maxxy columndata)  ;;->> (300 350)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to get max of repeated variable?
« Reply #5 on: July 24, 2014, 08:01:57 AM »
the lisp create this view (right side) and want update the code to create new raw.
So I want to get maximum of column length to copy objects and avoiding overlaping of objects.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get max of repeated variable?
« Reply #6 on: July 24, 2014, 08:10:23 AM »

In that case your original post is incorrect. You will need to collect all the data before trying to draw the sections.

Just pass the datalist :
(setq maxLength ( kdub:maxy columndata)  )  ;; returns the maximum Y value from the list of lists.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.