Converting from Architectural Units to Decimal Units eInvalidInput error

Converting from Architectural Units to Decimal Units eInvalidInput error

Anonymous
Not applicable
1,441 Views
4 Replies
Message 1 of 5

Converting from Architectural Units to Decimal Units eInvalidInput error

Anonymous
Not applicable

I've been using the Runtime.Converter to convert units to display correctly in text boxes after a user selects a different unit via a combobox on the form.  When I have 1/2" in the textbox and try to convert it to decimal units (or any other unit for that matter) I get an eInvalidInput error.  This is only happening when I change from Architectural to something else.  All other conversions are working just fine.  I'm using  AutoCAD 2019 and the code is in C#

 

Any help would be greatly appreciated.

0 Likes
Accepted solutions (2)
1,442 Views
4 Replies
Replies (4)
Message 2 of 5

Alexander.Rivilis
Mentor
Mentor

@Anonymous wrote:

 

Any help would be greatly appreciated.


Please provide code you are using for converting.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 3 of 5

_gile
Consultant
Consultant
Accepted solution

Hi,

 

You should show a code "not working" snippet.

This works for me (returns 0.5):

 

Converter.StringToDistance("1/2\"", DistanceUnitFormat.Architectural)


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 5

Alexander.Rivilis
Mentor
Mentor
Accepted solution

@Anonymous 

You can get this exception if system variable  LUNITS different from 4 and you use short form of

Converter.StringToDistance("1/2\"") method instead of
Converter.StringToDistance("1/2\"", DistanceUnitFormat.Architectural) method

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 5 of 5

Anonymous
Not applicable

Sorry I was unable to post a code snippet - I believe I was simply using the 2nd parameter incorrectly.

0 Likes