Author Topic: Adding draworder to nested entity selections...  (Read 1580 times)

0 Members and 1 Guest are viewing this topic.

KewlToyZ

  • Guest
Adding draworder to nested entity selections...
« on: November 03, 2009, 11:00:18 AM »
I am running this routine to change selected objects layer to a color
then change all objects on that layer to draworder back.
I keep erroring with nested objects though.
A little guidance to the source of the failure please?

Code: [Select]
(defun c:19 (/ lista o1 o2)
   (while
      (setq o1 (nentsel (strcat "\n Select nested entity to change color to 19.  --layer: ")))     
      (if o1
         (progn
           
            (setq o2 (cdr (assoc 8 (entget (car o1)))))
            (if (= o2 "0")
               (setq o2 (cdr (assoc 8 (entget (car (cadddr o1))))))
            )
             ; select all objets on the layer selected above
            (setq grabit(ssget "x" (list (cons 8 o2))))
; change layer color to 19     
            (command "-layer" "c" 19 o2 "")           
            (prompt o2)
           ; and send to back of draworder
            (command "_.draworder" grabit "" "back")           
         )
         (princ "\n* No entities selected *")
      )
   )
   (princ)
)

wizman

  • Bull Frog
  • Posts: 290
Re: Adding draworder to nested entity selections...
« Reply #1 on: November 04, 2009, 12:24:52 AM »
hi sir,


i think command draworder doesnt work with nested entities, please try:



Code: [Select]
(defun c:19 (/ lista o1 o2)
  (vl-load-com)
  (while
    (setq o1
           (nentsel
             (strcat
               "\n Select nested entity to change color to 19.  --layer: "
             )
           )
    )
     (if o1
       (progn

         (setq o2 (cdr (assoc 8 (entget (car o1)))))
         (if (= o2 "0")
           (setq o2 (cdr (assoc 8 (entget (car (cadddr o1))))))
         )
         ;;
         ;; select all objets on the layer selected above
         (setq grabit (ssget "x" (list (cons 8 o2))))
         ;;
         ;; change layer color to 19    
         (command "-layer" "c" 19 o2 "")
         (prompt o2)
         ;;
         ;; and send to back of draworder
         (vl-catch-all-apply
           (function
             (lambda ()
               (vla-MoveToBottom
                 (vla-AddObject
                   (vla-GetExtensionDictionary
                     (vla-item
                       (vla-get-blocks
                         (vla-get-ActiveDocument
                           (vlax-get-acad-object
                           )
                         )
                       )
                       (cdr (assoc 2
                                   (entget
                                     (cdr (assoc 330 (entget (car o1))))

                                   )
                            )
                       )
                     )
                   )
                   "ACAD_SORTENTS"
                   "AcDbSortentsTable"
                 )
                 (vlax-make-variant
                   (vlax-safearray-fill
                     (vlax-make-safearray
                       vlax-vbobject
                       '(0 . 0)
                     )
                     (list (vlax-ename->vla-object
                             (car o1)
                           )
                     )
                   )
                 )
               )
             )
           )
         )
       )
       (princ "\n* No entities selected *")
     )
     (vla-regen (vla-get-activedocument (vlax-get-acad-object))
                1
     )
  )
  (princ)
)

KewlToyZ

  • Guest
Re: Adding draworder to nested entity selections...
« Reply #2 on: November 24, 2009, 02:36:40 PM »
Yeah I am finding it difficult to nail down myself.
Nice approach in your code, many thanks  ;-)

wizman

  • Bull Frog
  • Posts: 290
Re: Adding draworder to nested entity selections...
« Reply #3 on: November 25, 2009, 10:43:42 AM »
Glad to help KewlToyZ , btw  belated HB :-)