ewan_m Posted February 15, 2009 Share Posted February 15, 2009 Hi Everyone, I have recently found what I would call a bug in a lisp routine I've been charged with fixing. In Autocad Map 2006 we have a routine which prepares a drawing to be run through CadPublisher and then does so (it does a number of thing from changing/freezing layers to modifying setfiles on the fly). For some reason a change a senior programmer made to this routine caused the help window to pop up every time a map is processed, while it doesnt stop the process it takes focus and makes working on anything else difficult. I have gone through the process line by line and it did not seem to trigger, does anyone know of commands that might make the help window pop up? (i.e. an insert or explode or something maybe?) Quote Link to comment Share on other sites More sharing options...
PS_Port Posted February 16, 2009 Share Posted February 16, 2009 Upon opening a new or existing drawing (no previous command has been issued), my enter key with initiate the help window. So maybe an extra "" in the Lisp file might be the cause? Maybe not... the extra "" would do the last command in the lisp.. Can you post the code ? Quote Link to comment Share on other sites More sharing options...
ewan_m Posted February 16, 2009 Author Share Posted February 16, 2009 Upon opening a new or existing drawing (no previous command has been issued), my enter key with initiate the help window. So maybe an extra "" in the Lisp file might be the cause? Maybe not... the extra "" would do the last command in the lisp.. Can you post the code ? I think I've sort of found the problem, you'll have to bear with me explaining it though: When you have a process that doesn't return anything you get a nil right? like (command "move" "all" 0,0 1,1) nil the problem is a returned nil seems to repeat the last input? for example if i open vlide then run something that produces a nil it will try to redo vlide Command: 'VLIDE Command: Command: (command "move" "all" 0,0 1,1) nil Command: 'VLIDE Now my understanding is a function should not return or produce anything except what its told or if its told nothing it will return the last function it worked through so it would be like: (defun c:test () (command "move" "all" 0,0 1,1) ) Command: TEST nil Command: when run. I was told that a way to protect against this was to put (princ) at the bottom of a function so it would return a blank line, not a nil or a value. However the function being used is returning all its nils regardless of the (PRINC) at the end and causing a problem like the one you described when "" are inserted. I hope that made sense, and if so, what should I do? Quote Link to comment Share on other sites More sharing options...
badien Posted February 16, 2009 Share Posted February 16, 2009 I've still not understood what you mean in details but this my opinion : (defun c:test () (command "move" "all" "" "0,0" "1,1") ) Cheers!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 16, 2009 Share Posted February 16, 2009 Yes Badien, When using commands that require a selection set input (like "move" for instance), one must include a "" (as if the user pressed enter) after the input, to tell the command that you have finished adding objects to the selection set of objects to be moved. You will find that this extra "" is needed on a lot of other functions also - for example: "chprop" "rotate" "mirror" "copy" and many more. Hope this explains things a little better. Cheers Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 16, 2009 Share Posted February 16, 2009 (defun c:test () (command "move" "all" 0,0 1,1) ) One other thing I have just noticed also is that there are no quotation marks around your coordinate specifications. When using the "command" function, this function requires strings as arguments and will just print these strings to the command line in succession. Therefore, unless the specified arguments are variables containing strings, then all input to this function will need quotation marks. I would also use a (princ) or (prin1) at the end of the LISP to exit cleanly and suppress the last function return as it makes things more professional. Quote Link to comment Share on other sites More sharing options...
badien Posted February 17, 2009 Share Posted February 17, 2009 Lee Mac! Your explains are very clear and helpful. I hope to learn more from you!! Thanks!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 17, 2009 Share Posted February 17, 2009 No worries badien, if you have any questions, just ask Quote Link to comment Share on other sites More sharing options...
badien Posted February 17, 2009 Share Posted February 17, 2009 Lee Mac! You're very kind! I'd like to know your opinions for my problems in Auto Lisp. Could you help me and show me the way? http://www.cadtutor.biz/forum/showthread.php?p=213753#post213753 Thanks!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 17, 2009 Share Posted February 17, 2009 I have had a look - hope you can get it solved soon 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.