
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I work with a solar company, and I am tasked with designing the sites. Doing this, we use a block for the solar panels I place on a site.
I am trying to write a function that will:
- ask us how many arrays we want to place (this works)
- ask us where we want to insert the first array (this works)
- then based on the answer to 1, adds more arrays in the format we want.
Our arrays are spaced 20ft appart from the bottom of an array to the top of the next array. I have commented out the lines in the loop I think are causing the problem. 6.42 is the width of one row in the array, and 284.26 is the length of a row in the array, as you will see I used these lengths to make the insertion point at the top left of my array, the original insertion point is the bottom right side of the array.
I have a function that works that just sets down a single array at my wanted insertion point (identical to the top part of my code here), but I'd like it to put down multiple arrays if the user wants it.
Whats wierd is that it:
- changes the x position to something different than my "final X'
- it seems to only put one array down, and its the 'last' one of the total arrays I want.
We don't use the 'row' quantity in rectangle array for these solar modules because we want to be able to adjust each row as needed to fit our sites. Thus, we use rect array and adjust the 'columns' quantity to add or subtract the modules.
Here's the function that works for laying down a single set of modules:
(defun c:RBI84() (setq pointA (getpoint "\n Select the insertion point: ")) (setq FinalX (+ (car pointA) 6.42)) (setq FinalY (- (car (cdr pointA)) 284.26)) (setq FinalPoint (list FinalX FinalY 0.0)) (command "-Insert" "1-RBI 84" FinalPoint "1.0" "1.0" "0.0") (command "Arrayrect" (entlast) "" "1" "19" "Rows" "1" "1" "0" "COLumns" "2" "19" "") )
That looks like this when its done:
Here's how I'd like the function that doesn't work to look when its done (if the user wants 2 arrays):
Heres the function that doesn't work:
(defun c:TestRBI84() (setq NumberOfRows (getint "\n How many arrays do you want to place")) (setq pointA (getpoint "\n Select the insertion point: ")) (if (<= NumberofRows 1) ( (setq FinalX (+ (car pointA) 6.42)) (setq FinalY (- (car (cdr pointA)) 284.26)) (setq FinalPoint (list FinalX FinalY 0.0)) (command "-Insert" "1-RBI 84" FinalArrayPoint "1.0" "1.0" "0.0") (command "Arrayrect" (entlast) "" "1" "19" "Rows" "1" "1" "0" "COLumns" "2" "19" "") ) ( (while (>= NumberOfRows 2) ( (setq FinalArrayX FinalX) (setq FinalArrayY (+ FinalY (* NumberOfRows 304.26))) ;20ft plus array length (setq FinalArrayPoint (list FinalX FinalArrayY 0.0)) ;(command "Copy" (entlast) FinalPoint FinalArrayPoint) ;(command "-Insert" "1-RBI 84" FinalArrayPoint "1.0" "1.0" "0.0") ;(command "Arrayrect" (entlast) "" "1" "19" "Rows" "1" "1" "0" "COLumns" "2" "19" "") (setq NumberofRows (- NumberOfRows 1)) ) ) ) ) )
Those three commented out lines are where the problem is, but I keep just getting "bad function" in cad.
Should I copy the original, or insert new blocks? Is there a different processing for duplicating the first array that I should go about?
Thanks!!
Solved! Go to Solution.