Author Topic: Visibility States: So here's the situation...  (Read 2507 times)

0 Members and 1 Guest are viewing this topic.

nivuahc

  • Guest
Visibility States: So here's the situation...
« on: November 21, 2005, 09:59:17 AM »
We've just updated to AutoCAD 2006 from 2002 and I'm going through setting up our menus/customizations/etc

I've decided to take advantage of the dynamic blocks for things like our receptacles and what-not (we're an electrical firm) and was pleased to see that Autodesk put an option on the tool palettes that allowed me to pre-set the visibility state of a dynamic block when a user chooses it. That's great. Really handy. But let's talk about toolbars for a second...

I'd like the same functionality in toolbars, it's going to be a bit of a struggle to get everyone here used to using palettes in the first place and it seems, to me at least, that it's a bit easier to control something like toolbars using the enterprise cui than it is to control tool palettes. So how do I set the visibility state of a dynamic block when a user selects it off of a toolbar?

I've been through the help files, the customization guide, and quite a bunch of other things and I can't imagine this is the first time this has been asked. In fact, I asked it a loooooong time ago, before 2006 hit the retail shelves. ;)

Anyone?

whdjr

  • Guest
Re: Visibility States: So here's the situation...
« Reply #1 on: November 21, 2005, 10:54:22 AM »
Chuck,

What is the macro or command you are using in the toolbar button to insert your block?

I know if the tool palettes once you get your block in the palette you just right-click it and change the properties for that tool only.

Im not sure about toolbars.  Send me your sequence and Ill test it out here.

Will

nivuahc

  • Guest
Re: Visibility States: So here's the situation...
« Reply #2 on: November 21, 2005, 11:02:59 AM »
Code: [Select]
-insert \\location\\of\\block;
:D

Lemme 'splain...

I have, for example, a dynamic block for a receptacle. In that block I have 2 options, a duplex receptacle and a quadruplex receptacle. I have the tool palette setup to have each one visible (i.e. the user sees both receptacles in the palette) and I achieve that by simply copying the dynamic block thinger from the palette and changing the visibility state in the properties of that button.

I want to have a toolbar that has a duplex receptacle and a quadruplex receptacle. I want to use the dynamic block I have just setup. I want the user to be able to select the duplex receptacle and it come in as a duplex receptacle (the default visibility state, so that's not a problem). But, this is where it gets tricky... I want the user to be able to select the quadruplex receptacle (same dynamic block as the duplex, mind you) and have it come in as a quadruplex receptacle. I want to be able to change the visibility state of a block on insertion from the toolbar.

Simple enough with palettes, but not so simple with a toolbar (at least, not so far as I have found)

Murphy

  • Guest
Re: Visibility States: So here's the situation...
« Reply #3 on: November 21, 2005, 11:19:03 AM »
Don't know if this will help but, it's worth a shot.
http://discussion.autodesk.com/thread.jspa?messageID=4841498

nivuahc

  • Guest
Re: Visibility States: So here's the situation...
« Reply #4 on: November 21, 2005, 11:41:50 AM »
Thanks Murphy,

I actually worked through discovering what the different visibility states are in this thread a while back (with mucho help from Kerry I might add) but the situation is changing the visibility state. Okay, so I've got 50 different visibility states in a dynamic block. Swell. I want it to insert as visibility state 3. From a toolbar. Or the command line. Or something other than a palette.

Sdoman

  • Guest

whdjr

  • Guest
Re: Visibility States: So here's the situation...
« Reply #6 on: November 21, 2005, 11:53:44 AM »
Chuck,

Try this and see if works for you:
Code: [Select]
(defun c:vis (ent)
  (foreach prop (vlax-safearray->list
  (vlax-variant-value
    (vla-getdynamicblockproperties
      (vlax-ename->vla-object ent)
    )
  )
)
    (if (eq (vla-get-propertyname prop) "VISIBILITY") ;this string should match the name
            ;of your visibility property.
      (vla-put-value (vlax-make-variant "put name here")) ;this string should match the value
        ;of the string you want to show.
    )
  )
)

Load this and then put a call to it in you button.  Make sure you change the appropriate strings as indicated in the code.

Let me know if it works or not.

Maybe something like this:
Code: [Select]
-insert \\location\\of\\block;;;;(c:vis (entlast))
The only issue I see is whether a valid insert was made before calling the 'vis' code.

ELOQUINTET

  • Guest
Re: Visibility States: So here's the situation...
« Reply #7 on: November 21, 2005, 11:54:54 AM »
isn't the first state in the list always the default state upon insertion?

whdjr

  • Guest
Re: Visibility States: So here's the situation...
« Reply #8 on: November 21, 2005, 11:55:31 AM »
If that works Chuck then you might want to include the strings in the original call to make the function more universal.

nivuahc

  • Guest
Re: Visibility States: So here's the situation...
« Reply #9 on: November 21, 2005, 12:12:50 PM »
If that works Chuck then you might want to include the strings in the original call to make the function more universal.

Code: [Select]
error: bad argument type: lentityp #<VLA-OBJECT IAcadBlockReference2 01144c64>
 :-(

See if this helps:
http://www.theswamp.org/forum/index.php?topic=7340.msg91197#msg91197
 

Tried it on a lighting fixture

Code: [Select]
(PushDBProps (vlax-ename->vla-object (car (entsel))) '(("Visibility" . "2x4 Emergency")))
worked flawlessly

thanks :)

Now to Frankenstein this bit o' work a bit, make it a little user friendly for my purposes ;)

Sdoman

  • Guest
Re: Visibility States: So here's the situation...
« Reply #10 on: November 21, 2005, 05:44:59 PM »
 
Quote
worked flawlessly

Coolness!  Have fun Dr.Frankenstein.  8-)
 
 

nivuahc

  • Guest
Re: Visibility States: So here's the situation...
« Reply #11 on: November 22, 2005, 08:11:49 AM »
All I did was add this to my MNL

Code: [Select]
(defun SetVisState (state /) (PushDBProps (vlax-ename->vla-object (entlast)) (list (cons "Visibility" state))))
so, now, when I insert a dynamic block via a toolbar I just put one of these on the end

Code: [Select]
(SetVisState "2x2 Emergency")
and the world is a happier place ;)

Thanks! :)

Sdoman

  • Guest
Re: Visibility States: So here's the situation...
« Reply #12 on: November 22, 2005, 08:28:38 AM »
I just realized that you can simplify a little more by eliminating 'vlax-ename->vla-object' from the argument list, since this conversion is handled in PushDBProp: 

Code: [Select]
(defun SetVisState (state /) (PushDBProps (entlast) (list (cons "Visibility" state))))
Saves some screen space!  :-)


nivuahc

  • Guest
Re: Visibility States: So here's the situation...
« Reply #13 on: November 22, 2005, 09:07:19 AM »
I just realized that you can simplify a little more by eliminating 'vlax-ename->vla-object' from the argument list, since this conversion is handled in PushDBProp:

Code: [Select]
(defun SetVisState (state /) (PushDBProps (entlast) (list (cons "Visibility" state))))
Saves some screen space! :-)

I actually considered doing that, because I'm drawn to the method by habit. But I'm trying to get into the habit of seeing things in a VLA kinda way so I left it that way on porpoise :D

I'm actually gonna setup an entire popin-popout sequence to simplify things a bit more as it's not exactly a simple task to cut-n-paste one symbol's code into the next like I've been doing for the past 15 years   :x

(thank you Autodesk) :realmad: