[gme-users] Creating read-only attributes in a meta-model

Cinthya Lopez Cinthya_K_Lopez at raytheon.com
Thu Feb 1 16:18:24 CST 2018


That was it. The attribute value did not change so the parameter was null. I used a combination of #1 and #2 from your suggestions and I got it to do what I wanted. Thank you.

On a separate topic, my add-on pops up a form whenever the user changes the value of an attribute. In my case, the attribute I am interested in is an Enum. Right now, if the user wishes to display the form again without changing the value of the attribute, they have to click on the drop down arrow and select the same item. I would like to make this more intuitive for the user.

I have 2 ideas, but I am not sure if it would be possible to do in GME.


1)      Add a custom option in the GME context menu when they right-click on Atoms of a certain Kind

2)      Catch the double-click event on Atoms of a certain Kind

Is this possible? Do you have any suggestions on how I would be able to achieve something like this?

Cinthya

From: gme-users [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf Of Kevin Smyth
Sent: Thursday, February 1, 2018 10:16 AM
To: A list for GME users to share thoughts and discuss bugs and fixes. <gme-users at list.isis.vanderbilt.edu>
Subject: [External] Re: [gme-users] Creating read-only attributes in a meta-model

The third parameter should not be null if the type is OBJEVENT_ATTR and an attribute's value has changed. (It may be null if the attribute was set to the same value)

Kevin

On Thu, Feb 1, 2018 at 10:37 AM, Cinthya Lopez <Cinthya_K_Lopez at raytheon.com<mailto:Cinthya_K_Lopez at raytheon.com>> wrote:
Hi Kevin,

For #1, the third parameter that is passed into ObjectEvent is of type object. When I look at it in the debugger its value is null so casting it to object[] shows null as well. Am I missing something? I am working with GME 14.

I think this would be the information I need. If I can get the “attibuteName” to check which attribute is being modified, I can avoid falling into the case where my add-on code executes again when I modify my “read-only” attribute on the same object.

Thanks,
Cinthya

From: gme-users [mailto:gme-users-bounces at list.isis.vanderbilt.edu<mailto:gme-users-bounces at list.isis.vanderbilt.edu>] On Behalf Of Kevin Smyth
Sent: Thursday, February 1, 2018 8:58 AM
To: A list for GME users to share thoughts and discuss bugs and fixes. <gme-users at list.isis.vanderbilt.edu<mailto:gme-users at list.isis.vanderbilt.edu>>
Subject: [External] Re: [gme-users] Creating read-only attributes in a meta-model

Hi Cinthya,

It is not possible to disable editing of an attribute through the GUI. You can only hide attributes from the GUI.


I'd suggest:
1. Your add-on detects when the user modifies the attribute and sets the value back to the original value. When your addon receives OBJEVENT_ATTR in ObjectEvent, the third parameter contains the old value. For C#, cast it to object[], and you'll see {"ATTR:", "attributeName", "oldValue"}. Or
2. Look at OBJEVENT_ATTR and return E_MGA_CONSTRAINT_VIOLATION to signify the GME transaction should be aborted. In C#, you can do this like
int E_MGA_CONSTRAINT_VIOLATION = 0x87657fff;
throw new COMException("Constraint violation", E_MGA_CONSTRAINT_VIOLATION );
3. Create a hidden attribute in your meta-model. Your add-on sets this attribute and your original attribute to the same value. Then write a constraint that the attributes must be equal

Kevin

On Wed, Jan 31, 2018 at 5:22 PM, Cinthya Lopez <Cinthya_K_Lopez at raytheon.com<mailto:Cinthya_K_Lopez at raytheon.com>> wrote:
Hello,

I am looking for a way to create a read-only attribute in my meta-model. Basically I want to be able to populate the value of my attribute through my add-on and it will only be informational to the user when they create their model.

Does anyone know of a way to do this in GME?

Thank you,
Cinthya

_______________________________________________
gme-users mailing list
gme-users at list.isis.vanderbilt.edu<mailto:gme-users at list.isis.vanderbilt.edu>
http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/gme-users


_______________________________________________
gme-users mailing list
gme-users at list.isis.vanderbilt.edu<mailto:gme-users at list.isis.vanderbilt.edu>
http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/gme-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20180201/6c57ebba/attachment.html>


More information about the gme-users mailing list