Author Topic: Error message "commands may not be nested more than 4 times deep"  (Read 3185 times)

0 Members and 1 Guest are viewing this topic.

iliekater

  • Guest
I got the strange error message saying "commands may not be nested more than 4 times deep" :

Here is the link (lately I can no longer attach pictures on normal size , I wander why...) :
http://img340.imageshack.us/img340/8742/nested4timesdeeprf1.jpg

Anyway , the thing is that I can only press OK and then AutoCAD aborts !
This problem only appeared when I added some code on a Lisp command . You see lately I found a way to stop the program going further unless the user provides a value to a variable needed . The code looks like that :
Code: [Select]
( while ( = MyVariable nil )
        ( setq MyVariable ( getpoint txt_"bla bla bla" ) ) )

You see , the code runs fine , unless the user causes the loop to take place for four times (i.e. instead of specifying a point , he pressed ENETER or enter a numeric value in the command line etc) .
So I guess there is something that AutoCAD doesn't like in the above code ...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Error message "commands may not be nested more than 4 times deep"
« Reply #1 on: June 24, 2007, 04:43:27 AM »
I think you'll need to post the code before and after that statement for us to find the problem.

The code you posted will NOT cause the nesting error.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Error message "commands may not be nested more than 4 times deep"
« Reply #2 on: June 24, 2007, 06:43:03 AM »
To expand on what Kerry said, you can test this by running the code you posted at the command line....it will run forever until you enter a valid point or cancel it.

One thing that WILL cause it is an external command (see the documentation for External Commands) being called more than 4 times, not necessarily "nested" as the error would lead you to believe. Such as (command "align").....

The list of these is getting smaller with each release. In 2002 there were more than 20, but 2008 only lists 5, so Autodesk is converting more of these to native code (or just dropping them altogether).

iliekater

  • Guest
Re: Error message "commands may not be nested more than 4 times deep"
« Reply #3 on: June 24, 2007, 08:27:56 AM »
Well actually I am uing the ALIGN command ! Here's the code before :

Code: [Select]
( if ( /= ObjectsForUltraAlign nil )
       ( progn
         ( setq 1stBasePointForULTRAALIGNs ( getpoint txt_1stSourcePoint ) )
         ( setq 1stDestinationPointForULTRAALIGNs ( getpoint txt_1stDestinationePoint ) )
         ( setq 2ndBasePointForULTRAALIGNs ( getpoint txt_2ndSourcePoint ) )
         ( setq 2ndDestinationPointForULTRAALIGNs ( getpoint txt_2ndDestinationePoint ) )
         ( setq 3rdBasePointForULTRAALIGNs ( getpoint txt_3rdSourcePoint ) )
( if ( /= 3rdBasePointForULTRAALIGNs nil )
              ( setq 3rdDestinationPointForULTRAALIGNs ( getpoint txt_3rddDestinationePoint ) ) )
         ( princ )
( if ( = 3rdBasePointForULTRAALIGNs nil )
              ( command "ALIGN" ObjectsForUltraAlign "" 1stBasePointForULTRAALIGNs 1stDestinationPointForULTRAALIGNs
                                2ndBasePointForULTRAALIGNs 2ndDestinationPointForULTRAALIGNs "" "" )


And after :
Code: [Select]
( if ( /= ObjectsForUltraAlign nil )
       ( progn
( while ( = 1stBasePointForULTRAALIGNs nil )
                 ( setq 1stBasePointForULTRAALIGNs ( getpoint txt_1stSourcePoint ) ) )
( while ( = 1stDestinationPointForULTRAALIGNs nil )
                 ( setq 1stDestinationPointForULTRAALIGNs ( getpoint txt_1stDestinationePoint ) ) )
( while ( = 2ndBasePointForULTRAALIGNs nil )
                 ( setq 2ndBasePointForULTRAALIGNs ( getpoint txt_2ndSourcePoint ) ) )
( while ( = 2ndDestinationPointForULTRAALIGNs nil )
                 ( setq 2ndDestinationPointForULTRAALIGNs ( getpoint txt_2ndDestinationePoint ) ) )
         ( setq 3rdBasePointForULTRAALIGNs ( getpoint txt_3rdSourcePoint ) )
( if ( /= 3rdBasePointForULTRAALIGNs nil )
              ( setq 3rdDestinationPointForULTRAALIGNs ( getpoint txt_3rddDestinationePoint ) ) )
         ( princ )
( if ( = 3rdBasePointForULTRAALIGNs nil )
              ( command "ALIGN" ObjectsForUltraAlign "" 1stBasePointForULTRAALIGNs 1stDestinationPointForULTRAALIGNs
                                2ndBasePointForULTRAALIGNs 2ndDestinationPointForULTRAALIGNs "" "" )

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Error message "commands may not be nested more than 4 times deep"
« Reply #4 on: June 24, 2007, 10:35:56 AM »
OK, so per the help on the Align function, change it to this and you should be good to go.
Code: [Select]
(ALIGN ObjectsForUltraAlign  1stBasePointForULTRAALIGNs 1stDestinationPointForULTRAALIGNs
                                2ndBasePointForULTRAALIGNs 2ndDestinationPointForULTRAALIGNs "" "2d" )
You may need to experiment to get the syntax correct for ALIGNs other than 2d. Good Luck!

Adesu

  • Guest
Re: Error message "commands may not be nested more than 4 times deep"
« Reply #5 on: June 24, 2007, 07:51:04 PM »
Hi iliekater,
Before you load External Commands, use this

Code: [Select]
(if
 (not (member "geom3d.arx" (arx)))
    (arxload "geom3d"))
(rotate3d p4 "x" p3 "r" 0 90) ; change as you need

Well actually I am uing the ALIGN command ! Here's the code before :

Code: [Select]
( if ( /= ObjectsForUltraAlign nil )
       ( progn
         ( setq 1stBasePointForULTRAALIGNs ( getpoint txt_1stSourcePoint ) )
         ( setq 1stDestinationPointForULTRAALIGNs ( getpoint txt_1stDestinationePoint ) )
         ( setq 2ndBasePointForULTRAALIGNs ( getpoint txt_2ndSourcePoint ) )
         ( setq 2ndDestinationPointForULTRAALIGNs ( getpoint txt_2ndDestinationePoint ) )
         ( setq 3rdBasePointForULTRAALIGNs ( getpoint txt_3rdSourcePoint ) )
( if ( /= 3rdBasePointForULTRAALIGNs nil )
              ( setq 3rdDestinationPointForULTRAALIGNs ( getpoint txt_3rddDestinationePoint ) ) )
         ( princ )
( if ( = 3rdBasePointForULTRAALIGNs nil )
              ( command "ALIGN" ObjectsForUltraAlign "" 1stBasePointForULTRAALIGNs 1stDestinationPointForULTRAALIGNs
                                2ndBasePointForULTRAALIGNs 2ndDestinationPointForULTRAALIGNs "" "" )


And after :
Code: [Select]
( if ( /= ObjectsForUltraAlign nil )
       ( progn
( while ( = 1stBasePointForULTRAALIGNs nil )
                 ( setq 1stBasePointForULTRAALIGNs ( getpoint txt_1stSourcePoint ) ) )
( while ( = 1stDestinationPointForULTRAALIGNs nil )
                 ( setq 1stDestinationPointForULTRAALIGNs ( getpoint txt_1stDestinationePoint ) ) )
( while ( = 2ndBasePointForULTRAALIGNs nil )
                 ( setq 2ndBasePointForULTRAALIGNs ( getpoint txt_2ndSourcePoint ) ) )
( while ( = 2ndDestinationPointForULTRAALIGNs nil )
                 ( setq 2ndDestinationPointForULTRAALIGNs ( getpoint txt_2ndDestinationePoint ) ) )
         ( setq 3rdBasePointForULTRAALIGNs ( getpoint txt_3rdSourcePoint ) )
( if ( /= 3rdBasePointForULTRAALIGNs nil )
              ( setq 3rdDestinationPointForULTRAALIGNs ( getpoint txt_3rddDestinationePoint ) ) )
         ( princ )
( if ( = 3rdBasePointForULTRAALIGNs nil )
              ( command "ALIGN" ObjectsForUltraAlign "" 1stBasePointForULTRAALIGNs 1stDestinationPointForULTRAALIGNs
                                2ndBasePointForULTRAALIGNs 2ndDestinationPointForULTRAALIGNs "" "" )

Jochen

  • Newt
  • Posts: 30
Re: Error message "commands may not be nested more than 4 times deep"
« Reply #6 on: June 25, 2007, 03:15:45 AM »
Some times ago I had trouble in using the ALIGN-command too - so I made my own:

(defun C:XALIGN(/ p1 p2 p3 q1 q2 q3 ep1 ep2 ep3 eq1 eq2 eq3 auswahl pp2 pp3 qq1 qq2)
; scj, www.black-cad.de, 2007
   (setq nullpunkt (list 0 0 0))
   (command "_UCS" "_W")
   (setq P1 (getpoint "\nStartpoint 1: "))
      (command "_point" p1)
      (setq ep1 (entlast))
   (setq Q1 (getpoint "\nTargetpoint 1: "))
      (command "_point" q1)
      (setq eq1 (entlast))
   (setq P2 (getpoint "\nStartpoint 2: "))
      (command "_point" p2)
      (setq ep2 (entlast))
   (setq Q2 (getpoint "\nTargetpoint 2"))
      (command "_point" q1)
      (setq eq2 (entlast))
   (setq P3 (getpoint "\nStartpoint 3: "))
      (command "_point" p3)
      (setq ep3 (entlast))
   (setq Q3 (getpoint "\nTargetpoint 3"))
      (command "_point" q3)
      (setq eq3 (entlast))

   (prompt"\npick the objects to align")
   (setq auswahl (ssget))
   (command "_move" auswahl ep1 ep2 ep3 "" p1 q1)
   (setq pp2 (cdr (assoc 10 (entget ep2))))
   (command "_ucs" "_3p" q1 q2 pp2)
   (setq qq1 (trans q1 0 1))
   (setq pp2 (trans pp2 0 1))
   (setq qq2 (trans q2 0 1))
   (command "_rotate" auswahl ep1 ep2 ep3 "" qq1 "B" qq1 pp2 qq2)
   (command "_UCS" "_w")
   (command "_ucs" "_ZA" q2 q1)
   (setq pp3 (trans (cdr (assoc 10 (entget ep3))) 0 1))
   (setq q3 (trans q3 0 1))
   (command "_rotate" auswahl "" nullpunkt "B" nullpunkt pp3 q3)
   (princ)
); end xalign.lsp

Good luck
Jochen

iliekater

  • Guest
Re: Error message "commands may not be nested more than 4 times deep"
« Reply #7 on: June 25, 2007, 07:38:53 AM »
Thank you all for your replies . I will try your advice and reply . However , I wonder : what is an external command ?

iliekater

  • Guest
Re: Error message "commands may not be nested more than 4 times deep"
« Reply #8 on: July 16, 2007, 08:11:51 AM »
I changed the code the way you told me and suprisingly the ALIGN command was recognised ! However , now when I run the lisp command , I get an error message saying :
Quote
Null argument not allowed .
What's that ?