Author Topic: Grab all...  (Read 1884 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 462
Grab all...
« on: May 13, 2013, 11:52:18 PM »
After arrying (5 columns) an object, how to get all the 5 objects?
l want to change the layer of the 5 objects and make them as a black.
Thanks in advance.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Grab all...
« Reply #1 on: May 14, 2013, 02:06:19 AM »
The array command or so , is just a copy of the original object  AFAIK .

Can you show the code that you used to make that array ?

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Grab all...
« Reply #2 on: May 14, 2013, 02:29:02 AM »
I haven't actually started the code but the following is the idea:

Code: [Select]
(defun c:Test (/ Ent)
(command "_.point")
(setq Ent (Entlast))
(command "_.-array" Ent "" "Rectangular" 5 1 100)

; grab the 5 obiects created above
; then change layer and make them to a block
)

Thanks

fixo

  • Guest
Re: Grab all...
« Reply #3 on: May 14, 2013, 03:16:57 AM »
Try this one but adopt to your needs

Code: [Select]
(defun c:sb (/ pt Ent ss)
(setq ss (ssadd))
(setq pt (getpoint "\nPick first point:")
      )
(entmake
(list
(cons 0 "POINT")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPoint")
(cons 10 pt)
(cons 8  "0")
)
)
(setq Ent (Entlast))
(command "_.-array" Ent "" "Rectangular" 5 1 100)
  (command "_.zoom" "_e")
(setq ss (ssadd Ent ss))
(repeat 4 (setq Ent (entnext Ent))
(ssadd Ent ss)
);repeat
 
; grab the 5 obiects created above
; then change layer and make them to a block
(command "_.chprop" ss "" "_LA" "MyCoolLayer" "" "");<-- change layer name here
(command "-block" "MyBlock" pt ss  "");<-- change block name here
  (command "_.zoom" "_p")
(princ)
)

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Grab all...
« Reply #4 on: May 14, 2013, 08:55:20 AM »
Try this instead of the array command .

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ *error* showdcl checkitout blk p on i j pt sad)
  2. ;;;--- Tharwat 14. May. 2013 ---;;;
  3.   (or doc
  4.   )
  5.   (defun *error* (x)
  6.     (if doc
  7.       (vla-endundomark doc)
  8.     )
  9.     (if f
  10.       (progn (close f) (vl-file-delete fn))
  11.     )
  12.     (princ "\n*Cancel*")
  13.   )
  14.   (defun ShowDcl (/ sn f str dcl_id l lays pos)
  15.     (setq fn (vl-filename-mktemp "dcl.dcl"))
  16.     (setq f (open fn "w"))
  17.     (foreach str
  18.              (list
  19.                "Layers : dialog { label = \"Layer List\"; fixed_width = true;"
  20.                ": popup_list { label = \"Select Layer\"; key = \"layer\"; width = 32;}"
  21.                ": boxed_row { label = \"Action\";" ": row {"
  22.                ": button { label = \"Accept\"; key = \"accept\"; is_default = true;  }"
  23.                ": button { label = \"Cancel\"; key = \"cancel\"; is_cancel = true; }}}}"
  24.               )
  25.       (write-line str f)
  26.     )
  27.     (close f)
  28.     (setq dcl_id (load_dialog fn))
  29.     (if (not (new_dialog "Layers" dcl_id))
  30.       (exit)
  31.     )
  32.     (while (setq l (tblnext "LAYER" (not l)))
  33.       (setq lays (cons (cdr (assoc 2 l)) lays))
  34.     )
  35.     (setq lays (reverse lays))
  36.     (start_list "layer")
  37.     (mapcar 'add_list lays)
  38.     (end_list)
  39.       "accept"
  40.       "(setq pos (get_tile \"layer\"))(done_dialog)"
  41.     )
  42.     (action_tile "cancel" "(done_dialog)")
  43.     (start_dialog)
  44.     (unload_dialog dcl_id)
  45.     (if pos
  46.       (princ (nth (atoi pos) lays))
  47.     )
  48.   )
  49.   (defun CheckItOut (/ blk)
  50.     (while (and (setq blk (getstring t "\n specify New Block name :"))
  51.                 (tblsearch "BLOCK" blk)
  52.            )
  53.       (princ "\n Block is already existed ! < Try again > ")
  54.     )
  55.     (if (not (tblsearch "BLOCK" blk))
  56.       blk
  57.     )
  58.   )
  59.   (if (and (setq p (getpoint "\n Specify point :"))
  60.            (setq blk (CheckItOut))
  61.            (setq on (ShowDcl))
  62.       )
  63.     (progn
  64.       (vl-file-delete fn)
  65.       (vla-StartUndomark doc)
  66.       (setq sad (ssadd))
  67.       (setq i  0
  68.             pt p
  69.       )
  70.       (ssadd (entmakex (list '(0 . "POINT") (cons 10 p) (cons 8 on)))
  71.              sad
  72.       )
  73.       (repeat 4
  74.         (setq p (polar p (* pi 0.5) 100))
  75.         (ssadd (entmakex (list '(0 . "POINT") (cons 10 p) (cons 8 on)))
  76.                sad
  77.         )
  78.       )
  79.       (command "_.-block" blk "_none" pt sad "")
  80.       (command "_.-insert" blk "_none" pt "" "" "")
  81.       (vla-put-layer (vlax-ename->vla-object (entlast)) on)
  82.       (vla-endundomark doc)
  83.     )
  84.   )
  85.   (princ "\n Written By Tharwat Al Shoufi")
  86.   (princ)
  87. )
  88.  
  89.  

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Grab all...
« Reply #5 on: May 15, 2013, 11:45:00 PM »
Thanks to fixo & Tharwat.
fixo: your solution provides a few lines and simple explanation in the code. Neat is the word.
Tharwat: you are a LG = Lisp Giant.
Many thanks to both of you!

BTW. how to make this work if the source object arraying to a sepecified path (two points)?
Please see my another thread "How to array object to a path by selecting 2 points?"
« Last Edit: May 15, 2013, 11:49:15 PM by MeasureUp »

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Grab all...
« Reply #6 on: May 16, 2013, 12:40:31 AM »
Thanks to fixo & Tharwat.
Tharwat: you are a LG = Lisp Giant.
You're welcome .

I am also still learning and not a Lisp Giant yet  ;-)