Jump to content

How do you get vlisp to round up?


BLOACH85

Recommended Posts

:huh: 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?:?
Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...