Jump to content

Can someone see where I'm going wrong?


Fire_col

Recommended Posts

I removed this and now it at least loads...

 

 

;*****************************************************************************************************************

 

(princ)

)

;*****************************************************************************************************************

 

The Polar calculations have issues...

 

Looks like the c:dtr is looking for "x" and no "x" is being passed to it.

 

Not sure what you are trying to calculate in order to be of further help.

 

--

Link to comment
Share on other sites

This should work:

 

; BY COLIN MACKENZIE
; DRAWS SPRINKLER HEAD WITH MAX RADIUS

;*****************************************************************************************************************

(defun C:head (/ oldsnap oldblipmode ip r1 r2 r3)
 ;define the function

;*****************************************************************************************************************
 ;Save System Variables
 
 (setq oldsnap (getvar "osmode")) ;save current snap settings
 
 (setq oldblipmode (getvar "blipmode")) ; save current blipmode settings

;*****************************************************************************************************************
 ;switch OFF system variables
 
 (setvar "osmode" 2)
 (setvar "blipmode" 0)

;*****************************************************************************************************************
 ;Get User Input
 
 (setq ip (getpoint ":\nEnter Insertion Point : "))

;*****************************************************************************************************************
 ;Polar Calculations
 
 (setq r1 (polar ip (dtr 180.0) 59   ))
 (setq r2 (polar ip (dtr 180.0) 119  ))
 (setq r3 (polar ip (dtr 180.0) 3200 ))

;*****************************************************************************************************************
 ; Command Function

 (command "circle" ip r1 
      "circle" ip r2 
      "circle" ip r3
 )       

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

;*****************************************************************************************************************
      
 (princ)
 ; Finish Cleanly

) ;End Function

    
;*****************************************************************************************************************
 ; Converts Degrees to Radians

(defun dtr (x) (* pi (/ x 180.0)))

     
      
      
          

Link to comment
Share on other sites

A few notes on where you went wrong:

 

  • You suppressed the return of the dtr function using princ, so the value would not be returned when used in the main function.

  • DTR was defined as a function to be invoked at the command line, not a sub-function.

  • You enclosed your arguments for the polar function within brackets, which would indicate they are functions in themselves.

  • You should always localise your variables.

  • You don't actually need (vl-load-com), as you are not using any Visual LISP functions.

Lee

Link to comment
Share on other sites

Right cheers for the tips Lee.

But now it says ;error: bad argument type : numberp

 

Now I'm really confused. What's numberp?

Link to comment
Share on other sites

Right cheers for the tips Lee.

But now it says ;error: bad argument type : numberp

 

Now I'm really confused. What's numberp?

 

FYI,

 

stringp -- argument should be a string (but isn't)

numberp -- argument should be a number

fixnump -- argument should be an integer [eg. try (itoa 1.2) ]

etc etc

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