Jump to content

Array - Not sure why this isn't easy.


ILoveMadoka

Recommended Posts

If this worked, it would do exactly what I need to do (over and over and over)

(DEFUN C:A1 ()
(SETQ SS (SSGET))
(setq num (getint "Number of Rows:"))
(setq DIST "-0.9375")
(COMMAND "ARRAY" SS "" "RECTANGULAR" "COLUMNS" "1" "1" "ROWS" NUM DIST "" "")
(PRINC))

 

What it returns is:

 

Requires an integer between 1 and 32767.
; error: Function cancelled

 

I've tried all sorts of things but can't this to work.

 

Please help..

 

 

 

 

 

Edited by ILoveMadoka
Link to comment
Share on other sites

Try this. Tested in AutoCAD 2012

 

(DEFUN C:A1 (/ ss num dist);; LOCALISE YOUR VARIABLES
(SETQ ss (SSGET))
(setq num (getint "Number of Rows : "))
(setq dist -0.9375)                      ;;This needs to be a real number not a string
(COMMAND "-ARRAY" ss "" "_R" num 1 dist) ;;This needs to be "-ARRAY" NOT "ARRAY"
(PRINC))

 

If you want something different type the command on the command line and follow the options/prompts

 

(COMMAND "ARRAY" SS "" "RECTANGULAR" "COLUMNS" "1" "1" "ROWS" NUM DIST "" "")

My prompts/options don't follow this                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 

After "RECTANGULAR" should come "COUNT" then num of rows then num of columns (NOT strings) then distance

Edited by dlanorh
Added to Post
Link to comment
Share on other sites

See if this works

(defun c:a1 (/ ss num dist)
  (setq ss (ssget)
  (setq num (getint "\nEnter number of rows: "))
  (setq dist -0.9375)
  (command "-array" ss "" "rectangular" "columns" "1" "1" "rows" num dist "" "")
  (princ)
  )

Just notied that @dlanorh posted about the same time I did. His solution is better than mine.

Edited by jonathann3891
Link to comment
Share on other sites

ps: I'm using Autocad 2020

 

The prompts are:

 

Command: Array

Select Objects 

Array Type [Rect/Path/Polar]   Rectangular
Select grip to edit array or [ASsociative/Base point/COUnt/Spacing/COLumns/Rows/Levels/eXit]<eXit>: COLUMNS

Enter the number of columns or [Expression] <4>: 1

Specify the distance between columns or [Total/Expression] <1.0995>: 1

Select grip to edit array or [ASsociative/Base point/COUnt/Spacing/COLumns/Rows/Levels/eXit]<eXit>: ROWS

Enter the number of rows or [Expression] <3>: 5 <Variable NUM>

Specify the distance between rows or [Total/Expression] <0.8866>: -.9375 <Variable DIST>

Specify the incrementing elevation between rows or [Expresson] <0.0000>: <ENTER>

Select grip to edit array or [ASsociative/Base point/COUnt/Spacing/COLumns/Rows/Levels/eXit]<eXit>: <ENTER> to Exit

 

 

 

Jonathann3891

 

You left off a ")" after the ssget.

 

I am getting the same error as before with your code Sir..

 

 

dlanorh

 

Your code works perfectly...

(DEFUN C:A1 (/ ss num dist);; LOCALISE YOUR VARIABLES
(SETQ ss (SSGET))
(setq num (getint "Number of Rows : "))
(setq dist -0.9375)                      ;;This needs to be a real number not a string
(COMMAND "-ARRAY" ss "" "_R" num 1 dist) ;;This needs to be "-ARRAY" NOT "ARRAY"
(PRINC))

 

I guess -ARRAY is the legacy command.

 

Thank you so much!!

 

Link to comment
Share on other sites

Based on the command output, did you try this ?

 

(COMMAND "ARRAY" SS "" "_R" "_COL" 1 1.0 "_R" num dist "" "")

 The number of columns needs to be an integer and the distance a real. Does this still error?

Link to comment
Share on other sites

Same error

 

Requires an integer between 1 and 32767.
; error: Function cancelled

 

Your method works great!

 

Thank you again!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...