Author Topic: code tweak  (Read 3216 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
code tweak
« on: February 19, 2004, 12:30:51 PM »
i have this code which works great but i would like to make improve it so the user can input their units in any format. e.g. instead of .125 they could enter 1/8. i usually type it in decimal form but not everyone does and it will use the previous distance if you don't use decimal format.


Code: [Select]
(defun c:DOF (/ a b b1 p1 d pckbox)
(setq d 20 p1 nil pee (/ pi 2)e 3 pckbox (getvar "pickbox")line "                               ")
(if(= #parof nil)(setq #parof(/(getvar "viewsize")10)))
(princ "\nCurrent offset <")(princ #parof)
(setq answer(getstring ">: "))
(if (/= (atof answer) 0.0)(setq #parof(atof answer)))

(princ line)
(setvar "pickbox" pckbox)
(setq ent(entsel "\nPick the line: "))
(setvar "pickbox" 2)
(setq point(cadr ent))
(princ line)
        (setq side(getpoint "\nPick an offset side: "))
(setq dist(distance side point))(setq ang(angle side point))
(if(or(or(< ang 0.78)(> ang 5.5))(and(> ang 2.35)(< ang 3.92)))
(setq ang(- 0 ang))(setq ang(- pi ang))
);end if
(setq other(polar point ang dist))
(command "offset" #parof ent side ent other "")
        (entdel(car ent))

(setvar "pickbox" pckbox)
(prin1)
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
code tweak
« Reply #1 on: February 19, 2004, 01:34:49 PM »
dan
that is more than a code tweak.
I think you would have to write a number input interpreter
to accomplish that. :shock:


CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
code tweak
« Reply #2 on: February 19, 2004, 01:41:12 PM »
really huh didn't know it was complicated. goes to show how much i know. it's not a big deal i was just trying to make it more user friendly. don't worry about it then guys

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
code tweak
« Reply #3 on: February 19, 2004, 01:42:12 PM »
Lookup distof in the dev help.chm
Code: [Select]

Command: (distof "1/8" 4)
0.125
TheSwamp.org  (serving the CAD community since 2003)

Columbia

  • Guest
code tweak
« Reply #4 on: February 19, 2004, 02:47:20 PM »
Dan,

Check out this post that was in the "Show Your Stuff" topic.

http://theswamp.org/phpBB2/viewtopic.php?t=364

It might lead you down the road to glory.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
code tweak
« Reply #5 on: February 19, 2004, 05:02:06 PM »
How soon we forget. :)

Columbia that is just what Dan was looking for.

CAB
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.