Sweety Posted August 20, 2010 Author Posted August 20, 2010 A couple of things to be answered Please. - I tried to go back after implementing any of the created routines, and I did pass that normally.So could you please tell why did you add the UNDO command ? - According to my information, the IF function would test if the list (pt1 pt2 num) are having value to keep on running normally, and function NOT would test for the list equal to nil, and you added nil with member . I can not understand it that way at all. Would you please explain the following part for me .? (if (not(member 'nil (list pt1 pt2 num))) Many thanks. Sweety. Quote
JohnM Posted August 20, 2010 Posted August 20, 2010 (if (not(member 'nil (list pt1 pt2 num))) Lets look at it inside out (list pt1 pt2 num), makes a list of the variables (member 'nil (list pt1 pt2 num)) look to see if any variable = nil This is from the AutoCAD developers help file: Searches a list for an occurrence of an expression and returns the remainder of the list, starting with the first occurrence of the expression (member expr lst) Arguments expr The expression to be searched for. lst The list in which to search for expr. Return Values A list; otherwise nil, if there is no occurrence of expr in lst. Examples Command: (member 'c '(a b c d e)) (C D E) Command: (member 'q '(a b c d e)) nil Not will turn a nil repose into a T or true response. As you can see above, if the member function finds the expression the be searched for, it will return a list starting with the first occurrence of the expression and the IF function will see this as a T or true response, so we have to use NOT to turn a False into a true The if function: IF True do this Else do this. The If function always looks for a non nil response and if our member function found a nil in the list it would return a list and the if function would see this as a True and continue to process the code. The following returns a yes (if (=(+ 1 1)2) :_ 1+1 does = 2 so this is true (alert “yes”) :_do this (alert “no”);_if false do this );_if The following returns a no (if (=(+ 1 1)1000) :_ 1+1 does not = 1000 so this is false or nil (alert “yes”) :_do this (alert “no”);_if false do this );_if This is where the prong function comes in.. The prong function takes a group of expressions and processes them and the if function treats it like 1 expression (if (=(+ 1 1)2) :_ 1+1 does = 2 so this is true (progn (alert “yes”) :_do this (alert “I said yes”) :_and this (alert “yes yes yes”) :_and this );_progn (progn (alert “no”) :_do this (alert “no no no”) :_and this (alert “are you deaf”) :_and this );_prong );_end of if i hope this helps Quote
Sweety Posted August 21, 2010 Author Posted August 21, 2010 Thanks Thanks Thanks . I got it Very helpful , I do appreciated a lot. Sweety. Quote
Sweety Posted August 21, 2010 Author Posted August 21, 2010 Heloooooooooo. I did made the rest of the routine. BUT something wrong with the horizontal start point, so could you please check this out for me. (defun c:mystart (/ pt1 pt2 num ang dist step1 myst 1stpt count points pt3 2ndst pt4 pt5) (setq pt1 (getpoint "\n Select First point :") pt2 (getpoint pt1 "\n Select second point :") Xnum (getint "\n Specify number of X segments :") Ynum (getint "\n Specify number of Y segments :") ang (angle pt1 pt2) dist1 (distance pt1 pt2) step1 (/ dist1 Xnum) step2 (/ dist1 Ynum) ) (setq os (getvar 'osmode)) (setvar 'osmode 0) (repeat (- Xnum 1) (setq 1stpt (polar pt1 ang step1));Start point (setq pt3 (polar 1stpt (+ pi(/ pi 2)) dist1));End point (entmakex (list (cons 0 "LINE") (cons 10 1stpt) (cons 11 pt3))) (setq pt1 1stpt) ) (repeat (- Ynum 1) (setq 2ndst (polar pt5 (+ pi(/ pi 2)) step2));Start point (setq pt4 (polar 2ndst (* pi 2) dist1));End point (entmakex (list (cons 0 "LINE") (cons 10 2ndst) (cons 11 pt4))) (setq pt5 (list (- (car pt1) dist1) (cadr pt1))) (setq pt5 2ndst) ) (setvar 'osmode os) (princ) ) Many Many thankssssss. Quote
Sweety Posted August 24, 2010 Author Posted August 24, 2010 Where are you gus ? You are running away from me . I need your help . Quote
JohnM Posted August 24, 2010 Posted August 24, 2010 small changes (defun c:mystart (/ pt1 pt2 num ang dist step1 myst 1stpt count points pt3 2ndst pt4 pt5) (setq pt1 (getpoint "\n Select First point :") pt2 (getpoint pt1 "\n Select second point :") Xnum (getint "\n Specify number of X segments :") Ynum (getint "\n Specify number of Y segments :") ang (angle pt1 pt2) dist1 (distance pt1 pt2) step1 (/ dist1 Xnum) step2 (/ dist1 Ynum) pt1a pt1 ;_added to retain original start point ) (setq os (getvar 'osmode)) (setvar 'osmode 0) (repeat (- Xnum 1) (setq 1stpt (polar pt1a ang step1));Start point use pt1a for x moves (setq pt3 (polar 1stpt (+ pi(/ pi 2)) dist1));End point (entmakex (list (cons 0 "LINE") (cons 10 1stpt) (cons 11 pt3))) (setq pt1a 1stpt) ) (repeat (- Ynum 1) (setq 2ndst (polar pt1 (+ pi(/ pi 2)) step2));Start point use pt1 for y moves (setq pt4 (polar 2ndst (* pi 2) dist1));End point (entmakex (list (cons 0 "LINE") (cons 10 2ndst) (cons 11 pt4))) (setq pt1 2ndst);_incerment point ) (setvar 'osmode os) (princ) ) Quote
Sweety Posted August 24, 2010 Author Posted August 24, 2010 small changes Yes Yes .. Great, and well done. Thanks a milionnnnnnn Regards, 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.