Jump to content

How can i use the (array ) command in Autolisp ???


سبع الليل

Recommended Posts

بسم الله الرحمن الرحيم

الحمد لله رب العالمين ، و الصلاة و السلام على أشرف المرسلين ، أشهد أن لا إله إلا الله ، و أن محمداً رسول الله ، و أن عيسى المسيح عبد الله و رسوله و كلمته ألقاها إلى مريم ،، و بعد :

 

Hii Guys and cad msters :

I really love you , and happy to join this great forum :)

 

(command "circle" p1 "d" d1 "")
(setq soda ( entlast))
(command "hatch" "s" soda "")
(command "array" "l" "" "r" "1" "10" "150" "")

 

This will make an array for a circle along ( + X ) direction

What shall I do if i need the array in (-X) direction ,,,, or if i want to specify an angle for the array ??

Link to comment
Share on other sites

(Defun c:demo (/ soda p1 d1 dir ang)
 (setq p1 (Getpoint "\nPick point:"))
 (setq d1 (getdist "\nEnter Circle Diameter size: "))
 (setq soda (ssadd)) ;<-- empty selection set
 (command "circle" p1 "d" d1 "")
 (ssadd (entlast) soda) ;<--add  circle to selection set
 (command "hatch" "s" soda "")
 (ssadd (entlast) soda);<--add  hatch to selection set
 ;;; 	option for direction	;;;
 (initget 1 "R L")
 (setq dir (getkword "\nChoose Direction [Left/Right]: "))
 ;;;				;;;
 (command "array"
          soda  ""  "r" "1" "10"
          (if (eq dir "L")
            (- 150)
            150
          )
          
 )
 (princ)
)

 

Now whats the deal with the "angle" ? polar array angle? or directional angle?

Link to comment
Share on other sites

My approach . :)

 

(defun c:TesT (/ *error* GrLeader c s p d g pt)
;;; Author : Tharwat Al Shoufi 14. 03. 2013 ;;;
 (defun *error* (x) (redraw) (princ "\n*Cancel*"))
 (defun GrLeader (pt d w / p1 p2 p3 p4)
   (if (eq "R" w)
     (setq p1 (polar pt (* pi 0.5) (* d 4.))
           p2 (polar p1 (/ pi 4.) (* d 4.))
           p3 (polar p2 pi d)
           p4 (polar p2 (* pi 1.5) d)
     )
     (setq p1 (polar pt (* pi 0.5) (* d 4.))
           p2 (polar p1 (* (/ pi 4.) 3.) (* d 4.))
           p3 (polar p2 0. d)
           p4 (polar p2 (* pi 1.5) d)
     )
   )
   (grvecs (list -1 pt p1 p1 p2 p2 p3 p2 p4))
   (princ)
 )
 (setq d 75.) ; Radius of the Circle 
 (if (and (setq s (ssadd)
                p (getpoint "\n Specify Circle insertion point:")
          )
          (ssadd (setq c (entmakex (list '(0 . "CIRCLE") (cons 10 p) (cons 40 d)))) s)
     )
   (progn (command "_.hatch" "s" c "")
          (ssadd (entlast) s)
          (while (eq (car (setq g (grread t 15 0))) 5)
            (redraw)
            (princ "\r Specify the Direction ")
            (if (> (car (cadr g)) (car p))
              (Grleader p d "R")
              (GrLeader p d nil)
            )
          )
          (cond ((and (eq 3 (car g)) (> (car (cadr g)) (car p))) (command "_.array" s "" "r" "1" "10" 150))
                ((and (eq 3 (car g)) (< (car (cadr g)) (car p))) (command "_.array" s "" "r" "1" "10" -150))
                (t (princ "*Cancel*"))
          )
   )
 )
 (redraw)
 (princ "\n Written by Tharwat Al Shoufi")
 (princ)
)

Link to comment
Share on other sites

Really ::::

This is a great forum

Thank you all ,, Every day i learn new something ...

 

 

(Defun c:demo (/ soda p1 d1 dir ang)
 (setq p1 (Getpoint "\nPick point:"))
 (setq d1 (getdist "\nEnter Circle Diameter size: "))
 (setq soda (ssadd)) ;<-- empty selection set
 (command "circle" p1 "d" d1 "")
 (ssadd (entlast) soda) ;<--add  circle to selection set
 (command "hatch" "s" soda "")
 (ssadd (entlast) soda);<--add  hatch to selection set
 ;;; 	option for direction	;;;
 (initget 1 "R L")
 (setq dir (getkword "\nChoose Direction [Left/Right]: "))
 ;;;				;;;
 (command "array"
          soda  ""  "r" "1" "10"
          (if (eq dir "L")
            (- 150)
            150
          )
          
 )
 (princ)
)

 

Now whats the deal with the "angle" ? polar array angle? or directional angle?

 

ssadd is new for me ,,, but really it is a great and very useful & important .... thank you mr pBe very much

what i need is the directional angle

Link to comment
Share on other sites

My approach . :)

 

(defun c:TesT (/ *error* GrLeader c s p d g pt)
;;; Author : Tharwat Al Shoufi 14. 03. 2013 ;;;
 (defun *error* (x) (redraw) (princ "\n*Cancel*"))
 (defun GrLeader (pt d w / p1 p2 p3 p4)
   (if (eq "R" w)
     (setq p1 (polar pt (* pi 0.5) (* d 4.))
           p2 (polar p1 (/ pi 4.) (* d 4.))
           p3 (polar p2 pi d)
           p4 (polar p2 (* pi 1.5) d)
     )
     (setq p1 (polar pt (* pi 0.5) (* d 4.))
           p2 (polar p1 (* (/ pi 4.) 3.) (* d 4.))
           p3 (polar p2 0. d)
           p4 (polar p2 (* pi 1.5) d)
     )
   )
   (grvecs (list -1 pt p1 p1 p2 p2 p3 p2 p4))
   (princ)
 )
 (setq d 75.) ; Radius of the Circle 
 (if (and (setq s (ssadd)
                p (getpoint "\n Specify Circle insertion point:")
          )
          (ssadd (setq c (entmakex (list '(0 . "CIRCLE") (cons 10 p) (cons 40 d)))) s)
     )
   (progn (command "_.hatch" "s" c "")
          (ssadd (entlast) s)
          (while (eq (car (setq g (grread t 15 0))) 5)
            (redraw)
            (princ "\r Specify the Direction ")
            (if (> (car (cadr g)) (car p))
              (Grleader p d "R")
              (GrLeader p d nil)
            )
          )
          (cond ((and (eq 3 (car g)) (> (car (cadr g)) (car p))) (command "_.array" s "" "r" "1" "10" 150))
                ((and (eq 3 (car g)) (< (car (cadr g)) (car p))) (command "_.array" s "" "r" "1" "10" -150))
                (t (princ "*Cancel*"))
          )
   )
 )
 (redraw)
 (princ "\n Written by Tharwat Al Shoufi")
 (princ)
)

 

 

Thank you eng. Tharwat

but there is somethings i can't understand it

any way i am trying to understand and use

Link to comment
Share on other sites

thank you mr pBe very much......

 

what i need is the directional angle

 

If you want to maintain the use of the command ARRAY, you can twist the UCS like so:

(Defun c:demo (/ soda p1 d1 dir ang)
 (setq p1 (Getpoint "\nPick point:"))
 (setq d1 (getdist p1 "\nEnter Circle Diameter size: "))
 (setq d (getdist  "\nEnter Distance between circles: "))
 (setq it (getint "\nEnter Number of itmes: "))
 (setq soda (ssadd)) ;<-- empty selection set
 (command "circle" p1 "d" d1 "")
 (ssadd (entlast) soda) ;<--add  circle to selection set
 (command "hatch" "s" soda "")
 (ssadd (entlast) soda);<--add  hatch to selection set
 (setq p2 (getpoint p1 "\nPick point for direction "))
 (command "_UCS" "_3P" p1 p2 "" "")
 (command "array"
          soda  ""  "r" "1" it  d  )
 (command "_ucs" "_World")
 (princ)
)

 

There's probably an angle prompt on newer version of CAD for array. :)

 

Or you can use the command COPY:

 

(Defun c:demo2 ()
(setq p1 (Getpoint "\nPick point:"))
(setq d1 (getdist p1 "\nEnter Circle Diameter size: "))
(setq d (getdist  "\nEnter Distance between circles: "))
(setq it (getint "\nEnter Number of itmes: "))
(setq soda (ssadd))
(command "circle" p1 "d" d1 "")
(ssadd (entlast) soda)
(command "hatch" "s" soda "")
(ssadd (entlast) soda)
(setq p2 (getpoint p1 "\nPick point for direction "))
 	(setq ang (angle p1 p2))
 	(repeat it
         	(setq p2 (polar p1 ang d))          
	(command "_copy" soda "" "_non" p1 "_non" p2)
         	(setq p1 p2)
         )
 )

 

Both codes doesn't require a negative value for direction at all. play around with the plain and simple snippets until you get the hang of it, then you can start experimenting with codes like the one posted by tharwat.

 

HTH

Link to comment
Share on other sites

If you want to maintain the use of the command ARRAY, you can twist the UCS like so:

(Defun c:demo (/ soda p1 d1 dir ang)
 (setq p1 (Getpoint "\nPick point:"))
 (setq d1 (getdist p1 "\nEnter Circle Diameter size: "))
 (setq d (getdist  "\nEnter Distance between circles: "))
 (setq it (getint "\nEnter Number of itmes: "))
 (setq soda (ssadd)) ;<-- empty selection set
 (command "circle" p1 "d" d1 "")
 (ssadd (entlast) soda) ;<--add  circle to selection set
 (command "hatch" "s" soda "")
 (ssadd (entlast) soda);<--add  hatch to selection set
 (setq p2 (getpoint p1 "\nPick point for direction "))
 (command "_UCS" "_3P" p1 p2 "" "")
 (command "array"
          soda  ""  "r" "1" it  d  )
 (command "_ucs" "_World")
 (princ)
)

 

There's probably an angle prompt on newer version of CAD for array. :)

 

Or you can use the command COPY:

 

(Defun c:demo2 ()
(setq p1 (Getpoint "\nPick point:"))
(setq d1 (getdist p1 "\nEnter Circle Diameter size: "))
(setq d (getdist  "\nEnter Distance between circles: "))
(setq it (getint "\nEnter Number of itmes: "))
(setq soda (ssadd))
(command "circle" p1 "d" d1 "")
(ssadd (entlast) soda)
(command "hatch" "s" soda "")
(ssadd (entlast) soda)
(setq p2 (getpoint p1 "\nPick point for direction "))
 	(setq ang (angle p1 p2))
 	(repeat it
         	(setq p2 (polar p1 ang d))          
	(command "_copy" soda "" "_non" p1 "_non" p2)
         	(setq p1 p2)
         )
 )

 

Both codes doesn't require a negative value for direction at all. play around with the plain and simple snippets until you get the hang of it, then you can start experimenting with codes like the one posted by tharwat.

 

HTH

 

 

 

Mr pBe

really , you Are awesome great man

thank you a lot a lot a lot a lot a lot a lot a lot a lot a lot a lot a lot a lot

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