.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with GetString

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
473 Views, 10 Replies

Problem with GetString

I wanted to ask for some stings, in this case for a prefix and a suffix.

I do it with something like the following code
~~~~~~~~~~~~~~~
PromptStringOptions optString = new PromptStringOptions("\nPrefix");

optString.AllowSpaces = true;

PromptResult prString = ed.GetString(optString);

~~~~~~~~~~~~~~~~~~~~

If I write "km " or " km" for the string, it allways returns "km" without
the spaces.

Is it possible to get these spaces, too?

Roland
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: Anonymous

Realy strange, your code works
for me in A2007

~'J'~

public class StringUtils
{
[CommandMethod("CTX")]
public static void SpaceText()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
string s = "1000";
PromptStringOptions optString = new PromptStringOptions("\nPrefix: ");
optString.AllowSpaces = true;
PromptResult prString = ed.GetString(optString);
string p = prString.StringResult;
MessageBox.Show(string.Format("Result: {0}", s + p));
}
}
Message 3 of 11
Anonymous
in reply to: Anonymous

Thank you, Fatty.

I work with 2008, and there I get the wrong result. With your example when i
type " km" the MessageBox shows: "Result: 1000km" and not "Result: 1000 km".
Very strange. Does anyone have the same problem?

Roland

schrieb im Newsbeitrag news:5633520@discussion.autodesk.com...
Realy strange, your code works
for me in A2007

~'J'~

public class StringUtils
{
[CommandMethod("CTX")]
public static void SpaceText()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
string s = "1000";
PromptStringOptions optString = new PromptStringOptions("\nPrefix: ");
optString.AllowSpaces = true;
PromptResult prString = ed.GetString(optString);
string p = prString.StringResult;
MessageBox.Show(string.Format("Result: {0}", s + p));
}
}
Message 4 of 11
Anonymous
in reply to: Anonymous

Hi Fatty,
I tried it now in 2007 and it also doesn't work there.
Does it really work correct for you?

Roland
Message 5 of 11
Anonymous
in reply to: Anonymous

Hi Roland, yes it does work nice
But in fact I use VB.NET, I just converted
my code for you
tested on A2007 only
Here is it

_
Public Shared Sub SpaceText()
Dim doc As Document = acadApp.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim s As String = "1000"
Dim optString As PromptStringOptions = New PromptStringOptions(vbcr & "Prefix: ")
optString.AllowSpaces = True
Dim prString As PromptResult = ed.GetString(optString)
Dim p As String = prString.StringResult
MessageBox.Show(String.Format("Result: {0}", s & p))
End Sub

~'J'~
Message 6 of 11
Anonymous
in reply to: Anonymous

This works also with suffix and prefix
See picture

_
Public Shared Sub SpaceText()
Dim doc As Document = acadApp.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim s As String = "1000"
Dim optString As PromptStringOptions = New PromptStringOptions("\nPrefix")
optString.AllowSpaces = True
Dim prString As PromptResult = ed.GetString(optString)
Dim p As String = prString.StringResult
MessageBox.Show(String.Format("Result: {0}", p & s))
End Sub

~'J'~
Message 7 of 11
Anonymous
in reply to: Anonymous

Thank you, again, Fatty.
So this seems to be a bug in C#.

Roland
Message 8 of 11
Luis Esquivel
in reply to: Anonymous

It is working here using A2007

[code]
[CommandMethod("OTXT")]
public void otxt()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptStringOptions optString = new PromptStringOptions("\nPrefix");
optString.AllowSpaces = true;
PromptResult prString = ed.GetString(optString);
ed.WriteMessage("\nReturn: 1000" + prString.StringResult);
}
[/code]
Message 9 of 11
Anonymous
in reply to: Anonymous

Thank you, Luis.
Your code also didn't work for me with 2007. Therefore I wanted to make a
screenshot of the text-window and saw that the input had no spaces allthough
I typed them in. Then I tried this command with opened text-window and it
worked. So the problem is not the command, it is AutoCAD. I use the dynamic
input, and with this it does not work.
Am I right that no one of you does work with dynamic input and therefore you
had no problems? I think so.

Roland
Message 10 of 11
Anonymous
in reply to: Anonymous

Hi Roland;

Yes I use the dyn-input too, but did not tested with that, last night, I'll
check a little later, and post the result here 🙂

>>Am I right that no one of you does work with dynamic input and therefore
>>you had no problems? I think so.
Message 11 of 11
Anonymous
in reply to: Anonymous

OK;

You are right, it is NOT working. - Another BUG they will say.... 🙂


>>Yes I use the dyn-input too, but did not tested with that, last night,
>>I'll check a little later, and post the result here 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost