Agent 31 Posted June 30, 2010 Posted June 30, 2010 Hey everyone, I am brand new to creating threads, though I have been a fan of the forum for a while now and I have received a lot of help. So here goes, my very first question! Drumroll please?! I am kind of new to AutoLISP, I have been diving deeply into it for almost 8 hours a day straight for the last 2 weeks. I decided that I did not have anything better to try so I want to create a security macro for my AutoCAD. I can get it started and all that good stuff so I am not concerned for help with that. I just need to know the code and what I am doing wrong. I want it to ask the user for a point. If that point matches a certain coordinate (0,0), then nothing happens. If it DOES NOT match the point, AutoCAD dies, . I will worry about setting up the point I want and stuff, I just need to know whats going on with my code?! The more experienced users can probably figure out what is happening a lot faster. Right now, it just dies regardless of the coordinate I enter, *sigh* (defun C:security() (setq pass (getpoint "\nGet to the point already!")) (if (= pass '(0,0))(alert "Welcome Agent 31!")(command "quit" "y") ) ) Quote
MSasu Posted June 30, 2010 Posted June 30, 2010 You should use EQUAL to compare lists: (equal pass '(0.0 0.0 0.0)) But I'm not sure what you will achive with that... Are you aware that a simple will skip your security check?!? Regards Quote
Tharwat Posted June 30, 2010 Posted June 30, 2010 Welcome to the forum everthing goes well but the princ of greating it won't be seen due to the quit command Regards Tharwat Quote
MSasu Posted June 30, 2010 Posted June 30, 2010 the princ of greating it won't be seen due to the quit command I'm affraid this is not true - the idea is that the user will receive a welcome message if pass the test or the AutoCAD will close if doesn't. Even for the case when both statements were issued, the AutoCAD will not quit until the ALERT box isn't closed. Regards, Quote
Tharwat Posted June 30, 2010 Posted June 30, 2010 I'm affraid this is not true - the idea is that the user will receive a welcome message if pass the test or the AutoCAD will close if doesn't.Even for the case when both statements were issued, the AutoCAD will not quit until the ALERT box isn't closed. Regards, I am sorry, for the first time I do not agree with you.... try to invoke the Lisp and you will find out that there won't be any alert, so only a message to save the changes .... Regards Tharwat Quote
MSasu Posted June 30, 2010 Posted June 30, 2010 try to invoke the Lisp and you will find out that there won't be any alert, so only a message to save the changes That's right - but this is because the OP's code is wrong; that test will never pass - please take a look to post #2. Regards, Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 I am sorry, for the first time I do not agree with you....try to invoke the Lisp and you will find out that there won't be any alert, so only a message to save the changes .... Regards Tharwat You are wrong. The reason the above doesn't work is because his comparison check is wrong. Anything after an alert call will NOT execute until alert has finished. eg. (progn (alert "See") (command "_.quit")) Quote
Agent 31 Posted June 30, 2010 Author Posted June 30, 2010 This really helped me out, thanks. I know there are several flaws with it, but honestly I am just trying to play around with some things. One key thing that this just taught me is what I was doing wrong with the IF function and how to enter coordinates. I thank both of you. And for the record, "Y" wont allow it to ask you to save changes, I honestly do thank you both for helping me on this, and I appreciate such a quick reply time. Regards! (defun C:security() (setq pass (getpoint "\nGet to the point already!")) (if (equal pass '(0.0 0.0 0.0))(alert "Welcome Agent 31!")(command "quit" "y") ) ) Quote
Tharwat Posted June 30, 2010 Posted June 30, 2010 If anyone will copy the lisp file and pasted it in the command line of Autocad and invoke the Program , so will be asked " Get to the point already" if you type 0 so the Autocad program will quit smoothly.. Try it Regards Tharwat Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 If anyone will copy the lisp file and pasted it in the command line of Autocad and invoke the Program , so will be asked " Get to the point already" if you type 0 so the Autocad program will quit smoothly.. Try it Regards Tharwat Only because the original evaluation was completely wrong and no matter what you did, it was never going to do anything but exit. Quote
Tharwat Posted June 30, 2010 Posted June 30, 2010 exactly ....... and that was the core of the issue. My best regards Tharwat Quote
alanjt Posted June 30, 2010 Posted June 30, 2010 exactly ....... and that was the core of the issue. My best regards Tharwat I know, but you are arguing about the mechanics of alert and you are wrong. Quote
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.