Jump to content

Recommended Posts

Posted

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, :twisted:. 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")
 )
)

Posted

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

Posted

Welcome to the forum

 

everthing goes well but the princ of greating it won't be seen due to the

quit command

 

Regards

Tharwat

Posted
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,

Posted
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

Posted
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,

Posted
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"))

Posted

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, :twisted:

 

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")
 )
)

Posted

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.. :D

 

Try it

Regards

 

Tharwat

Posted
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.. :D

 

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.
Posted

exactly ....... and that was the core of the issue.

 

My best regards

 

Tharwat

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...