TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GDF on August 01, 2019, 09:58:57 AM

Title: Array Help
Post by: GDF on August 01, 2019, 09:58:57 AM
I would like to get all of "SS" occurrences of the array; where "LEVELS" is the total number of the array repeat.

The code below will only pick up the first:
(setq SS (ssadd))
(command "array" (entlast) "" "r" (rtos (- LEVELS 1) 2 0) "1" flrheight)
(setq SS (ssadd (entlast) SS))


Thanks for any help
Title: Re: Array Help
Post by: ronjonp on August 01, 2019, 11:47:32 AM
Not exactly sure what you're asking for but this should return the number of columns and rows in an array.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ _getrc s)
  2.   (defun _getrc (e / a)
  3.     (if (and (= 'ename (type e))
  4.              (setq a (cdr (member '(102 . "{ACAD_REACTORS") (entget e))))
  5.              (= "ACDBASSOCDEPENDENCY" (cdr (assoc 0 (setq a (entget (cdar a))))))
  6.              (= "ACDBASSOCACTION" (cdr (assoc 0 (setq a (entget (cdr (assoc 330 a)))))))
  7.         )
  8.       (list (cdar (cdddr (member '(1 . "Items") a))) (cdar (cdddr (member '(1 . "Rows") a))))
  9.     )
  10.   )
  11.   (if (setq s (ssget '((0 . "insert") (2 . "`*U*"))))
  12.     (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (print (_getrc e)))
  13.   )
  14.   (princ)
  15. )
Title: Re: Array Help
Post by: GDF on August 01, 2019, 03:16:42 PM
Thanks Ron

I'm having trouble with the selection set capturing all of the lines that make up the curtainwall in elevation.
I thought it was with the array command...now I'm not sure.

;;;;;;;;;;;;;;;;;;;;;;;; Curtainwall Elevation Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   (defun draw_cwall  ()...
   
Thanks for any guidance you can give me.
Title: Re: Array Help
Post by: ronjonp on August 01, 2019, 04:35:15 PM
Sorry Gary I'm not sure what you're trying to do.

An array is just a block so if you need to get all individual items, you could use vla-explode then have all the individual pieces to work with.
Title: Re: Array Help
Post by: GDF on August 01, 2019, 04:53:44 PM
No problem...

Thanks anyway
Title: Re: Array Help
Post by: GDF on August 01, 2019, 06:09:18 PM
I think I found a solution:

The (setq ss (ssadd (entlast) ss)) was not picking up all of the linework in the selection set..


Replaced  (createblock-elev ss a))

With         (createblock-elev (ssget "X" '((0 . "LINE")(8 . "A-GLAZ-MULL"))) a))
Title: Re: Array Help
Post by: GDF on August 02, 2019, 09:45:50 AM
For those following this thread, it was never an array problem. The problem was selection set gathering.

I also modified the code to replace the "Create Block Function" function with a "Raddom Generator Number" function.


Sorry for the confusion.