Dimaligned command produces "no function definition: nil" error upon completion

Dimaligned command produces "no function definition: nil" error upon completion

DerekX9SQ2
Contributor Contributor
1,834 Views
17 Replies
Message 1 of 18

Dimaligned command produces "no function definition: nil" error upon completion

DerekX9SQ2
Contributor
Contributor

Hi!

 

I've written an AutoLISP script that helps me with some of my day-to-day activities. I'm currently running into a problem while trying to create DIMALIGNED objects. 

 

Here's the line:

 

 

(command "dimaligned" (car (cdr (nth 0 actMlist))) (car (cdr (nth 1 actMlist))) "t" (strcat "RISE: " (rtos rise 2 2) "' \n" "RUN: " (rtos run 2 4) "' \n SLOPE: " slope "%") (car (cdr (nth 0 actMlist))))

 

 

 

This line executes with no problems. It creates an Aligned Dimension, changes the text as desired, and places it where I want it. However, no matter what code I put after this line, it tries to execute it as a function. I've tried replacing the last point with a pause and finishing the command with ("") at the end and  (command) on the next line to no avail. Any help here would be great! 

 

Here's a screenshot. I'll be happy to provide more information if needed.

 

1.jpg

0 Likes
Accepted solutions (2)
1,835 Views
17 Replies
Replies (17)
Message 2 of 18

Sea-Haven
Mentor
Mentor

I remember  "exit" not "" I seem to remember had to do with some code related to dimensions. 

 

(command "DIM" "align" pt1 pt4 pt3 "" "exit")

 

0 Likes
Message 3 of 18

DerekX9SQ2
Contributor
Contributor

When I tried exit it said: 

 

(command "dimaligned" (getpoint)(getpoint)(getpoint) "_exit")

Command: exit Unknown command "EXIT".  Press F1 for help.
Command: nil

 

0 Likes
Message 4 of 18

DerekX9SQ2
Contributor
Contributor

I just tried finishing the line with: 

 

'""

 

so that it looks like :

(command "dimaligned" (car (cdr (nth 0 actMlist))) (car (cdr (nth 1 actMlist))) "t" (strcat "RISE: " (rtos rise 2 2) "' \n" "RUN: " (rtos run 2 4) "' \n SLOPE: " slope "%") (car (cdr (nth 0 actMlist))) `"")

 

and when it finishes executing that line, it tries to re-run the function that I'm currently in.

 

To clarify, I type "ds1" to start the command, it runs until the error, and then it tried to run "ds1" again. 

 

Here's a picture of the error log,

 

1.jpg

0 Likes
Message 5 of 18

wispoxy
Advisor
Advisor
You can't assign EXIT. It's already an autocad default.
0 Likes
Message 6 of 18

wispoxy
Advisor
Advisor

Why not just:

(defun c:MyDimAligned ()
  (setq actMlist '((1 2) (3 4))) ; Replace with your actual point coordinates
  (setq rise 5.67) ; Replace with your actual rise value
  (setq run 3.45) ; Replace with your actual run value
  (setq slope 12.34) ; Replace with your actual slope value

  (setq output-string
        (strcat
         "RISE: " (rtos rise 2 2) "'\n"
         "RUN: " (rtos run 2 4) "'\n"
         "SLOPE: " (rtos slope 2 2) "%"))

  (princ output-string)
)
0 Likes
Message 7 of 18

DerekX9SQ2
Contributor
Contributor

I want to use a dimaligned because it's a standard I'm tied to with my employer. At this point I'm honestly just really confused at what's happening to throw this error. It seems like the autoLISP interpreter doesn't exit the dimaligned command properly. 

 

Making it even more perplexing, it will execute lines of code AFTER the dimaligend command UNTIL it exits the current function, here's what I mean:

 

(defun riseRunSlope ()
	(setq rise (abs (- (car (nth 0 actMlist)) (car (nth 1 actMlist)))))  
	(setq slope (rtos (* 100 (/ rise run)) 2 2))
	(setq plineFlag nil)
	(command "dimaligned" (car (cdr (nth 0 actMlist))) (car (cdr (nth 1 actMlist))) "t" (strcat "RISE: " (rtos rise 2 2) "' \n" "RUN: " (rtos run 2 4) "' \n SLOPE: " slope "%") (car (cdr (nth 0 actMlist))) `"")
	(princ "\n hi \n")
	(princ "\n WHY?!!?!?!?!?! \n")
	(princ (+ 10 15))
	(princ "Still executing")
)

 

1.jpg

 

Notice that it runs all the way to the last print function and then tries to execute the text inside of the last print as a function.

0 Likes
Message 8 of 18

wispoxy
Advisor
Advisor
Try (exit) to end function
0 Likes
Message 9 of 18

DerekX9SQ2
Contributor
Contributor

@wispoxy wrote:
Try (exit) to end function

That appears to exit the entire LISP function and not just the function at the level the code is executed.

0 Likes
Message 10 of 18

marko_ribar
Advisor
Advisor

You don't have assigned "run" variable...

Check your code before posting...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 11 of 18

DerekX9SQ2
Contributor
Contributor

I just posted a snippet as the code is 200+ lines. Here's the file

0 Likes
Message 12 of 18

marko_ribar
Advisor
Advisor
Accepted solution

Please, have a look how I used DIMALIGNED command... It accepts 3 points and that's all - there should be no "" at the end or anywhere inbetween specified points...

Here is the link : https://forums.augi.com/showthread.php?168619-Automatically-dimension-all-sides-and-angles-of-select... 

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 13 of 18

Kent1Cooper
Consultant
Consultant

Is there any chance you're working with a redefined DIMALIGNED command?  What if you force use of the native command with the period prefix?

(command ".dimaligned" ...)

Kent Cooper, AIA
0 Likes
Message 14 of 18

DerekX9SQ2
Contributor
Contributor

@marko_ribar wrote:

Please, have a look how I used DIMALIGNED command... It accepts 3 points and that's all - there should be no "" at the end or anywhere inbetween specified points...

Here is the link : https://forums.augi.com/showthread.php?168619-Automatically-dimension-all-sides-and-angles-of-select... 


I got this to work! Thank you very much!!!

0 Likes
Message 15 of 18

DerekX9SQ2
Contributor
Contributor

@Kent1Cooper wrote:

Is there any chance you're working with a redefined DIMALIGNED command?  What if you force use of the native command with the period prefix?

(command ".dimaligned" ...)


I wasn't able to get this to work. I fixed it by using (vla-adddimaligned)

0 Likes
Message 16 of 18

Sea-Haven
Mentor
Mentor

I tried this in my Bricscad V20 and it worked.

 

(command "dimaligned" (getpoint "\nP1")(getpoint "\nP2")(getpoint "\nP3") )

 

0 Likes
Message 17 of 18

DerekX9SQ2
Contributor
Contributor
Accepted solution

I found and fixed the error at the end of the day yesterday! I was calling (progn) inside an (if) condition. That's why it kept trying to execute the last line of the function.

 

My code looked like this:

 

 

(if (= a b)
     (
          (progn
               (vla-adddimaligned pt1 pt2 pt1)
               (setq var 1)
          )
     )
     ;else
     ()
)
​

 

 

 

 

 

when it needed to look like this:

 

 

(if (= a b)
     (progn
          (vla-adddimaligned pt1 pt2 pt1)
          (setq var 1)
     )
     ;else
     ()
)
​

 

 

 

 

0 Likes
Message 18 of 18

Sea-Haven
Mentor
Mentor

You don't need a else. Sometimes I add an else or true false so can see what has happened.

 

(if (= a b)
     (progn
          (vla-adddimaligned pt1 pt2 pt1)
          (setq var 1)
      )
)


(if (= a b)
     (progn
          (vla-adddimaligned pt1 pt2 pt1)
          (setq var 1)
     )
     (princ "\nnot =")
)

 

 

 

 

0 Likes