Jump to content

Divide an area by a specific amount


Recommended Posts

When creating the shutter in the attachment I divided the total height by the number of slats. Then copied each slat all the way down the shutter. There must be a faster way to do this! Is there a command that will divide an area into a specific number of parts?

 

This would be a huge time saver for me and I thank anyone with suggestions.

 

windowo.th.png

Link to comment
Share on other sites

Sorry I forgot to attach the image at first. It's there now.

 

How would you go about using the DIVIDE command for creating the slats in a shutter. I just tried the command but it didn't seem to be working for me.

Link to comment
Share on other sites

If the slat is a block, you could use either DIVIDE or MEASURE (whichever suits your situation), and select the 'block' option.

Link to comment
Share on other sites

Just tried again with the slat as a block but I was getting some funny results. I'll try your link to see if it helps.

Link to comment
Share on other sites

You can also use the array command and plug in the values.

Row X

Column 1

 

Preview before accpting.

Link to comment
Share on other sites

@ LeeMac The problem with that method is that it doesn't adjust the slats to different size shutters.

Link to comment
Share on other sites

@ LeeMac The problem with that method is that it doesn't adjust the slats to different size shutters.

 

The same with the array method.

 

It would be very convenient if you could just type in the number of slats to fit in a given rectangle, and the command would do the division.

Link to comment
Share on other sites

How about something like this?

 

(defun c:slat ( / line p1 p2 p3 n i pi/2 )
 ;; Lee Mac  ~  08.05.10

 (defun line (s e)
   (entmakex
     (list
       (cons 0 "LINE")
       (cons 10 s)
       (cons 11 e)
     )
   )
 )

 (if
   (and (setq p1 (getpoint  "\nPick First Corner Point: "))
        (setq p2 (getcorner "\nPick Second Point: " p1))
        (setq n  (getint    "\nSpecify Number of Slats: ")))
   (progn
     (setq i (/ (- (cadr p2) (cadr p1)) n)
        pi/2 (/ pi 2.) p3 (cons (car p2) (cdr p1)))
     (
       (lambda ( j )
         (repeat (1- n)
           (apply (function line)
             (mapcar
               (function
                 (lambda ( point )
                   (trans point 1 0)
                 )
               )
               (list
                 (polar p1 pi/2 (* (setq j (1+ j)) i))
                 (polar p3 pi/2 (* j i))
               )
             )
           )
         )
       )
       0
     )
   )
 )
 (princ)
)

Link to comment
Share on other sites

Knew you would come up with a good lisp Lee, sometimes we just need to be redirected a bit.

 

Thanks

Link to comment
Share on other sites

With the help of ObjectARX we can create a Dynamic Version :)

 

DynSlat.gif

 

;; An example of Dynamic Slat creating using a grRead substitute,
;; Function by Lee Mac, using DynDraw by Alexander Rivilis

(defun c:slat ( / line vers step bit v n p1 p2 p3 pi/2 i prev )
 ;; Lee Mac  ~  08.05.10
 (vl-load-com)

 (defun line (s e)
   (entmakex
     (list
       (cons 0 "LINE")
       (cons 10 s)
       (cons 11 e)
     )
   )
 )

 (setq vers
   '((18.0 . "2010")
     (17.2 . "2009")
     (17.1 . "2008")
     (17.0 . "2007")
     (16.2 . "2006")
     (16.1 . "2005")
     (16.0 . "2004")
     (15.6 . "2002"))
 )
 
 (setq step 1e-6
       bit (if (eq "X86"
                 (strcase
                   (getenv "PROCESSOR_ARCHITECTURE")
                 )
               )
             "x32" "x64"
            )
 )

 (cond
   (
     (not
       (setq v
         (cdr
           (assoc
             (atof
               (getvar 'ACADVER)
             )
             vers
           )
         )
       )
     )
    (princ "\n** Not Compatible in this Version **")
   )
   (
     (not
       (and
         (setq n
           (getint "\nSpecify Number of Slats: ")
         )
         (setq p1
           (getpoint "\nPick First Corner Point: ")
         )
       )
     )
     (princ "\n*Cancel*")
   )
   (
     (and
       (null dyndraw)
       (not
         (arxload
           (strcat "DynDraw" v
             (if (eq "2010" v) bit "") ".arx"
           )
         )
       )
     )
    (princ "\n** Arx File not Found **")
   )
   (    
     (vl-acad-defun 'UpdateSlatCallBack)
     
     (setq p2
       (dyndraw "UpdateSlatCallBack"
         "\nPick Second Point [Number] : "
         "Number"
         (+ 1 2 128 2048)
         -1
         nil
       )
     )
    
     (redraw)
    
     (if (vl-consp p2)
       (progn
         (setq i (/ (- (cadr p2) (cadr p1)) n)
            pi/2 (/ pi 2.) p3 (cons (car p2) (cdr p1)))
         (
           (lambda ( j )
             (repeat (1- n)
               (apply (function line)
                 (mapcar
                   (function
                     (lambda ( point )
                       (trans point 1 0)
                     )
                   )
                   (list
                     (polar p1 pi/2 (* (setq j (1+ j)) i))
                     (polar p3 pi/2 (* j i))
                   )
                 )
               )
             )
           )
           0
         )
       )
     )
   )
 )
 (princ)
)

(defun UpdateSlatCallBack ( argument / tmp )

 (cond
   (
     (eq 'STR (type argument))

     (redraw)

     (if (eq "Number" argument)
       (if
         (setq tmp
           (getint "\nSpecify Number of Slats: ")
         )
         (setq n tmp)
       )
       (princ "\n** Invalid Keyword **")
     )
    (setq argument t)
   )
   (
     (vl-consp argument)

     (or prev (setq prev argument))

     (if (< step (distance prev argument))
       (progn
         (setq prev argument p2 argument)

         (setq i    (/ (- (cadr p2) (cadr p1)) n)
               pi/2 (/ pi 2.)
               p3   (cons (car p2) (cdr p1))
               p4   (cons (car p1) (cdr p2)))

         (redraw)
         (grvecs (cons -3 (list p1 p3 p3 p2 p1 p4 p4 p2)))
         
         (
           (lambda ( j )
             (repeat (1- n)
               (grvecs
                 (cons -30
                   (list (polar p1 pi/2 (* (setq j (1+ j)) i))
                         (polar p3 pi/2 (* j i))
                   )
                 )
               )
             )
           )
           0
         )
       )
     )
   )
 )
 argument
)

 

You will need the correct version of DynDraw by Alexander Rivilis, here.

 

Lee

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