Jump to content

Recommended Posts

Posted

HI !

I HAVE A LISP, WHEN I DO, DISPLAY ERROR: NO FUNCTION DEFINITION: DTR

CAN YOU HELP ME !

THANKS ALL !

HAVE A NICE DAY !

;;; VE HUONG CHI
(defun C:HN (/ stp ep d1 d2 d3 d4 d5 ds ang d6 old_err old_hcosmode)
(setq old_err *error*
     *error* hc_err)
(setvar "CMDECHO" 0)
(setvar "BLIPMODE" 0)
(setq old_hcosmode(getvar "Osmode"))
(setvar "Osmode" 0)
(setq stp(getpoint "\nDiem Moc Cua Huong Chi:"))
(if(/= stp NIL)
  (progn
     (setq ep (getpoint "\nHuong:" stp))
     (setq ds (distance stp ep) ang (angle stp ep))
  )
 (princ "\nKhong xac dinh !") 
)
(if(and stp ep)
(progn
 (setq d1(polar stp (+ ang (dtr 90)) (/ (* ds 2) 3) ) 
       d6(polar stp (- ang (dtr 90)) (/ (* ds 2) 3) ) 
       d2(polar d1 ang (/ ds 2) )
       d3(polar d2 (+ ang (dtr 90)) (/ ds 3) )
       d5(polar d6 ang (/ ds 2) )
       d4(polar d5 (- ang (dtr 90)) (/ ds 3) )
 )
 (command "_.PLINE" d1 "W" "0" "0"
                    d2 d3 ep d4 d5 d6 d1 "" 
          "_.CHPROP" "L" "" "C" "4" "")
)
);end if.
(setvar "Osmode" old_hcosmode)
(setq *error* old_err)
(princ)
)

Posted

Add this to your code:

 
(defun DTR (deg) (* deg (/ PI 180)))

Posted

Where do i insert your code into my code ?

Add this to your code:

 
(defun DTR (deg) (* deg (/ PI 180)))

Posted
Where do i insert your code into my code ?

 

[color=slategray](defun C:HN (/[/color] [color=blue]dtr [/color][color=slategray]stp ep d1 d2 d3 d4 d5 ds ang d6 old_err old_hcosmode)[/color]
[color=blue](defun dtr (deg)[/color]
[color=blue](* deg (/ PI 180)))[/color]      
[color=slategray](setq old_err *error*[/color]
[color=slategray]     *error* hc_err)[/color]
[color=slategray](setvar "CMDECHO" 0)[/color]
[color=slategray](setvar "BLIPMODE" 0)[/color]
[color=slategray](setq old_hcosmode(getvar "Osmode"))[/color]
..............

 

since you're only using it once might as well change all this

(+ ang (dtr 90))

to

(+ ang 1.5708 )

to prevent the overhead on defining a sub-function to run for a single value of 90

Posted

Thank you very much !

[color=slategray](defun c:hn (/[/color] [color=blue]dtr [/color][color=slategray]stp ep d1 d2 d3 d4 d5 ds ang d6 old_err old_hcosmode)[/color]
[color=blue](defun dtr (deg)[/color]
[color=blue](* deg (/ pi 180)))[/color]      
[color=slategray](setq old_err *error*[/color]
[color=slategray]     *error* hc_err)[/color]
[color=slategray](setvar "cmdecho" 0)[/color]
[color=slategray](setvar "blipmode" 0)[/color]
[color=slategray](setq old_hcosmode(getvar "osmode"))[/color]
..............

 

since you're only using it once might as well change all this

(+ ang (dtr 90))

to

(+ ang 1.5708 )

to prevent the overhead on defining a sub-function to run for a single value of 90

Posted

Hi vnanhvu, it is a "basicly" problem. Just copy Ahankhah code anywhere in your lisp to load, or change directly with formula like pBe, or use acet-dtor instead of dtr (if you have Express Tool)

Posted
since you're only using it once might as well change all this

(+ ang (dtr 90))

to

(+ ang 1.5708 )

 

to prevent the overhead on defining a sub-function to run for a single value of 90

I'd advise going a bit longer than that though:
(+ ang 1.570796326794896)

That was calculated using:

(rtos (/ PI 2) 2 16)

Though even that's not as accurate as going with calculating half of PI, or using a more accurate display like in windows's Calculator: 1.5707963267948966192313216916398

 

If you use the reduced value(s) you'll get lines which are not quite perpendicular, only close to. And even lines which won't properly intersect.

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