array 1 row

array 1 row

Lex_van_Ham
Advocate Advocate
1,548 Views
6 Replies
Message 1 of 7

array 1 row

Lex_van_Ham
Advocate
Advocate

I made a lisp file that creates an array with the values of R (rows) K (columns) L (Lenght) B (Width)

and when i make the array 1 row it uses the value of L where it should be B

(command "array" "_last" "" "Rectangular" R K (+ L 12)(+ B 2))

How do i fix this?1.PNG

0 Likes
Accepted solutions (1)
1,549 Views
6 Replies
Replies (6)
Message 2 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

True -- when there's only one row, the command doesn't ask for a spacing between them [it, actually].  You can take the command to the point of having gotten the number of rows and columns, and then follow up with answers to the spacings depending on whether there's more than one of either or both.  Lightly tested:

 

(command "array" "_last" "" "Rectangular" R K); leaves you in Array command
(if (> R 1) (command (+ L 12))); feed in row spacing only if applicable
(if (> K 1) (command (+ B 2))); likewise for column spacing
Kent Cooper, AIA
Message 3 of 7

Lex_van_Ham
Advocate
Advocate

In my dialog box i have the option to select portret and landscape default is portret but when you click landscape it should switch the values of L and B dow do i do this?

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

Maybe just like this...

 

(command "array" "_last" "" "Rectangular" R K)
(if (> R 1) (command (+ (if (= page "Landscape") L B)
                        12)))
(if (> K 1) (command (+ (if (= page "Landscape") B L)
                        2)))
0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant

@lexvanham123 wrote:

In my dialog box i have the option to select portret and landscape default is portret but when you click landscape it should switch the values of L and B dow do i do this?


Another way would be just what you describe.  First, do this:

 

(if (= page "Landscape") (setq temp L L B B temp))

 

then run the code in Post 2.

Kent Cooper, AIA
0 Likes
Message 6 of 7

Lex_van_Ham
Advocate
Advocate

I have a new problem now...

When I enter 1 as a value for both R and  K I get:

One-element array, nothing to do.
; error: Function cancelled

0 Likes
Message 7 of 7

Kent1Cooper
Consultant
Consultant

@Lex_van_Ham wrote:

I have a new problem now...

When I enter 1 as a value for both R and  K I get:

One-element array, nothing to do.
; error: Function cancelled


[Might it not be just as well to be notified if they're both 1, meaning there's nothing to do?]

 

But if there are valid circumstances that might lead to that, presumably within some longer routine, one way to handle it would be:

(if (or (> R 1) (> K 1))
  (progn ; then
    (command "array" "_last" "" "Rectangular" R K); leaves you in Array command
    (if (> R 1) (command (+ L 12))); feed in row spacing only if applicable
    (if (> K 1) (command (+ B 2))); likewise for column spacing
  ); progn
); if
Kent Cooper, AIA