PDA

View Full Version : UnKnown Command Reactor



kerbocad
2009-01-15, 07:47 PM
I'm trying to figure out how to fire an event to an "Unknown Command". I can't get any of the basic VBA reators to work (Begincommand, EndCommand, etc)

any ideas?

thanks,

Robert

Ed Jobe
2009-01-15, 09:18 PM
You need to explain further what you want. If you issue a command that acad does not recognise, how can it be tracked? Autocad will just ignore it and move on. It sounds more like your code is creating an error, sending text to the command line that acad does not recognise as a valid command. If that is so, insert a breakpoint and step through your code in debug mode until the error occurs.

kerbocad
2009-01-15, 09:34 PM
If I type in ...

"Command: hello"

After AutoCAD gives the...

"Unknown command "HELLO". Press F1 for help."

At that point I want a reactor event to fire off and run some code. I know it sounds crazy!!!

The other day I was reading your VBA-Lisp wrapper thread and had a crazy idea. what if we could use a reactor event to feed the command line a statement like this...

ThisDrawing.SendCommand "(defun C:hello ()(command " & Chr(34) & "-vbarun" & Chr(34) & " " & Chr(34) & "c:\programs\myprogram.dvb!Module1.Start" & Chr(34) & "))" & vbCr

I tried the "activate" statement and it hits AutoCAD too early. The command prompt isn't ready yet. I can't find a way to delay it... so started over and thought about reacting to a "unknown command".

Not sure how much I'll actually use this anyway. I'm not fond of "sendcommand" and I'm moving to dot.net anyway. But I couldn't resist the challenge of trying.

Any thoughts would be appreciated!

Ed Jobe
2009-01-15, 10:11 PM
That's because SendCommand is asyncronous...meaning that the commands sent to the command line run after your vba code finishes.

kerbocad
2009-01-17, 05:37 AM
I understand the Sendcommand is Asyncronous... trying to do this thru the "Activate" reactor was my first try and I really didn't know just how out of sync it was going to be until I tried it.

As a second effort I am trying to find a way to react to an "Unknown Command". When ACAD sees and "unknown command" is there a way to trigger a reactor?

jonesb33145
2009-01-18, 04:11 AM
It seems as though you are trying to load you command after someone types in the commandname which is fuzzy logic...so is this what you are trying to do?

Why not load it when autocad starts? That way you won't need to worry about unknown command...

kerbocad
2009-01-19, 03:15 PM
It's not a matter of loading the VBA routine. I am trying to "Defun C: " it completely from VBA. (as a standard this is not considered possible)

I have tried a couple of other things and now I'm playing with the idea of reacting to an unknown command.

kind of what I am envisioning is this...
1) user types in the VBA command name
2) AutoCAD doesn't recognize it hence the uknown command
3) the unknown command reactor fires and checks against a list of VBA commands
4) if it finds it in the list then it loads the appropriate VBA routine and restarts the command.
5) Once it's loaded the defun will hold thru the current session.

the tricky part is item #3

Keep in mind... I have no real need to do this. All of my VBA programs are currently loaded/run thru a Lisp Wrapper. This is nothing more than a neat challenge!

jonesb33145
2009-01-21, 02:48 PM
cool...go for it and let us know if you find your way through this neat challenge...

Ed Jobe
2009-01-21, 04:45 PM
VBA cannot add commands to the command stack. That's why lisp wrappers are needed. But you can execute lisp from vba by using the vl interface. Search this forum for vlax.cls. However, what you really need is a way to find out what they typed. You don't need to register a new command, but execute the one they intended which should already be registered.