Author Topic: Dynamic Blocks Visibility Setting  (Read 1885 times)

0 Members and 1 Guest are viewing this topic.

HD

  • Guest
Dynamic Blocks Visibility Setting
« on: October 21, 2005, 08:37:05 AM »
Hello All,


Does anyone know if there's a way to programmatically change the visibility setting of a dynamic block?

       Block Name: "AUX_LOC_ACCBLE_DCS"
   Anonymous Name: "*U2"
                at point, X=   7.5246  Y=   5.0503  Z=   0.0000
   X scale factor:    1.0000
   Y scale factor:    1.0000
   rotation angle:      0
   Z scale factor:    1.0000
  Scale uniformly: No
  Allow exploding: Yes
       Visibility: Show all lines and arcs for symbol.

                  ATTRIBUTE  Layer: "0"
                            Space: Model space

Thanks!

Sdoman

  • Guest
Re: Dynamic Blocks Visibility Setting
« Reply #1 on: October 21, 2005, 10:12:04 AM »
I just wrote this about two days ago and it is still a work in progress, so may not be totally debugged.  Function was adapted from code snippets found on the net.  After I wrote it, I came across a function by Tony Tanzillo that is way more elegant then this one..

Code: [Select]
(defun PushDBProps (objent lst / blkprops propname propvalue n )
  ;; (PushDBProps ename|object '(("Visibility" . "No Shelves")("Width" . 36.0)...))
  ;; objent: ename or object of dynamicblock
  ;; lst: list of dotted pairs '((propname1 . newvalue1)(propname2 . newvalue2)...)
  (if (= 'ENAME (type objent))
    (setq objent (vlax-ename->vla-object objent))
  )
  (setq blkprops (vlax-safearray->list
            (vlax-variant-value (vla-getdynamicblockproperties objent))
          )
  )
  (foreach prop lst
    (setq n 0)
    (setq propname (car prop))
    (setq propvalue (cdr prop))
    (while (< n (length blkprops))
      (if (= propname (vlax-get-property (nth n blkprops) "PropertyName"))
        (progn (vlax-put-property (nth n blkprops) "Value" propvalue)
               (setq n (length blkprops))
        )
        (setq n (1+ n))
      )
    ) ;_while
  ) ;_foreach
)

[Edit: fixed typo]
« Last Edit: October 21, 2005, 11:04:13 AM by Sdoman »

Sdoman

  • Guest
Re: Dynamic Blocks Visibility Setting
« Reply #2 on: October 21, 2005, 01:01:10 PM »
So in your case, you could do something like:

Code: [Select]
(PushDBProps
  DBlockEnameOrObject
  '(("Visibility" . "Show all lines and arcs for symbol."))
)