I really I got confused - Hope somebody could give me a hand . I have a form with some textbox on it, which should be
filled in with imperial dimension. Like foot and inch. Users right now complain about it is not user friendly ,to put data in form, and honestly they are right. I didn't a good job .
Some people like to put vetting in inch and then by the time textbox lost it focus it should automatically convert data to feet-inch format. Some other user like to put decimal I have to be able to should them in 1/8 inch.
some user like to use space as separator between foot and inch and some other like to use dash.
Bottom line I stocked. Is there any function for this in autocad ?
when I look at my code I just struggled with pure string. I thought maybe there is something in autocad which give developer this option. Like the way we input dimension in command prompt.
Any Advice or tip would be appreciated already.
Janet.
Solved! Go to Solution.
Solved by chiefbraincloud. Go to Solution.
Solved by chiefbraincloud. Go to Solution.
I looked into something like this about 2 years ago because our MicroStation user really don't like the foot/inch input method in AutoCAD. ADN support said there's nothing built in.
MicroStation's input method handles feet, inches, and fractions all from the number pad. 10'-1 1/2" inches is entered as:
10..1 1/2
Makes it real easy with out having to hit the alpha keys on the keyboard.
If AutoCAD has any input method like this I would really love to hear about it also.
Mike ,
Thanks for heads up. I am pretty sure some people wrote something about it. Just it is a matter of sharing experiences.
At least now I know I should not look into object browser. I have to try to write it down from scratch unless somebody wrote it already.
Regards,
Janet.
Autodesk.AutoCAD.Runtime.Converter.DistanceToString(Dist as double, units as DistanceUnitFormat, precision as integer) as string
Thanks Chief,
First I didn't know about this at all. Really appreciated.
But the question is how you cotrol user input on a from data entry , Not at command prompt ?
Regards,
Janet.
That is what it is for. It won't work at a command line prompt unless you always allow Arbitrary input and parse the result autocad gives you.
You need to handle the .Leave event on the TextBox control (or whatever control your users are entering the length information), then pass the (numeric) string from the control to the Converter function and replace the controls text with the text returned by the converter.
Got you. I will try and let you know in a few hours.
Thanks chief.
Hope Mike is reading this as well.
Regards,
Janet.
BTW, It won't do any good for Mike's microstation example (10..1 1/2) because it requires a Double, but it would turn 121.5 into (10'-1 1/2")
Chief , it is working like a charm. Yeaaaaaaaaaaaaaaaaaah!!
I almost wrote 150 lines of code to do that and still buggy.
Really appreciated.
Without you guys here I should've been fired by far.
Regards, and all the best
Janet.
@chiefbraincloud wrote:Autodesk.AutoCAD.Runtime.Converter.DistanceToString(Dist as double, units as DistanceUnitFormat, precision as integer) as string
Can anyone explain how the integers relate to precision? I mean does a 1 mean 1/2" precision, a 2 mean 1/4" precision, etc?
How can I make it the same as the precision specified in the units dialog?
Thanks in Advance
Ok, I think I figured it out. the integer required should be the denominator of the fraction of the precision required. For example, 1/4" precision would require the integer 4 and 1/256" precision would require the integer 256.
If you want to use the drawing units, just use:
Autodesk.AutoCAD.Runtime.Converter.DistanceToString(Dist as double) as string
I had a similar situation once. I found that the best solution was using Regular Expressions. That way you can parse whatever the user puts in your text box. In my case I restricted the units to inches, but they where free to write some like 10'-1 5/16", 5/32", 10" or 8.75".
Recently I used Converter.DistanceToString method and I would like to clarify two points for others.
1) Precision is integer from 0 to 8 (LUPREC equivalent). E.g. 1/4" is 2.
2) This method return value affected by AutoCAD variable DIMZIN. This variable controls suppression of zero. You have to temporary change it to your needs and then revers it back.