Modifying TextEditorSelection.Language Issue

Modifying TextEditorSelection.Language Issue

drewj
Enthusiast Enthusiast
461 Views
3 Replies
Message 1 of 4

Modifying TextEditorSelection.Language Issue

drewj
Enthusiast
Enthusiast

This is a follow up to this question yesterday:

 

https://forums.autodesk.com/t5/net/modifying-characterset-property-of-mtext-object/td-p/7810356

 

Why is it that I can change the string in the MText with

 

MText mtext = (MText)tr.GetObject(id, OpenMode.ForWrite);
TextEditor textEditor = TextEditor.CreateTextEditor(mtext);
textEditor.SelectAll();
TextEditorSelection sel = textEditor.Selection;

 

sel.InsertString("Some New Text");

 

which works OK, however if I change the Language I get eInvalidInput

 

sel.Language = (int)System.Windows.Forms.VisualStyles.TextMetricsCharacterSet.Russian;

 

I am obviously misunderstanding something basic here, can anyone give me a pointer into the correct direction?

 

Thanks,


Drew

0 Likes
462 Views
3 Replies
Replies (3)
Message 2 of 4

ActivistInvestor
Mentor
Mentor

See the documentation for InsertString()

 

When you use this method, it invalidates the current selection. 

 

 


@Anonymous wrote:

This is a follow up to this question yesterday:

 

https://forums.autodesk.com/t5/net/modifying-characterset-property-of-mtext-object/td-p/7810356

 

Why is it that I can change the string in the MText with

 

MText mtext = (MText)tr.GetObject(id, OpenMode.ForWrite);
TextEditor textEditor = TextEditor.CreateTextEditor(mtext);
textEditor.SelectAll();
TextEditorSelection sel = textEditor.Selection;

 

sel.InsertString("Some New Text");

 

which works OK, however if I change the Language I get eInvalidInput

 

sel.Language = (int)System.Windows.Forms.VisualStyles.TextMetricsCharacterSet.Russian;

 

I am obviously misunderstanding something basic here, can anyone give me a pointer into the correct direction?

 

Thanks,


Drew


 

0 Likes
Message 3 of 4

drewj
Enthusiast
Enthusiast

I have been doing one or the other, so in the case of changing the Language I am not using the InsertString, so that shouldn't be a problem right?

0 Likes
Message 4 of 4

ActivistInvestor
Mentor
Mentor

See the docs >here<

 

According to that, eInvalidInput could be raised if the language isn't supported.

 

You can use the CanSupportLanguage() method to check if the selection supports a given language.

 


@Anonymous wrote:

I have been doing one or the other, so in the case of changing the Language I am not using the InsertString, so that shouldn't be a problem right?


 

0 Likes