Jump to content

error: bad argument type: point: nil


Recommended Posts

Posted (edited)

Hello All,

 

I am working on several programs to increment an attribute tag value and they seem to be working very well. During this process I decided to remove the looping functions that I normaly use and replace it with while. I ran into a few obstacles, But I got through it. I wanted the program to loop the insert command and when I right click the mouse it would return back to the dialog main function. Upto this point all seems to be working well except when I exit the program through the exit button, The program exits and leaves this message at the prompt:error: bad argument type: point: nil

 

This portion of the program is all I modified to get this error.

 

     (while
       (progn
         (setq INPT (getpoint "\nInsertion point:"))[color=red];Get the insertion point[/color]
         (cond
           ((= INPT nil)(ECP_MF)))                       [color=red];When right click of mouse, Go to main function[/color]
         (setq IANG (getpoint INPT)                    [color=red];Get the insertion angle[/color]
               INPT (trans INPT 1 0)                     [color=red];Translate insertion point coords[/color]
               IANG (trans IANG 1 0)                     [color=red];Translate insertion angle coords[/color]
               RAD# (angle INPT IANG)                  [color=red];Get the angle in radians[/color]
               DEG# (ECP_RTD RAD#))                  [color=red];Convert radians to degrees[/color]
         (if (and (> DEG# 90.0)(<= DEG# 270.0))  [color=red];If insertion direction is > 90deg and <= to 270deg[/color]
           (progn
             (setq RAD# (ECP_DTR (+ DEG# 180.0))))) [color=red];Add 180deg to DEG# and convert to radians[/color]
         (command "._-insert" BNAM$ INPT 1 1 DEG#) [color=red];Insert block[/color]
         (ECP_IAV)))))                                          [color=red]; Go to selectionset functions[/color]
 (princ))
(princ)

 

Any clues as to what is wrong would be quite helpful. As far as I know the nil error would be from the right click of the mouse, But how to clear it is a bit confusing.

 

Thanks

Edited by The Buzzard
Posted

Hello Buzzard.

 

I hope that my guess would give a help. :)

 

have you added the (defun *error* ( msg ) to your Program ? It might help to obtain the sudden exit.

 

Wish you best of luck.

 

Tharwat

Posted
Hello Buzzard.

 

I hope that my guess would give a help. :)

 

have you added the (defun *error* ( msg ) to your Program ? It might help to obtain the sudden exit.

 

Wish you best of luck.

 

Tharwat

 

Thats the odd part. I have this on my exit button:

  (action_tile "cancel" "(done_dialog)(setq BUTTON nil)[color=red](ECP_RUS)[/color]")

 

The ECP_RUS function goes to my restore user settings function. It should clear the error although I am not sure.

But thats a good point, I should look into that since this is kind of an intentional error.

 

And Thanks

Posted

Its hard to say for sure without seeing a bit more code

 

What is the Return Value of the ECP_IAV function? As it is the last function to be evaluated in the progn statement a nil here could end the function

Posted

Another possibility could be to move the (ECP_MF) outside the while loop

 

(while

 (and
   (setq INPT (getpoint "\nInsertion point:"))
   (setq IANG	(getpoint INPT))
   )
 (setq INPT (trans ...  )))

(ECP_MF)

 

Regards

 

Jammie

Posted
Another possibility could be to move the (ECP_MF) outside the while loop

 

(while

(and
(setq INPT (getpoint "\nInsertion point:"))
(setq IANG (getpoint INPT))
)
(setq INPT (trans ... )))

(ECP_MF)

 

Regards

 

Jammie

 

The point to having it where it is when INPT is nil or the right click of the mouse , I want the program to return to the dialog which is run thru ECP_MF.

The ECP_IAV function is just a selection set function after the object is inserted. If INPT returns nil and goes to ECP_MF it will never get to the selection set which is the intention. Since INPT has a nil value I believe this is whats causing the error, But I cannot clear it before the program exits. which is what I want to do.

Posted

Have you tried to change the settings of the options in Autocad to Right Click option ?

 

Or, you may do not give the chance to the program to exit unless to chose an options ( Exit the Program [Yes/No] : )

 

What you think ?

Posted
Have you tried to change the settings of the options in Autocad to Right Click option ?

 

Or, you may do not give the chance to the program to exit unless to chose an options ( Exit the Program [Yes/No] : )

 

What you think ?

 

Right clicking the mouse is the intent to cause INPT to go nil which brings me back to the dialog where I can exit thru the exit button. All this works great. I just get the message after the program has ended.

Posted
The point to having it where it is when INPT is nil or the right click of the mouse , I want the program to return to the dialog which is run thru ECP_MF.

The ECP_IAV function is just a selection set function after the object is inserted. If INPT returns nil and goes to ECP_MF it will never get to the selection set which is the intention. Since INPT has a nil value I believe this is whats causing the error, But I cannot clear it before the program exits. which is what I want to do.

 

The problem could be that you are still in the while loop after evaluating (ECP_MF)

 

 (cond
           ((= INPT nil)(ECP_MF)))

 

When ECP_MF completes, as there is no break point AutoCAD interprets ECP_MF as a sub function & will continue with the original loop

 

The next line

(setq IANG (getpoint INPT) 

 

could thow an error now if INPT is nil

Posted
The problem could be that you are still in the while loop after evaluating (ECP_MF)

 

 (cond
((= INPT nil)(ECP_MF)))

 

When ECP_MF completes, as there is no break point AutoCAD interprets ECP_MF as a sub function & will continue with the original loop

 

The next line

(setq IANG (getpoint INPT) 

 

could thow an error now if INPT is nil

 

Thanks for that jammie, But I already found that out while continuing to mess with it point by point. I will have to find another way. Thanks

Posted

Good looking out jammie. I got it fixed by trial and error and there was plenty of both.

The program works great. I will post it when its complete.

 

Thanks you and tharwat313 for the help.

 

Here is the section I fixed.

     (while
       (setq INPT (getpoint "\nInsertion point:"))
       (if
         (/= INPT nil)
         (progn
           (setq IANG (getpoint INPT "\nGet orientation angle:")
                 INPT (trans INPT 1 0)
                 IANG (trans IANG 1 0)
                 RAD# (angle INPT IANG)
                 DEG# (ECP_RTD RAD#))
           (command "._-insert" BNAM$ INPT 1 1 DEG#)
           (ECP_IAV)
         )
       )
     )
     (ECP_MF)
   )
 )
 (princ))

Posted
Thanks you and tharwat313 for the help.

 

Your welcome The Buzzard, glad to be of some help. Sounds like your program is coming along nicely

 

Regards

 

jammie

Posted

Congratulations Buzzard.

 

I was sure that you would make it, and I am so happy for you .

 

Best Regards,

 

Tharwat

Posted (edited)

Thanks Guys,

Edited by The Buzzard

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...