NH3man! Posted May 17, 2009 Author Share Posted May 17, 2009 Well not really. I should rise .125 per ft. (which is 12 inches) 240= 20ft so it would be 20x.125= 2.5 Sorry we still do not use decimal system over here. LOL Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 17, 2009 Author Share Posted May 17, 2009 Was able to get it to work properly by dividing .125 by 12 (0.010416666666666666666666666666667). I can live with that! Thanks so much Lee this will help a lot. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 Ok, but you could have sorted it also like this: (defun c:hc (/ *error* vlst ovar cBlk tmp1 tmp2 tmp3 tmp4 blkpt) ; Error Handler (defun *error* (msg) (if ovar (mapcar 'setvar vlst ovar)) ; Return System Variables (if (not (member msg '("Function cancelled" "quit / exit abort"))) (princ (strcat "\n<< Error: " msg " >>"))) ; Print Error Message (princ)) ; Collect and Set System Variables (setq vlst '("CMDECHO" "OSMODE") ovar (mapcar 'getvar vlst)) (mapcar 'setvar vlst '(0 0)) ; Set Defaults (or hc$slp:def (setq hc$slp:def 1)) (or hc$cop:def (setq hc$cop:def 1)) (or hc$spc:def (setq hc$spc:def 1)) (or hc$dir:def (setq hc$dir:def "X")) ; Get Block to Copy (if (and (setq cBlk (car (entsel "\nSelect Block: "))) (eq "INSERT" (cdr (assoc 0 (entget cBlk))))) (progn ; Get User Input (initget 6) (setq tmp1 (getreal (strcat "\nSpecify Slope <" (rtos hc$slp:def) "> : "))) (or (not tmp1) (setq hc$slp:def tmp1)) (initget 6) (setq tmp2 (getint (strcat "\nSpecify Number of Copies <" (itoa hc$cop:def) "> : "))) (or (not tmp2) (setq hc$cop:def tmp2)) (initget 6) (setq tmp3 (getreal (strcat "\nSpecify Spacing <" (rtos hc$spc:def) "> : "))) (or (not tmp3) (setq hc$spc:def tmp3)) (initget "X Y") (setq tmp4 (getkword (strcat "\nSpecify Direction [X/Y] <" hc$dir:def "> : "))) (or (not tmp4) (setq hc$dir:def tmp4)) ; Get Block Insertion Point Information and Initiate Counter (setq blkpt (cdr (assoc 10 (entget cBlk))) i 1) ; Copy the Block a Number of Times (repeat hc$cop:def (command "_copy" cBlk "" blkpt) (cond ((eq "X" hc$dir:def) (command (list (+ (* i hc$spc:def) (car blkpt)) (cadr blkpt) [b][color=Red](+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt)))))[/color][/b] ((eq "Y" hx$dir:def) (command (car blkpt) (list (+ (* i hc$spc:def) (cadr blkpt)) [b][color=Red](+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt))))))[/color][/b] (command) (setq i (1+ i)))) ; Else No Block was Selected (princ "\n<!> No Block Selected <!>")) ; Return Sys Vars Back (mapcar 'setvar vlst ovar) ; Exit Cleanly (princ)) Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 17, 2009 Author Share Posted May 17, 2009 I tried that one and it seemed to do the same thing. That is ok, I just have to remember to divide .125 by 12 and it works perfectly. I will keep looking at your code and if I can figure out where to make that happen I will try to edit it into and post back. Thanks again Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 I just have to remember to divide .125 by 12 and it works perfectly. The above code does the same as dividing the slope by 12... ^^ see highlighted part btw, you may need to reload these routines when testing - as they have the same syntax hence ACAD may run an old program instead. Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 17, 2009 Author Share Posted May 17, 2009 I don't see the highlighted area. But if I were to guess this would be the area (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt)))))) I even loaded it on my desktop and it does not seem to divide by 12. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 I don't see the highlighted area. But if I were to guess this would be the area (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt)))))) I even loaded it on my desktop and it does not seem to divide by 12. ??? You don't see the highlighted area? Look at the above code, and scroll down a bit - you should see the section I have made red. Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 17, 2009 Author Share Posted May 17, 2009 That is weird. It was not red the first few times I looked at it. Hmmm works even better now. Don't know how the thank you. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 I edited it when I posted #25 so you could see the part. Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 17, 2009 Author Share Posted May 17, 2009 I ran into a small problem. I can't get it to slope in the -x and -y direction. Or if it could use a -.125 so that it slopes in the opposite direction. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 Have you tried to correct it? If you post what you have, I shall correct it and comment it Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 18, 2009 Author Share Posted May 18, 2009 I think I see what I can do to make it go -x and -y. But do I need two new separate commands for this. Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 18, 2009 Author Share Posted May 18, 2009 (setq tmp5 (getkword (strcat "\nSpecify Direction [+/-] : "))) (or (not tmp5) (setq hc$dir:def tmp5)) Am I even close? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 18, 2009 Share Posted May 18, 2009 There are two ways you could approach it, either have an extra "-X" and "-Y" in the direction part, or have a separate prompt after the X/Y saying + or - which would you like to proceed with? Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 18, 2009 Author Share Posted May 18, 2009 The -x and -y would be faster I would think. I didn't know if that could be done. That was why I went the other way. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 18, 2009 Share Posted May 18, 2009 Ok, give this a shot.... Going over my code, I can't believe how many typo's there were... I must've been half asleep when I first wrote it! (defun c:hc (/ *error* vlst ovar cBlk tmp1 tmp2 tmp3 tmp4 blkpt) ; Error Handler (defun *error* (msg) (if ovar (mapcar 'setvar vlst ovar)) ; Return System Variables (if (not (member msg '("Function cancelled" "quit / exit abort"))) (princ (strcat "\n<< Error: " msg " >>"))) ; Print Error Message (princ)) ; Collect and Set System Variables (setq vlst '("CMDECHO" "OSMODE") ovar (mapcar 'getvar vlst)) (mapcar 'setvar vlst '(0 0)) ; Set Defaults (or hc$slp:def (setq hc$slp:def 1)) (or hc$cop:def (setq hc$cop:def 1)) (or hc$spc:def (setq hc$spc:def 1)) (or hc$dir:def (setq hc$dir:def "X")) ; Get Block to Copy (if (and (setq cBlk (car (entsel "\nSelect Block: "))) (eq "INSERT" (cdr (assoc 0 (entget cBlk))))) (progn ; Get User Input (initget 6) (setq tmp1 (getreal (strcat "\nSpecify Slope <" (rtos hc$slp:def) "> : "))) (or (not tmp1) (setq hc$slp:def tmp1)) (initget 6) (setq tmp2 (getint (strcat "\nSpecify Number of Copies <" (itoa hc$cop:def) "> : "))) (or (not tmp2) (setq hc$cop:def tmp2)) (initget 6) (setq tmp3 (getreal (strcat "\nSpecify Spacing <" (rtos hc$spc:def) "> : "))) (or (not tmp3) (setq hc$spc:def tmp3)) (initget "X Y -x -y") (setq tmp4 (getkword (strcat "\nSpecify Axis [X/Y/-X/-Y] <" hc$dir:def "> : "))) (or (not tmp4) (setq hc$dir:def tmp4)) ; Get Block Insertion Point Information and Initiate Counter (setq blkpt (cdr (assoc 10 (entget cBlk))) i 1) ; Copy the Block a Number of Times (repeat hc$cop:def (command "_copy" cBlk "" blkpt) (cond ((eq "X" hc$dir:def) (command (list (+ (* i hc$spc:def) (car blkpt)) (cadr blkpt) (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt))))) ((eq "Y" hc$dir:def) (command (list (car blkpt) (+ (* i hc$spc:def) (cadr blkpt)) (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt))))) ((eq "-x" hc$dir:def) (command (list (+ (* -1. i hc$spc:def) (car blkpt)) (cadr blkpt) (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt))))) ((eq "-y" hc$dir:def) (command (list (car blkpt) (+ (* -1. i hc$spc:def) (cadr blkpt)) (+ (* i (/ hc$spc:def 12.) hc$slp:def) (caddr blkpt))))) ) ; end cond (command) (setq i (1+ i)))) ; Else No Block was Selected (princ "\n<!> No Block Selected <!>")) ; Return Sys Vars Back (mapcar 'setvar vlst ovar) ; Exit Cleanly (princ)) Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 18, 2009 Author Share Posted May 18, 2009 (setq tmp4 (getkword (strcat "\nSpecify Direction [X/-X/Y/-Y] : "))) (or (not tmp4) (setq hc$dir:def tmp4) Something like this maybe Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 18, 2009 Share Posted May 18, 2009 (setq tmp4 (getkword (strcat "\nSpecify Direction [X/-X/Y/-Y] : "))) (or (not tmp4) (setq hc$dir:def tmp4) Something like this maybe Nice one Then you just got to include those terms in the initget function, and also make a few extra conditional statements Good work Quote Link to comment Share on other sites More sharing options...
NH3man! Posted May 18, 2009 Author Share Posted May 18, 2009 Damn much faster than I. I am starting to see how it works though. Thanks again Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 18, 2009 Share Posted May 18, 2009 Damn much faster than I. I am starting to see how it works though. Thanks again Lee It really isn't too difficult when you get the hang of it It just looks like jargon at first glance - you've just gotta break it down bit by bit The reason I named the variables so obscurely such as hc$slp:def with dollar signs and colons, is because they are what is known as "Global Variables" as opposed to local variables - meaning they hold their values throughout the drawing session, so one must give them less common names to prevent possible clashes with other programs that may be running. But more obscure names also means more typo's! Lee Quote Link to comment Share on other sites More sharing options...
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.