TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: DEVITG on February 21, 2004, 04:40:07 PM

Title: decimal to architec and other UNIT system
Post by: DEVITG on February 21, 2004, 04:40:07 PM
Hi all .

Has I born in a metric country, I allways use decimal as UNIT system.

But seldom I need to let the user to choose the unit system he/she want to use.

How it can be done by LISP :oops:
Title: decimal to architec and other UNIT system
Post by: daron on February 21, 2004, 05:56:03 PM
Not sure of the question, but have you tried (setvar 'luprec 4)?
Title: not luprec
Post by: DEVITG on February 21, 2004, 06:10:59 PM
Hi daron , luprec hold the decimal after the decimal point
What I'm looking for is to be able to change the way units can be input.

The drawing could be >

Architectural  [ 12' 10 1/4"]
Decimal [123.4589]
engeenirring [12' -0.0005"]
Fractional [0 1/8"]
Scientific [ 10 e 2]

It can be set by the UNITS command

How it can be set from a lisp.
Title: decimal to architec and other UNIT system
Post by: daron on February 21, 2004, 06:36:22 PM
try (setvar 'lunits 4). I'm only throwing out what comes to mind as I am not currently on a machine with autocad. I realized after I posted that what I wrote wouldn't be the answer, ah well.
Title: decimal to architec and other UNIT system
Post by: Keith™ on February 21, 2004, 06:46:58 PM
lunits is the answer ....
Title: that is
Post by: DEVITG on February 21, 2004, 07:04:09 PM
Hi Daron and Keith that is what I was lookin for.

Thanks again.
 :lol:  :)  :D  :wink:  :!:  :!:
Title: decimal to architec and other UNIT system
Post by: rude dog on February 21, 2004, 07:30:25 PM
Code: [Select]

(defun c:sdim ()
(initget 7)
(setq ds (getint "\nEnter <1> for Scientfic <2> for Decimal <3> Engineering <4> Architectural"))
(command "dimunit" ds "")
)
(princ)

I know someone else out there can improve on this.....
Title: ok and now hoe I do .....
Post by: DEVITG on February 21, 2004, 07:34:16 PM
:oops:

As I told you before , I allways use decimal .
If LUNITS is set to 4 how I must input the values
I only can input 12'10
But I can not input 12'10"3/4
How I shal key in the value??? :?:  :oops:  :oops:  :cry:
Title: dimunits + lunits
Post by: DEVITG on February 21, 2004, 07:38:19 PM
Hi Rude Dog
 Nice routine , but I change the LUNITS just to input values , maybe I need to change the  DIMUNITS too so the user will be able to DIM in architectural.
Thanks for it
Title: decimal to architec and other UNIT system
Post by: Anonymous on February 21, 2004, 07:55:14 PM
I think this will do it...

Code: [Select]

(defun C:UU ()
(initget 7)
(setq UA (getint "\nEnter <1> for Scientfic <2> for Decimal <3> Engineering <4> Architectural"))
(setvar UA)
)
(princ)

Title: decimal to architec and other UNIT system
Post by: rude dog on February 21, 2004, 07:58:49 PM
If it is wrong  it was me RDOG the unknown guest....
Hey DEVITG...this place is the best for any code questions me being a newbie myself I am astounded daily by some of these peoples creativity and knowledge....Enjoy your stay
Title: decimal to architec and other UNIT system
Post by: Keith™ on February 21, 2004, 08:35:48 PM
Your distance is 12'-10 3/4" which is equal to 154.75 in decimal or 154 3/4"

To enter a value when LUNITS is set to 4 (architectural) do it this way:

FEET'-INCHES FRACTIONS"
or
INCHES FRACTIONS"

Note the location of the single and double tic marks for the feet and inches designation.

I hope you understand now....
Title: no fractions allowed
Post by: DEVITG on February 21, 2004, 08:57:14 PM
Hi keith .
I'm missing something
I can type 12' -10"
but I can not put the fractions
Quote
Specify radius of circle or [Diameter] <0'-10">: 0'-10"3/4

Requires numeric radius, point on circumference, or "D".
Title: decimal to architec and other UNIT system
Post by: Keith™ on February 21, 2004, 09:16:54 PM
You have to put the inch mark AFTER the fraction and a space between the fraction and full inches as I showed in the above example...

12'-10 3/4"
Title: no way tu put fraction
Post by: DEVITG on February 22, 2004, 09:33:50 AM
Keith , please apologize me for so insistent.

Set lunits to 4 , when I put the 0'12-10 it is OK , but when I type an space after the 10 to put the fraction it do an enter and send me a error messg.

Quote
Specify radius of circle or [Diameter] <1'-0">: 0'-103/4"

Requires numeric radius, point on circumference, or "D".

Specify radius of circle or [Diameter] <1'-0">: 0'-10"3/4

Requires numeric radius, point on circumference, or "D".

Specify radius of circle or [Diameter] <1'-0">: 0'-10



Only the last one is ok but I can not put the fractios , what I'm doing wrong???? :oops:  :oops:  :cry:  :cry:
Title: decimal to architec and other UNIT system
Post by: rude dog on February 22, 2004, 10:14:41 AM
Command: l LINE Specify first point: 0,0,0

Specify next point or [Undo]: 12'10-3/4

Command: l LINE Specify first point:
Specify next point or [Undo]: 10

Command: LINE
Specify first point:
Specify next point or [Undo]: 10-3/8

Command: l LINE Specify first point:
Specify next point or [Undo]: 1'0-7/8
Title: decimal to architec and other UNIT system
Post by: Keith™ on February 22, 2004, 11:24:52 AM
If you are using the input in a program using the GETSTRING function you must use it in the following manner....

Code: [Select]

(getstring T "put prompt here")


Then you can enter it with a space,  or you alternatively can enter it as RD has shown above OR you can neter it as a sort of hybridlike so...

12'10.75"
12'-10.75"
Title: decimal to architec and other UNIT system
Post by: ELOQUINTET on February 23, 2004, 08:14:05 AM
kind of related to this i would like a way to quickly toggle between architectural and fractional units. i am in fabricational so we use fractional but when i'm doing layout work from architectural i use architectural. what would a button to do this look like?
Title: decimal to architec and other UNIT system
Post by: daron on February 23, 2004, 08:31:57 AM
I think RD's example is the answer. You separate the inches from fractions by a hypen "-". You don't need the inch mark at all. It is implied.
Title: decimal to architec and other UNIT system
Post by: ELOQUINTET on February 23, 2004, 10:09:23 AM
"fabricational" is that a word? i figured it out guys nevermind
Title: togle button for lunit
Post by: DEVITG on February 23, 2004, 01:05:46 PM
Please put it in a  button  macro .

Code: [Select]


(if (= (getvar "lunits" ) 4 ) (setvar "lunits" 5 ) (Setvar "lunits" 4))



If you only use fract and archi .

"fabricational"  is a word to name the drafter make thing to be fabricated.
 :wink:  :lol:
Title: decimal to architec and other UNIT system
Post by: ELOQUINTET on February 23, 2004, 09:51:07 PM
i was getting ahead of myself. if you look i used fractional shortly after fabrication making it fabricational. dyslexia  :roll:
Title: decimal to architec and other UNIT system
Post by: Serge J. Gianolla on February 24, 2004, 12:23:28 AM
Devitg,
If you are as familiar with imperial units as I am [which is pretty much close to nothing], you might have stumbled on a puzzling thing. When you draw a line say 12'10-3/4

Command: LINE Specify first point:
Specify next point or [Undo]: 12'10-3/4
then list the line you will notice a different format of the length is given

          Length =12'-10 3/4" ,  Angle in XY Plane =    308
                  Delta X =7'-11 15/16", Delta Y = -10'-1 7/16", Delta Z =

This happens when your UNITMODE is set on 0, when set on 1
 Length =12'10-3/4" ,  Angle in XY Plane =    308
                  Delta X =7'11-15/16", Delta Y = -10'1-7/16", Delta Z =
that might help when debugging.