Jump to content

error: bad argument type: 2D/3D point: nil


mitchellrodhous

Recommended Posts

Hi,

 

By the fellowing lispI get the next error:

 

error: bad argument type: 2D/3D point: nil

 

I put the complete file/tekst below..

Does anyone know what is going wrong?

YESTERDAY it worked correctly:(

 

(defun c:test ()
 ;define the function

 ;*

 ;Save System Variables
 (setq oldsnap (getvar "osmode"))

 ;save snap settings
 (setq oldblipmode (getvar "blipmode"))
 ;save blipmode setting
 ;*
 ;Switch OFF system Variables
 (setvar "osmode" 0)
 ;Switch OFF snap
 (setvar "blipmode" 0)
 ;Switch OFF Blipmode
 ;*test

 ;get User Inputs
 (initget (+ 1 2 4))
 ;check user input
 (setq b (getdist "\nBreedte van de kast : "))
 ;Krijg de Breedte van de kast

 (initget (+ 1 2 4))
 ;check user input
 (setq h (getdist "\nHoogte van de kast : "))
 ;Krijg de Hoogte van de kast
 (initget (+ 1 2 4))
 ;check user input
 (setq d (getdist "\nDiepte binnenwerk van de kast : "))
 ;Krijg de Diepte binnenwerk van de kast
 (initget (+ 1 2 4))
 ;check user input
 (setq m (getdist "\nMateriaaldikte van de kast : "))
 ;Krijg de Materiaaldikte van de kast
 (initget (+ 1 2 4))
 ;check user input
 (setq a (getdist "\nDikte achterwand van de kast : "))
 ;Krijg de dikte van de achterwand

 ;*

 ;Get Insertion Point
 (setq ip (getpoint "\nInsertion Point : "))
 ;get the insertion point
 (setvar "osmode" 32)
 ;switch ON snap
 (while ;start of while loop

 (setvar "osmode" 0)
 ;switch OFF snap
 ;*

 ;Start of Polar Calculations

 (setq p2 (polar ip (dtr -90.0) d))
 (setq p3 (polar p2 (dtr 360.0) m))
 (setq p4 (polar p3 (dtr 0.0) d))
 (setq p5 (polar ip (dtr 360.0) b))
 (setq p6 (polar p5 (dtr -90.0) d))
 (setq p7 (polar p6 (dtr 180.0) m))
 (setq p8 (polar p7 (dtr 0.0) d))
 (setq p9 (polar ip (dtr 90.0)a))
 (setq p10 (polar ip (dtr 360.0) b))
 ;End of Polar Calculations

 ;Start for Bottom
 (setq tp2 (polar ip (dtr 360.0) m))
 (setq tp3 (polar tp2 (dtr -90.0) d))
 (setq tp4 (polar p7 (dtr 0.0)0.0))
 ;End for Bottom
 (setq bt1 (polar tp5 (dtr 0.0) (+ m )))
 (setq bt2 (polar tp6 (dtr -90.0) (+ m )))

 ;Start for Top
 (setq tp5 (list (car tp2) (cadr tp2) (+ (caddr tp2) h)))
 (setq tp6 (list (car tp3) (cadr tp3) (+ (caddr tp3) h)))
 (setq tp7 (list (car tp4) (cadr tp4) (+ (caddr tp4) h)))


 ;End for Top

 ;*
 ;Start of Command Function

 (command "box" ip p3 h
    "box" p5 p7 h
          "box" tp2 tp4 m
   "box" tp5 tp7 (-(+ m))
   "box" p9 p10 h

) ;End Command

 ;End of Command Function
 ;*
(setvar "osmode" 32)
 ;switch ON snap
 );end System while loop

 ;*
 ;Reset System Variable
 (setvar "osmode" oldsnap)
 ;Reset snap
 (setvar "blipmode" oldblipmode)
 ;Reset blipmode

 ;*
 (princ)
 ;finish cleanly
 ) ;end of defun
;*
;This function converts Degrees to Radians.
(defun dtr (x)
 ;define degrees to radians function
 (* pi (/ x 180.0))
 ;divide the angle by 180 then
 ;multiply the result by the constant PI
) ;End of function
;*
(princ) ;load cleanly
;*

Link to comment
Share on other sites

Please take care that points tp5 and tp6 are used before assignment (excerpt from your code):

 

  ;End for Bottom
 (setq bt1 (polar [color=red]tp5[/color] (dtr 0.0) (+ m )))
 (setq bt2 (polar [color=red]tp6[/color] (dtr -90.0) (+ m )))

 ;Start for Top
 (setq [color=red]tp5[/color] (list (car tp2) (cadr tp2) (+ (caddr tp2) h)))
 (setq [color=red]tp6[/color] (list (car tp3) (cadr tp3) (+ (caddr tp3) h)))
 (setq tp7 (list (car tp4) (cadr tp4) (+ (caddr tp4) h)))

 

 

Since you didn't declare your variables as local, those are visible on drawing's namespace - probably yesterday tp5 and tp6 variables were available from a previous run, so the code worked.

 

Regards,

Link to comment
Share on other sites

Thanks for reply!

 

So If I change thoose two from position that part wil work, also in futher use?

Link to comment
Share on other sites

Yes - it draw something.

Also take care to place a condition to that while (may remove it at all), otherwise will run infinitely...

 

Regards,

Link to comment
Share on other sites

You’re welcome!

 

 

 

 

Some comments:

  • It will be very useful to use English prompts or at least English comments in your code – this way will be easiest for someone from forum to debug your code. There is no way to figure out what your inputs means.
  • Set the CMDECHO variable to 0, this way will avoid that annoying cascade of strings on command line.
  • Also (dtr 360.0) and (dtr 0.0) are equivalent .

Regards,

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