Author Topic: How to convert fraction string to a double?  (Read 2245 times)

0 Members and 1 Guest are viewing this topic.

Viktor

  • Guest
How to convert fraction string to a double?
« on: November 10, 2009, 04:05:54 PM »
Hi, this time I looked everywhere before posting, I even found something seemed like should work:
Autodesk.AutoCAD.Internal.ResourceUtil.StringToDouble(NewValue)
But that does not accept fractional entries either, there must be a built in function in autocad, since it does the conversion in just about every place. Anyone?

Thanks,

Draftek

  • Guest
Re: How to convert fraction string to a double?
« Reply #1 on: November 10, 2009, 04:25:00 PM »
Off the top of my head I'd say split the string with the '/' char and then do the math.

easy peazy

Viktor

  • Guest
Re: How to convert fraction string to a double?
« Reply #2 on: November 10, 2009, 04:27:06 PM »
Yea, I started building my own converter, but was hoping there was a more native approach to this. Autocad seems to do it so good.
« Last Edit: November 10, 2009, 04:30:17 PM by Viktor »

SEANT

  • Bull Frog
  • Posts: 345
Re: How to convert fraction string to a double?
« Reply #3 on: November 10, 2009, 05:29:50 PM »
There is:
Autodesk.AutoCAD.Runtime.Converter.StringToDistance Method (string, DistanceUnitFormat)
Sean Tessier
AutoCAD 2016 Mechanical

Viktor

  • Guest
Re: How to convert fraction string to a double?
« Reply #4 on: November 10, 2009, 07:52:51 PM »
There is:
Autodesk.AutoCAD.Runtime.Converter.StringToDistance Method (string, DistanceUnitFormat)

Thanks SEANT, that is exactly what I was looking for.