Freerefill Posted May 18, 2009 Share Posted May 18, 2009 Alright guys and gals, I've been working on a separate project with great success and whilst this was my original goal, I realized the challenges and, when my initial attempt failed and my second goal became my primary, it fell by the wayside until I remembered, hey, I should ask the smart folks on cadtutor.net! Now I don't need this for any reason other than my own curiosity and amusement. I can see potential for it in a lot of areas, but the work to construct such a thing might not ultimately be worth the effort. Hence, why it has been pushed aside for more pressing interests. I say all of this only because I am as curious as a kitten, and it's gotten the better of me. ^.^ In a nutshell.. Suppose you had this setup: (defun command_emulator(input / ) [i]do something [/i]) Is there anything, any way, shape or form where you could have that "do something" take the INPUT and interpret it as a command? Say you wanted to pass the string "M" to the function, and have the function start the Move command and carry the user through to completion, and then end the function. Now, you couldn't just do: (command input) because "M" is not a recognized command. Furthermore, in order to have such a thing occur like that, you'd need either pauses or (ssget)'s and (getpoint)'s, and that's just for the Move command, so you'd need a separate set up for every command. So that's the gist of what I'm curious of. Is it possible for there to be a stand-alone function which can take any text input and use it exactly as you would have typed it at the command line? I've given it a some thought, and I don't believe it's possible, unless you had a separate condition for each and every possible command, which, of course, would be a massive undertaking and bordering on foolishness. Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 19, 2009 Author Share Posted May 19, 2009 >.> <.> (defun command_emulator(input / comOn) (setq comOn T) (command input (while comOn (if (= input (getvar "cmdnames")) (command pause) (setq comOn nil)))) ) Not perfect.. it only allows me single-selection when I try to move or copy.. but if that's not a damn fine start, I don't know what is. Quote Link to comment Share on other sites More sharing options...
VovKa Posted May 19, 2009 Share Posted May 19, 2009 (defun command_emulator (input /) (command input) (while (= (logand (getvar "CMDACTIVE")) 1) (command "\\")) ) Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 19, 2009 Author Share Posted May 19, 2009 (defun command_emulator (input /) (command input) (while (= (logand (getvar "CMDACTIVE")) 1) (command "\\")) ) Nice, a lot slicker than mine. Still can't get multiple selection to work, though Only allows single clicks. Must have something to do with the structure of the Move function... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 19, 2009 Share Posted May 19, 2009 Its to do with the selection method - a single pause does not allow for a windowed selection set object retrieval. Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 19, 2009 Author Share Posted May 19, 2009 I see.. I wonder if the same trick could be pulled.. Anyone know of a way to determine if selection call is active, much the same way one would determine if a command is active? I snooped around but found nothing. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 19, 2009 Share Posted May 19, 2009 I see.. I wonder if the same trick could be pulled.. Anyone know of a way to determine if selection call is active, much the same way one would determine if a command is active? I snooped around but found nothing. Is it really worth the effort? The only way I would see to approach it is to breakdown the various commands into which commands require selection sets, and which require other types of input - and make a cond statement for those with selection set input. But in reality one would just amend the LISP as necessary to incorporate these command calls, not use a separate sub-function for the same task. I know this is just a task for curiousity - but is there really any practical value in this task? Just my $0.02, Lee Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 19, 2009 Author Share Posted May 19, 2009 Is it really worth the effort?The only way I would see to approach it is to breakdown the various commands into which commands require selection sets, and which require other types of input - and make a cond statement for those with selection set input. But in reality one would just amend the LISP as necessary to incorporate these command calls, not use a separate sub-function for the same task. I know this is just a task for curiousity - but is there really any practical value in this task? Just my $0.02, Lee The foundation of curiosity is naught but the lack of existence and the belief that anything is possible. Practicality has no place in pure curiosity. As I said, I am purely curious. But, if you must know, a while back I had an idea: a way to track all movement and commands that were inputted into AutoCAD and, using that data, construct automated tasks. Normally, user input is via keyboard and clicking, and specifying that you are entering data. What if you took away the "In/Out" interface and simply had AutoCAD respond to your demands, with no completion of task without immediately accepting new ones? A dynamic user interface, not one based on static and "start here, stop there" commands. I believe this would open up a lot of options, and allow users the ability to extract even more functionality out of AutoCAD. AutoCAD is an engine, a powerful one with many options and tools at the disposal of the user. It can be modified and tweaked with great precision. What if we put that engine into a car and gave the user a steering wheel? If you still think it's silly, then I'd refer you to the infamous tilemode thread. I'm sure we didn't need 23 methods of the same operation, but we did it anyway. Why? Because we're human. Think about it. Quote Link to comment Share on other sites More sharing options...
wizman Posted May 19, 2009 Share Posted May 19, 2009 i'm not sure if i get your idea right but maybe: (defun command_emulator (cmdstring / app doc) (vl-load-com) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat cmdstring " ")) (princ) ) test: (command_emulator "copy") (command_emulator "rotate") (command_emulator "c") (command_emulator "r") Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 19, 2009 Author Share Posted May 19, 2009 i'm not sure if i get your idea right but maybe: (defun command_emulator (cmdstring / app doc) (vl-load-com) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat cmdstring " ")) (princ) ) test: (command_emulator "copy") (command_emulator "rotate") (command_emulator "c") (command_emulator "r") I tried using your code but to no avail, and here's why: (defun command_emulator (cmdstring / app doc) (vl-load-com) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat cmdstring " ")) (princ) (princ "print this") ) When you run that for anything, you'll see the "print this" appear instantly, as opposed to when the command has completed and the function ends. Try adding a (princ "print this") before the closing paren to the other two examples, you'll see what I'm talking about. It won't appear until you've finished whatever it is you're doing, like, say, if you've passed "move" to the function, it won't appear until you've finished the Move command. Quote Link to comment Share on other sites More sharing options...
wizman Posted May 19, 2009 Share Posted May 19, 2009 thanks for testing, i'll post again if ever if i find something. Quote Link to comment Share on other sites More sharing options...
Freerefill Posted May 19, 2009 Author Share Posted May 19, 2009 And thank you very much for your efforts, Wizman ^.^ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.