.NET

Reply
Member
marskar
Posts: 4
Registered: ‎09-25-2008
Message 1 of 4 (470 Views)

.Net equivalent to Esc key

470 Views, 3 Replies
05-18-2012 06:29 AM

Hi all

 

Rewriting old VBA code in .Net C#. Strugeling with finding a way to send Esc key. Chr(27) worked fine in VBA.

 

This VBA code is updating the block definition but aborts by Esc key before insertion.

 

ThisDrawing.SendCommand ("-insert" + vbLf + "STREAM003=C:/CAD/GDIR/Library/STREAM/STREAM003.DWG" + vbLf + "y" + vbLf + Chr(27))

 

 

Tried the same using ACADCMD but this results in 'Requires numeric distance or two points.' in the commandline.

 

ResultBuffer rb = newResultBuffer();

rb.Add(newTypedValue(5005, "-INSERT"));

rb.Add(newTypedValue(5005, BlockString));

rb.Add(newTypedValue(5005, "y"));

rb.Add(newTypedValue(5005, (char)27));

acedCmd(rb.UnmanagedObject);

 

 

Any ideas?

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 4 (456 Views)

Re: .Net equivalent to Esc key

05-18-2012 08:18 AM in reply to: marskar

Try this one

            ResultBuffer rb = new ResultBuffer();

            rb.Add(new TypedValue((int)LispDataType.Text, "-INSERT"));

            rb.Add(new TypedValue((int)LispDataType.Text, BlockString));

            rb.Add(new TypedValue((int)LispDataType.Text, "y"));

            rb.Add(new TypedValue((int)LispDataType.Text, @"^C"));

            acedCmd(rb.UnmanagedObject);

 

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Member
marskar
Posts: 4
Registered: ‎09-25-2008
Message 3 of 4 (408 Views)

Re: .Net equivalent to Esc key

05-20-2012 10:36 AM in reply to: Hallex

Sorry, didn't work.

 

Typing ^C in AutoCAD commandline during an command doesn't help either, so I think we're barking up the wrong tree.

Member
marskar
Posts: 4
Registered: ‎09-25-2008
Message 4 of 4 (395 Views)

Re: .Net equivalent to Esc key

05-20-2012 11:04 PM in reply to: marskar

Hi again

 

Got it working by using

 

ads_queueexpr("(command \"-insert\" \"" + BlockString + "\" \"y\" ^C)");

 

 

Thanks for pointing me at the right tree afterall. :smileyvery-happy:

 

 

Cheers

Tore

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!