Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Not getting Osnap

12 REPLIES 12
Reply
Message 1 of 13
Anonymous
258 Views, 12 Replies

Not getting Osnap

I am writing a routine that is a series of autocad commands wrapped in a defun. I would like to force an osnap at certain points in the commands where you would be pausing for user input, but can't figure out how to do it. Below is the routine. Before anyone comments on the formatting of the program, the book I am using to teach myself (ABC's of AutoLISP) uses this convention and it makes sense to me. I would like to use NEAREST when setqing p1 & p2 and use ENDPOINT when completing A2 (this would snap to the end of the arc of A1). I have another issue with the routine, but if I could get help with these items I would be very appreciative. (defun c:slo (/ osold) (setq osold (getvar "osmode")) (setvar "osmode" 0) (LS) (A1) (A2) (L1) (setvar "osmode" osold) ) (defun LS () (if (not (tblsearch "layer" "slope")) (command "-layer" "n" "SLOPE" "c" "1" "SLOPE" "s" "SLOPE" "") ) ) (defun A1 (/ p1) (setq p1 (getpoint "\nPick start point for first ARC: ")) (command "_.arc" p1 pause pause) ) (defun A2 (/ p2) (setq p2 (getpoint "\nPick start point for second ARC: ")) (command "_.arc" p2 pause pause) ) (defun L1 () (command "_.line" "" pause "") )
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

Before the command set the osnap mode to what you need. (setvar "osmode" 1) ; endpoint (setvar "osmode" 2) ; midpoint (setvar "osmode" 3) ; endpoint,midpoint (setvar "osmode" 4) ;center (setvar "osmode" 5) ; endpoint,center etc..... You should also use (setq osmode (getvar "osmode")) before setting osmode and (setvar "osmode" osmode) at the end of the function so that it is reset to whatever the user was using. "ffejgreb" wrote in message news:40350dfc$1_3@newsprd01... > I am writing a routine that is a series of autocad commands wrapped in a > defun. I would like to force an osnap at certain points in the commands > where you would be pausing for user input, but can't figure out how to do > it. Below is the routine. Before anyone comments on the formatting of the > program, the book I am using to teach myself (ABC's of AutoLISP) uses this > convention and it makes sense to me. I would like to use NEAREST when > setqing p1 & p2 and use ENDPOINT when completing A2 (this would snap to the > end of the arc of A1). I have another issue with the routine, but if I > could get help with these items I would be very appreciative. > > (defun c:slo (/ osold) > (setq osold (getvar "osmode")) > (setvar "osmode" 0) > (LS) > (A1) > (A2) > (L1) > (setvar "osmode" osold) > ) > > (defun LS () > (if (not (tblsearch "layer" "slope")) > (command "-layer" "n" "SLOPE" "c" "1" "SLOPE" "s" "SLOPE" "") > ) > ) > > (defun A1 (/ p1) > (setq p1 (getpoint "\nPick start point for first ARC: ")) > (command "_.arc" p1 pause pause) > ) > > (defun A2 (/ p2) > (setq p2 (getpoint "\nPick start point for second ARC: ")) > (command "_.arc" p2 pause pause) > ) > > (defun L1 () > (command "_.line" "" pause "") > ) > >
Message 3 of 13
Anonymous
in reply to: Anonymous

I tried setting osmode prior to each function, but I don't want them to be running. I would like to emulate the command line way of doing things by issuing the "nea" override and have it go away. I have tried placing the "nea" where the "pause" is, but it didn't work correctly. Can a setvar be nested inside of a command call? If so, how would it be written? Also I believe that I am using a setq osmode. Mine is called osold however.
Message 4 of 13
Anonymous
in reply to: Anonymous

Since you're using the (command ...) function, just insert the OSnaps in the command string, as if you were entering it from the Command: prompt. IF that doesn't work, then something else is amiss. (command "_.line" "_nea" pause ... ...) ___ "ffejgreb" wrote in message news:403527ef_3@newsprd01... > I tried setting osmode prior to each function, but I don't want them to be > running. I would like to emulate the command line way of doing things by > issuing the "nea" override and have it go away.
Message 5 of 13
Anonymous
in reply to: Anonymous

I have been trying that to no avail. I will keep plugging away and see if I can find the amiss. Thank you Paul.
Message 6 of 13
Anonymous
in reply to: Anonymous

The problem with (command ".line" "nea" pause ...) is that the "nea" only works for the first point. The command line override should work with the osmode set. It is no different than setting the osnaps before you start a command at the command line. (defun A1 (/ p1) (setvar "osmode" 512) (setq p1 (getpoint "\nPick start point for first ARC: ")) (setvar "osmode" 0) (command "_.arc" p1 pause pause) ) (defun A2 (/ p2) (setvar "osmode" 1) (setq p2 (getpoint "\nPick start point for second ARC: ")) (setvar "osmode" 0) (command "_.arc" p2 pause pause) ) (defun L1 () (setvar "osmode" 0) (command "_.line" "" pause "") ) Or if you don't like setting osnaps then you could do this: (defun A1 (/ p1) (setq p1 (osnap (getpoint "\nPick start point for first ARC: ") "nea")) (command "_.arc" p1 pause pause) ) (defun A2 (/ p2) (setq p2 (osnap (getpoint "\nPick start point for second ARC: ") "endp")) (command "_.arc" p2 pause pause) ) "Paul Turvill" wrote in message news:40352b6e_1@newsprd01... > Since you're using the (command ...) function, just insert the OSnaps in the > command string, as if you were entering it from the Command: prompt. IF that > doesn't work, then something else is amiss. > > (command "_.line" "_nea" pause ... ...) > ___ > > "ffejgreb" wrote in message > news:403527ef_3@newsprd01... > > I tried setting osmode prior to each function, but I don't want them to be > > running. I would like to emulate the command line way of doing things by > > issuing the "nea" override and have it go away. > >
Message 7 of 13
Anonymous
in reply to: Anonymous

Thanks Jim. I took the same approach you did in the first section. The only problem I seem to have now is that I can't make L1 work correctly. When I do this: (defun L1 () (command "_.line" "_endp" "_perp" "") ) I get this: _.line Specify first point: _endp of _perp Invalid point. ; error: Function cancelled Specify first point: I've placed a pause in front of each osnap, but what happens then is that no osnap is set for the first pick, endp is set for the second, then the line command ends. Any other thoughts?
Message 8 of 13
Anonymous
in reply to: Anonymous

pause *after* osnap ? (command "_.line" "_endp" pause "_perp" pause "") "ffejgreb" wrote in message news:40353433$1_2@newsprd01... > Thanks Jim. I took the same approach you did in the first section. The > only problem I seem to have now is that I can't make L1 work correctly. > When I do this: > > (defun L1 () > (command "_.line" "_endp" "_perp" "") > ) > > I get this: > > _.line Specify first point: _endp of _perp > Invalid point. > ; error: Function cancelled > Specify first point: > > I've placed a pause in front of each osnap, but what happens then is that no > osnap is set for the first pick, endp is set for the second, then the line > command ends. > > Any other thoughts? > >
Message 9 of 13
Anonymous
in reply to: Anonymous

Well that seems to have worked! Thank you so much Mark! I don't know why I didn't think to try that myself. Jeff
Message 10 of 13
Anonymous
in reply to: Anonymous

You're welcome :-) Glad to help "ffejgreb" wrote in message news:403540a9$1_3@newsprd01... > Well that seems to have worked! Thank you so much Mark! I don't know why I > didn't think to try that myself. > > Jeff > >
Message 11 of 13
Anonymous
in reply to: Anonymous

You're leaving out the pauses. ___ "ffejgreb" wrote in message news:40352cdf$1_3@newsprd01... > I have been trying that to no avail. I will keep plugging away and see if I > can find the amiss.
Message 12 of 13
Anonymous
in reply to: Anonymous

Figured that out. Thanks for continuing to look for my errors. Jeff
Message 13 of 13
Anonymous
in reply to: Anonymous

Method 1: Set osmode to 512 before getpoint P1 Set osmode to 1 before getpoint P2 (defun A1 (/ p1) (setvar "osmode" 512) (setq p1 (getpoint "\nPick start point for first ARC: ")) (setvar "osmode" 0) (command "_.arc" p1 pause pause) ) Method 2: Use (osnap pt mode) (defun A1 (/ p1) (setq p1 (getpoint "\nPick start point for first ARC: ")) (setq p1 (osnap p1 "_nea") (command "_.arc" p1 pause pause) ) This method is dangerous because (osnap pt mode) will give NIL if Autocad will not find an object that is nearest to p1. JanC "ffejgreb" schreef in bericht news:40350dfc$1_3@newsprd01... > I am writing a routine that is a series of autocad commands wrapped in a > defun. I would like to force an osnap at certain points in the commands > where you would be pausing for user input, but can't figure out how to do > it. Below is the routine. Before anyone comments on the formatting of the > program, the book I am using to teach myself (ABC's of AutoLISP) uses this > convention and it makes sense to me. I would like to use NEAREST when > setqing p1 & p2 and use ENDPOINT when completing A2 (this would snap to the > end of the arc of A1). I have another issue with the routine, but if I > could get help with these items I would be very appreciative. > > (defun c:slo (/ osold) > (setq osold (getvar "osmode")) > (setvar "osmode" 0) > (LS) > (A1) > (A2) > (L1) > (setvar "osmode" osold) > ) > > (defun LS () > (if (not (tblsearch "layer" "slope")) > (command "-layer" "n" "SLOPE" "c" "1" "SLOPE" "s" "SLOPE" "") > ) > ) > > (defun A1 (/ p1) > (setq p1 (getpoint "\nPick start point for first ARC: ")) > (command "_.arc" p1 pause pause) > ) > > (defun A2 (/ p2) > (setq p2 (getpoint "\nPick start point for second ARC: ")) > (command "_.arc" p2 pause pause) > ) > > (defun L1 () > (command "_.line" "" pause "") > ) > >

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost