Is there a way to repeat more than the max number of arguments?

Is there a way to repeat more than the max number of arguments?

Anonymous
Not applicable
730 Views
8 Replies
Message 1 of 9

Is there a way to repeat more than the max number of arguments?

Anonymous
Not applicable

I'm getting the error: too many arguments: (REPEAT .....

is there a way around the max number of arguments?

0 Likes
Accepted solutions (1)
731 Views
8 Replies
Replies (8)
Message 2 of 9

Shneuph
Collaborator
Collaborator

What is your full repeat code?

 

 

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 3 of 9

stevor
Collaborator
Collaborator
' too many arguments: (REPEAT' Show, or attach, the code.
S
0 Likes
Message 4 of 9

Anonymous
Not applicable

I Just tried posting it but now it's not showing up..... maybe it's to long to post here lol  

 

It creates a radial platform acording to the data entered into an excel file.Radial Platform.jpg

0 Likes
Message 5 of 9

Anonymous
Not applicable

Ok I decided to put the code in a text file so I can post it.

0 Likes
Message 6 of 9

Anonymous
Not applicable
Accepted solution

Hi,

 

First thing is you have to separate your program into many sub functions. It will help you to minimize, identify and fix the bugs.

In your attached program I put your all code (exists inside the outermost while loop) in to a separate function and called that function in a repeat loop from another function. So, while loading, I did not get any error. Try this suggestion.

But, you should split up your program. Otherwise you can expect many more errors.

 

Regards

gsktry

0 Likes
Message 7 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Ok I decided to put the code in a text file so I can post it.


That's a lot to look through....

 

I'm not aware of their being any limit to the number of expressions you can have in a (repeat) function, so I imagine that it's some other function inside the (repeat) that's being fed too many arguments.

 

BUT if there is a limit in (repeat) itself, and it's purely in the number of AutoLISP functions you can have inside it, that code may well exceed it.  One thing you can do to reduce the sheer quantity of function calls used is to set more than one variable within one (setq) function.  You can replace these seven functions near the beginning:

 

  (setq endang (- (nth rn RSPEORIENT) (nth rn RSPSORIENT)))
  (setq endangp (* PI (/ (- 90.0 endang) 180.0)))
  (setq lninpt2 (polar TANKCTR endangp pltinrad))
  (setq lnoutpt2 (polar TANKCTR endangp pltoutrad))
  (setq mirang (/ endang 2))
  (setq mirangp (* PI (/ (- 90.0 mirang) 180.0)))
  (setq mirlnpt (polar TANKCTR mirangp pltoutrad))

 

with this one function:

 

  (setq

    endang (- (nth rn RSPEORIENT) (nth rn RSPSORIENT))
    endangp (* PI (/ (- 90.0 endang) 180.0))
    lninpt2 (polar TANKCTR endangp pltinrad)
    lnoutpt2 (polar TANKCTR endangp pltoutrad)
    mirang (/ endang 2)
    mirangp (* PI (/ (- 90.0 mirang) 180.0))
    mirlnpt (polar TANKCTR mirangp pltoutrad)

  )

 

Similarly, you can execute more than one consecutive command within one (command) function.  You can replace these four functions:

 

  (command "trim"
   (nth 0 ssent1)
   (nth 0 ssent2)
   ""
   radtrimpt1
   ""
   ""
  )
  (command "trim"
   (nth 0 ssent1)
   (nth 0 ssent2)
   ""
   radtrimpt2
   ""
   ""
  )
  (command
    "_insert"
    "C:/AutoCAD lsp Files/3D files/Platforms/Radial/Platform Inside Base.DWG"
    lninpt1
    ""
    ""
    ""
   )
  (command "explode" "l" "")

 

with this one function:

 

   (command

     "trim" (nth 0 ssent1) (nth 0 ssent2) "" radtrimpt1 "" "" ;;;;; is there an extra Enter at the end?
     "trim" (nth 0 ssent1) (nth 0 ssent2) "" radtrimpt2 "" "" ;;;;; is there an extra Enter at the end?
     "_insert" "C:/AutoCAD lsp Files/3D files/Platforms/Radial/Platform Inside Base.DWG" lninpt1 "" "" ""
     "explode" "l" ""

   )

 

and I think you can conflate those two Trim commands into one, also, since they use the same Trimming edges.

 

[And by the way, you don't need the .DWG filetype ending on the drawing name -- it won't Insert any other kind of file.]

Kent Cooper, AIA
0 Likes
Message 8 of 9

stevor
Collaborator
Collaborator

As I see your code:

'

(setq rn 0)
	(repeat  RSPNBC
	  (setq CNTR 0)
	  (setq TKCHT1 0)
	  (setq TKCHT2 (nth 0 TCHT))
	  (repeat NC...'
there 3 undefined variables:
RSPNBC, TCHT, and NC,
at the start, anyway.

Plus, there were 2 extras closing parens at the end.
Was this txt file all of the intended lsp?

The other recommendations also apply:
Combine the 'setq assignments
Form subroutines, espectially if redundant processes.


S
0 Likes
Message 9 of 9

Anonymous
Not applicable

Thanks for the help everyone.  I'll have to implement some of the changes that you recomended.  The sub functions worked perfect.

0 Likes