Jump to content

Ribbon Diesel functions


Aftertouch

Recommended Posts

Hey all,

 

I got some issues with DIESEL function in the ribbon again...

 

I want a ribbon button to highlight when the "UserI3" is 2.

 

i use this code:

$(if,$(and,2,$(getvar,UserI3)),!.)

 

But the button now highlights when UserI3 is 2 or 3.

Why is this happening?

 

Also...

How would the code look like if i want the button to hightlight when the value if 1 or 4?

Link to comment
Share on other sites

First it should highlight when UserI3 is 2 or 3 since 1+2=3, see AutoCAD help for logand (AutoLISP) which is same as 'and' function in DIESEL.

 

Diesel functions work great in Shortcut Menus, but not so great in the Ribbon. The Ribbon display doesn't regen every time you change a setting. It may work when you click it in the Ribbon, but will not change if you change the value on the command line or in a lisp routine. The Shortcut Menus are generated each time they are brought up so they are always up to date.

 

Since about the 2006 version I've used

$(if,$(and,16384,$(getvar,osmode)),,$(if,$(and,1,$(getvar,osmode)),!.))&Endpoint

as the Display Name for Endpoint in Object Snap Cursor Menu. It's only highlighted if both Osnap is turned on and Endpoint snap is set. I have all my snaps set up this way.

 

You could create another flyout from that menu or create your own. Don't know yet what you're really trying to do, but maybe a dialog box for the routine with the values loaded from USERI values is what you're looking for.

Link to comment
Share on other sites

Hey tombu,

 

I have to say your wrong.

A ribbon button DOES update everytime i change a variable with lisp/command line.

If i use: (setvar "UserI3" 1) then (setvar "UserI3" 2) then (setvar "UserI3" 3) etc.etc... it updates each time...

 

It just doesnt update the way i want it. :-)

Link to comment
Share on other sites

Hey tombu,

 

I have to say your wrong.

A ribbon button DOES update everytime i change a variable with lisp/command line.

If i use: (setvar "UserI3" 1) then (setvar "UserI3" 2) then (setvar "UserI3" 3) etc.etc... it updates each time...

 

It just doesnt update the way i want it. :-)

 

You're right it does update every time now, believe that's a new feature in 2017. Cool, I'll have to add some more to my Ribbon.

 

To toggle the bitcode 1 on and off in UserI3 I'd use

^P'setvar;UserI3;$M=$(if,$(and,1,$(getvar,UserI3)),$(-,$(getvar,UserI3),1),$(+,$(getvar,UserI3),1)) ^P 

using

$(if,$(and,2,$(getvar,UserI3)),!.)

as the Display Name.

 

To toggle the bitcode 2 on and off in UserI3 I'd use

^P'setvar;UserI3;$M=$(if,$(and,2,$(getvar,UserI3)),$(-,$(getvar,UserI3),2),$(+,$(getvar,UserI3),2)) ^P 

using your

$(if,$(and,2,$(getvar,UserI3)),!.)

as the Display Name.

 

To toggle the bitcode 4 on and off in UserI3 I'd use

^P'setvar;UserI3;$M=$(if,$(and,4,$(getvar,UserI3)),$(-,$(getvar,UserI3),4),$(+,$(getvar,UserI3),4)) ^P 

using

$(if,$(and,2,$(getvar,UserI3)),!.)

as the Display Name.

 

Did you check out the help link I posted above?

Do you understand why the ribbon button highlights when the "UserI3" is 2, 3 (2+1), 6 (2+4), 7 (2+1+4), etc. It will not be highlighted when it's set to 1, 4, 5 (4+1), etc without the 2 bitcode added in.

Link to comment
Share on other sites

Hey Tombu,

Glad to hear your gonna use this feature too!

 

Also thanks for your codes again... its close to what i need, but not exactly.

Ill try to explain what im looking for...

 

I have a command that uses UserI3 for some on.off filtering. that same command also changes the value of the UserI3.

Variable UserI3 can either be: 1 2 3 or 4. This is not a bit-number or anything, its just a number that i read in the LISP and depending on that number it does something...

 

I want to highlight the one single button using 'Displayname' if the value of UserI3 is either 2 or 3.

 

In lisp i would use something like:

 

(if (or(= (getvar "UserI3") 2)(= (getvar "UserI3") 3))([color="red"]<highlight>[/color])([color="red"]<dont highlight>[/color]))

But i cannot get this translated to a DIESEL. :cry:

Link to comment
Share on other sites

Just feel the need to ask why you decided to limit USERI3 by not using bitcodes?

$(if,$(or,$(=,1,$(getvar,UserI3)),$(=,2,$(getvar,UserI3))),!.)

will do what you're looking for.

Link to comment
Share on other sites

Hey tombu thanks for the reply again. I was close, but i keep messing up with the $ and , symbols...

 

Well... the reason i dont use them as bitcodes is because i have no idea how to properly use my variables as bitcodes in my case... each number of UserS3 is linked to a set of variables. With the highlighted buttons i want to show wich propery is set on or off wich a specific set.

I use the ribbon like some sort of visual check method.

Instead of usong the VariableControl or some dialog thingy... all numbers are sort of random so i think it cannot be bit-coded. Also i must admit that i dont have any idea how to set up a bitcoded code... :-)

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