BLOACH85 Posted February 2, 2009 Share Posted February 2, 2009 Im now working on a lisp routine that will figure the picket spacing out on any user defined rail. Now to start the user must supply a distance which is from the center line of one post to the other. Then it will subtract one pipesize and add one picket size. This number is then divided by 4 witch is the max. picket spacing center to center. if that number came out to 13.025 it would need to round up to 14. Then the 14 would be subtracted by 2 because the 2 end spaces are different then divided by the original number -1 pipe + 1 picket. This should give the inside pickets. the remaining dimension should then be divided by 2 and this is the end spaces. first how do you get it to round up? then is there and way to get this displayed in a dialog box? Quote Link to comment Share on other sites More sharing options...
CAB Posted February 2, 2009 Share Posted February 2, 2009 (fix (+ 13.25 0.99)) Quote Link to comment Share on other sites More sharing options...
CAB Posted February 2, 2009 Share Posted February 2, 2009 Here is an example routine, not exactly what you want. ;; CAB 10/26/2006 ;; Divide a dividable object based on spacing desired (defun c:mydivide (/ ent start num ed dist 1stpt) (vl-load-com) (if (and (setq ent (entsel "\nSelect object to divide.")) (not (vl-catch-all-error-p (setq start (vl-catch-all-apply 'vlax-curve-getpointatparam (list (car ent) 0.0)))) ) ) (progn (setq ent (car ent)) (initget 7) (setq num (getint "\nEnter the number of points.(spaces -1)")) (initget "Half Whole") (setq ed (getkword "\nEnd segment Half or Whole space? [Half/Whole] <Half> ")) (setq endpar (vlax-curve-getendparam ent) len (vlax-curve-getdistatparam ent endpar) ) (if (= ed "Whole") ; 1st & last are full spaces (setq 1stpt (/ len (1+ num)) step 1stpt ) (setq step (/ len num) 1stpt (/ step 2.0) ) ) (command "_.point" "_non" (vlax-curve-getpointatdist ent 1stpt)) (setq dist (+ step 1stpt)) (repeat (1- num) (command "_.point" "_non" (vlax-curve-getpointatdist ent dist)) (setq dist (+ dist step)) ) ) (prompt "\n*** ERROR - Can not divide that object. ***") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
ABuckingham Posted February 2, 2009 Share Posted February 2, 2009 Just a quick question, the reason you're doing (fix (+ x 0.99)) is because if I did (+ 1 (fix x)) and x was already an integer it would produce a number that was too high. Did you pick two decimal places for 0.99 based on an assumed tolerance or does it work regardless of the required precision? Quote Link to comment Share on other sites More sharing options...
CAB Posted February 2, 2009 Share Posted February 2, 2009 Assumed tolerance. Also (1+ (fix 13.00)) would be incorrect. No? Quote Link to comment Share on other sites More sharing options...
CAB Posted February 2, 2009 Share Posted February 2, 2009 very cool link about rounding http://en.wikipedia.org/wiki/Rounding#Round-to-even_method Discussion on rounding http://www.theswamp.org/forum/index.php?topic=3076.0 http://www.theswamp.org/index.php?topic=8511.msg109002#msg109002 Quote Link to comment Share on other sites More sharing options...
ABuckingham Posted February 2, 2009 Share Posted February 2, 2009 Thanks for the links, I was a bit surprised that there wasn't a build in ceiling function but I'm glad I got to learn a bit about implementing one. Quote Link to comment Share on other sites More sharing options...
CAB Posted February 2, 2009 Share Posted February 2, 2009 You're quite welcome. Quote Link to comment Share on other sites More sharing options...
BLOACH85 Posted February 3, 2009 Author Share Posted February 3, 2009 Im not actually getting the routine to divide or anything i just want the calculations to work the plot the final answer in a dialog box. example : : : : : : : : : 5-1/4 : 3'-8 : 5-1/4 : ----------------------------- 11 SPACES @ 4 See i just want the result but im not a whole lot familiar with doing a lisp routine that is nothing but calculations and im not sure about dialog boxes Quote Link to comment Share on other sites More sharing options...
BLOACH85 Posted February 3, 2009 Author Share Posted February 3, 2009 By looking through the autocadets guide i think i can figure out dialog boxes but how do i do the calculations in a lisp that does just calculations? and do it in decimal form but post the final result in feet and inches? rtos? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 3, 2009 Share Posted February 3, 2009 You can change units using RTOS "units" "precision" where "units" and "precision" are both integers. i..e rtos 2 2 is decimal, to two dp. Quote Link to comment Share on other sites More sharing options...
BLOACH85 Posted February 3, 2009 Author Share Posted February 3, 2009 OK so the rtos works ok good then im just screwing up with everything else. When i get a little further with this routine ill post it and see if you have any ideas on this one lee mac. so have you worked with dialog boxes much? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 3, 2009 Share Posted February 3, 2009 Not at all I'm afraid... that is one thing I have no experience in Quote Link to comment Share on other sites More sharing options...
BLOACH85 Posted February 3, 2009 Author Share Posted February 3, 2009 Well i may be taking on too much at one time but im used to it. its either this or clean house hmmmmm. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 3, 2009 Share Posted February 3, 2009 Well i may be taking on too much at one time but im used to it. its either this or clean house hmmmmm. Yeh, a real tough decision that one... 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.