Hsanon Posted June 25, 2020 Posted June 25, 2020 Hi, Im facing a very strange issue in a part of my (very basic) code..... (setq Vshelves (strcase (getstring "\nDo You want to have Vertical partitions?? [Yes/No] <Y> :"))) (if (or (= Vshelves "Y") (= Vshelves "")) (while ;(setvar "osmode" 183) ; (setq vspt (getpoint "\nPick Vertical Partition Start Point: ")) (setq vdist (getdist vspt "\nPick extent of the vertical partition ?? :")) ;(setvar "osmode" 0) (command "insert" "2dply" vspt plythk vdist "" ) );end while );end if as soon as i keep the Osnap on, the program crashes .... and it works fine without the osnap in the code.... (but the exection is a pain) i would need to have the osnaps on in the program !!!! can someone tell me where i an going wrong ???? Thanks Quote
dlanorh Posted June 25, 2020 Posted June 25, 2020 27 minutes ago, Hsanon said: Hi, Im facing a very strange issue in a part of my (very basic) code..... (setq Vshelves (strcase (getstring "\nDo You want to have Vertical partitions?? [Yes/No] <Y> :"))) (if (or (= Vshelves "Y") (= Vshelves "")) (while ;(setvar "osmode" 183) ; (setq vspt (getpoint "\nPick Vertical Partition Start Point: ")) (setq vdist (getdist vspt "\nPick extent of the vertical partition ?? :")) ;(setvar "osmode" 0) (command "insert" "2dply" vspt plythk vdist "" ) );end while );end if as soon as i keep the Osnap on, the program crashes .... and it works fine without the osnap in the code.... (but the exection is a pain) i would need to have the osnaps on in the program !!!! can someone tell me where i an going wrong ???? Thanks The answer is what is controlling the while loop. As it is, selecting a point is the controlling factor. If you uncomment (setvar "osmode" 183) this then controls the while loop. Try this, not tested (setq Vshelves (strcase (getstring "\nDo You want to have Vertical partitions?? [Yes/No] <Y> :"))) (setvar "osmode" 183) (if (or (= Vshelves "Y") (= Vshelves "")) (while (setq vspt (getpoint "\nPick Vertical Partition Start Point: ")) (setq vdist (getdist vspt "\nPick extent of the vertical partition ?? :")) (setvar "osmode" 0) (command "insert" "2dply" vspt plythk vdist "" ) (setvar "osmode" 183) );end while );end if Quote
pkenewell Posted June 25, 2020 Posted June 25, 2020 Another way would be to override the osnaps within the command - no need to change OSMODE. i.e. (command "insert" "2dpoly" "non" vspt plythk vdist ""). NON tells the command to ignore osnaps for the next point specified. Quote
BIGAL Posted June 26, 2020 Posted June 26, 2020 Add (setq oldnsap (getvar 'osmode)) so save current osmode, then add at end (setvar 'osmode oldsnap) Quote
Hsanon Posted June 26, 2020 Author Posted June 26, 2020 Hey. Thanks..... Really appreciate it.... Lemmie check it out. Quote
Hsanon Posted June 26, 2020 Author Posted June 26, 2020 Thanks so much ..... That issue has been resolved !!! You guys are the best !!!! Quote
Hsanon Posted June 26, 2020 Author Posted June 26, 2020 20 hours ago, pkenewell said: Another way would be to override the osnaps within the command - no need to change OSMODE. i.e. (command "insert" "2dpoly" "non" vspt plythk vdist ""). NON tells the command to ignore osnaps for the next point specified. This works for the insert command, but not for copy or move as i see it. But its a brilliant option for the insert command !!! thanks Quote
pkenewell Posted June 26, 2020 Posted June 26, 2020 (edited) 6 hours ago, Hsanon said: This works for the insert command, but not for copy or move as i see it. But its a brilliant option for the insert command !!! thanks @Hsanon The "non" (or "none") modifier should work for ANY Autocad command that requests a point. I use this all the time, both in autoLISP and at the command line. The modifier has to be requested before EACH point specified. Examples: (command "._line" "_non" p1 "_non" p2 "") ;;note: the underscore ("_") prefix in the command options - although not necessary - allow for international usage; they translate to the local language. (command "._arc" "_non" p1 "_non" p2 "_non" p3) Edited June 26, 2020 by pkenewell Quote
Hsanon Posted June 27, 2020 Author Posted June 27, 2020 8 hours ago, pkenewell said: @Hsanon The "non" (or "none") modifier should work for ANY Autocad command that requests a point. I use this all the time, both in autoLISP and at the command line. The modifier has to be requested before EACH point specified. Examples: (command "._line" "_non" p1 "_non" p2 "") ;;note: the underscore ("_") prefix in the command options - although not necessary - allow for international usage; they translate to the local language. (command "._arc" "_non" p1 "_non" p2 "_non" p3) The copy command and move command didn't seem to work.... with "non" Maybe I should try again.... thanks Quote
pkenewell Posted June 29, 2020 Posted June 29, 2020 (edited) On 6/27/2020 at 1:17 AM, Hsanon said: The copy command and move command didn't seem to work.... with "non" Maybe I should try again.... thanks Works for me. Try this in a drawing with a few items to copy. I suspect you need to get your COPY command sequence correct. (defun C:foo () (princ "\n Selected Objects: ") (if (setq ss (ssget)) (command "._copy" ss "" "_non" "0,0,0" "_non" "1,1,0") ) (princ) ) Edited June 29, 2020 by pkenewell Quote
Hsanon Posted June 29, 2020 Author Posted June 29, 2020 Hey thanks... Lemmie try it in my existing code. Really appreciate your help. 1 Quote
pkenewell Posted June 29, 2020 Posted June 29, 2020 Just now, Hsanon said: Hey thanks... Lemmie try it in my existing code. Really appreciate your help. No problem! Let me know how it works out for you. If you're still having some issues - post your code. 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.