vnanhvu Posted June 3, 2011 Posted June 3, 2011 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) ) Quote
Ahankhah Posted June 3, 2011 Posted June 3, 2011 Add this to your code: (defun DTR (deg) (* deg (/ PI 180))) Quote
vnanhvu Posted June 3, 2011 Author Posted June 3, 2011 Where do i insert your code into my code ? Add this to your code: (defun DTR (deg) (* deg (/ PI 180))) Quote
pBe Posted June 3, 2011 Posted June 3, 2011 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 Quote
vnanhvu Posted June 3, 2011 Author Posted June 3, 2011 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 Quote
ketxu Posted June 4, 2011 Posted June 4, 2011 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) Quote
irneb Posted June 6, 2011 Posted June 6, 2011 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. Quote
Recommended Posts
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.