Jump to content

Recommended Posts

Posted

Suppose that I have a room and I want to divide it into specific points.

My codes are running well up to the crossing points. I mean How can I support

the X and Y for the divided points at X and Y as well ?

 

(defun c:cen (/ pt1 pt3 pt2 pt4 XLen YLen Xnum Ynum)
 (setq pt1 (getpoint"\n Specify The Left corner: ")
pt3 (getcorner pt1 "\n Specify the Right corner: ")
)
 ;; ******** the rest of rectangl points ****************
 (setq pt2 (list (car pt3)(cadr pt1))
pt4 (list (car pt1)(cadr pt3))
)
 ;; ****** Lengths of X and Y **************
 (setq XLen (distance pt1 pt2)
YLen (distance pt1 pt4)
)
 ;; ****** divide the X and Y **************
 (setq Xnum (getint "\n Specify Number of X elements: ");; for instance 5
Ynum (getint "\n Specify Number of Y elements: ");; for instance 4
)
 

Posted

Could you explain in more detail?

Do you just want to collect the point of the intersections of the x’s and y’s?

Use the polar function and the repeat function

Posted (edited)

Can not see any problem you just need a loop within a loop

 

(repeat Xnum

(repeat ynum

( do your thing here)

)

(setq xnum (+ xnum Xlen))

)

Edited by BIGAL
typo
Posted

The crosses in RED are what I would like to get. Although these points

are would be changed according to user input.

 

Many thanks

 

Michaels

Cross.jpg

Posted

I wrote this lisp for enforcements some moons ago

Looks like this is exactly what you looking for

Change to suit

 

~'J'~

grid_cross.LSP

Posted
I wrote this lisp for enforcements some moons ago

Looks like this is exactly what you looking for

Change to suit~'J'~

 

Thanks fixo,

 

I have two questions about your codes ,

- Why did you use the following since you didn't use it later in the routine ?

- And what does it mean?

pc (mapcar (function (lambda (x y)(* (+ x y) 0.5)))

 

 

It is really works fine, But I am looking forward to learing how codes are running and should be built with according to user inputs.

 

Any suggestion from any one would be highly appreciated.

 

Regards

Posted

Sorry,

I can't to expalin the things good because of my english level

and by this reason I'm afraid to mix something

Feel free to change the code to your suit

 

~'J'~

Posted
Sorry,

I can't to expalin the things good because of my english level

and by this reason I'm afraid to mix something

Feel free to change the code to your suit

~'J'~

 

Thank you so much for your reply.

 

I do understand.

 

Best Regards,

Posted

Hello,

 

I still worndering how to get the intersection points in the pose.

 

Any idea ?

 

Best regards,

Posted

what are you not understanding?

do you know how to use the polar and repeat functions?

Posted
what are you not understanding?

do you know how to use the polar and repeat functions?

 

Yes I do.

 

But my question was about the intesection of the lines that would be made by repeat function.

 

Regards,

Posted

do you need to show the lines?

or do you just want the coordinates of the intersections?

 

if you could explain in great detail maybe i could help

Posted
do you need to show the lines?

or do you just want the coordinates of the intersections?

if you could explain in great detail maybe i could help

 

Thanks for your concerns,

 

I would like to get the coordinates of the intersections to insert a specific block at the end of routine.

 

Thanking you.

Posted

It's a very interesting thread for unknown limits of points to be created.

 

Regards,

Posted
It's a very interesting thread for unknown limits of points to be created.

Regards,

 

Thanks,

 

But I wonder why nobody could solve or give an answer to my thread !! !! !!

 

Hope this won't be that complicated .

 

Regards,

Posted

When I asked if you knew the polar and repeat function you replied yes, so I thought you had it figured out.

First of all are the elements the lines or the spaces between the lines?

Posted

With a touch of ObjectArx from Alexander Rivilis:

 

DynGrid.gif

 

 

;; An example of Dynamic Grid creation using a grRead substitute,
;; Program by Lee Mac, using DynDraw by Alexander Rivilis
;; (http://www.maestrogroup.com.ua/support/dyndraw.zip)

(defun c:DynGrid ( / *error* line vers step bit v m n p1 p2 p3 p4 i j pi/2 prev )
 ;; © Lee Mac 2010

 (defun *error* ( msg )
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (redraw) (princ)    
 )

 (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
         (not (initget 6))
         (setq m
           (getint "\nSpecify Number of Rows: ")
         )
         (not (initget 6))
         (setq n
           (getint "\nSpecify Number of Columns: ")
         )
         (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 'UpdateGridCallBack)
     
     (setq p2
       (dyndraw "UpdateGridCallBack"
         "\nPick Second Point [Columns/Rows] : "
         "Columns Rows"
         (+ 1 2 128 2048)
         -1
         nil
       )
     )
    
     (redraw)
    
     (if (vl-consp p2)
       (progn
         (setq i    (/ (- (cadr p2) (cadr p1)) m)
               j    (/ (- (car  p2) (car  p1)) n)
               pi/2 (/ pi 2.)
               p3   (cons (car p2) (cdr p1))
               p4   (cons (car p1) (cdr p2))
         )
         (
           (lambda ( k )
             (repeat (1- n)
               (apply (function line)
                 (mapcar
                   (function
                     (lambda ( point ) (trans point 1 0))
                   )
                   (list (polar p1 0 (* (setq k (1+ k)) j))
                         (polar p4 0 (* k j))
                   )
                 )
               )
             )
           )
           0
         )
         (
           (lambda ( k )
             (repeat (1- m)
               (apply (function line)
                 (mapcar
                   (function
                     (lambda ( point ) (trans point 1 0))
                   )
                   (list (polar p1 pi/2 (* (setq k (1+ k)) i))
                         (polar p3 pi/2 (* k i))
                   )
                 )
               )
             )
           )
           0
         )
       )
     )
   )
 )
 (princ)
)

(defun UpdateGridCallBack ( argument )

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

     (cond
       (
         (eq "Columns" argument)

         (initget 6)
         (setq n
           (cond
             ( (getint (strcat "\nSpecify Number of Columns <" (itoa n) "> : ")) )
             ( n )
           )
         )
       )
       (
         (eq "Rows" argument)

         (initget 6)
         (setq m
           (cond
             ( (getint (strcat "\nSpecify Number of Rows <" (itoa m) "> : ")) )
             ( m )
           )
         )
       )
       (
         (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)) m)
               j    (/ (- (car  p2) (car  p1)) n)
               pi/2 (/ pi 2.)
               p3   (cons (car p2) (cdr p1))
               p4   (cons (car p1) (cdr p2)))

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

 

You will need this Arx file in your support path (make sure you pick the right version/bit width):

 

http://www.maestrogroup.com.ua/support/dyndraw.zip

Posted

Have you tried using DIVIDE or MEASURE at the command line? DIVIDE will divide a line or arc into equal parts and MEASURE will place a point at any given distance that you specify.

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