Jump to content

Recommended Posts

Posted

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.

 

--

Posted

I was under the impression that it needed both of them I'll try it with just the one and see what happens.

Posted

try changing this

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

to this and see if it works

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

Posted

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

     
      
      
          

Posted

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

Posted

Right cheers for the tips Lee.

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

 

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

Posted

Sorry missed a parenthesis, it works fine, thanks loads Lee!

Posted
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

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