Book a Demo

Author Topic: How to change the instance state for a element using vbscript  (Read 3348 times)

rogerjohansson

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
How to change the instance state for a element using vbscript
« on: August 18, 2023, 09:44:17 pm »
Hello!
Im trying to use the automation interface (vbscript) to read and change the object state value for an element.
Its possible to set this value in the user interface via "Rightclick - Advanced - Set Object State..." or CTRL+SHIFT+S shortcut, this brings up the "Set Instance State" dialog. But I struggle to find a way to read or set the same value using vbscript.
In exports I can see that there is column in the t_objects table called ”StateFlags” where this value appears to be stored…

Can I read and/or set this value using automation?

/Roger

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to change the instance state for a element using vbscript
« Reply #1 on: August 18, 2023, 10:33:26 pm »
It's in t_object.runstate (or EAElement.runstate) where you find something like
Code: [Select]
@VAR;Variable=s1;Value=state1;Op==;@ENDVAR;@VAR;Variable=...
q.

rogerjohansson

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: How to change the instance state for a element using vbscript
« Reply #2 on: August 18, 2023, 11:22:26 pm »
It's in t_object.runstate (or EAElement.runstate) where you find something like
Code: [Select]
@VAR;Variable=s1;Value=state1;Op==;@ENDVAR;@VAR;Variable=...
q.
Are you sure? isnt Runstate separate from Object instance state? Two different attributes.
When I use EAElement.runstate it returns the runstate not "Stateflags".
This is an exemple element in XML:
<UML:ClassifierRole name="Test" xmi.id="EAID_AA4F78A0_7A0B_481e_8ED3_A4AF2F924EF7" visibility="public" base="EAID_11111111_5487_4080_A7F4_41526CB0AA00">
<UML:ModelElement.stereotype>
<UML:Stereotype name="AValueObject"/>
</UML:ModelElement.stereotype>
<UML:ModelElement.taggedValue>
<UML:TaggedValue tag="isAbstract" value="false"/>
<UML:TaggedValue tag="isSpecification" value="false"/>
<UML:TaggedValue tag="ea_stype" value="Object"/>
<UML:TaggedValue tag="ea_ntype" value="0"/>
<UML:TaggedValue tag="version" value="0.1"/>
<UML:TaggedValue tag="isActive" value="false"/>
<UML:TaggedValue tag="package" value="EAPK_6E6B9B29_21FC_4364_A5C7_32D799458250"/>
<UML:TaggedValue tag="date_created" value="2023-08-15 13:32:16"/>
<UML:TaggedValue tag="date_modified" value="2023-08-15 14:41:05"/>
<UML:TaggedValue tag="gentype" value="Java"/>
<UML:TaggedValue tag="tagged" value="0"/>
<UML:TaggedValue tag="package_name" value="Nuläge"/>
<UML:TaggedValue tag="phase" value="1.0"/>
<UML:TaggedValue tag="author" value="rojo05"/>
<UML:TaggedValue tag="complexity" value="1"/>
<UML:TaggedValue tag="object_style" value="MDoc=1;"/>
<UML:TaggedValue tag="status" value="Proposed"/>
<UML:TaggedValue tag="stereotype" value="AValueObject"/>
<UML:TaggedValue tag="runstate" value="@VAR;Variable=ThsIsRunnerstate;Op==;@ENDVAR;"/>
<UML:TaggedValue tag="tpos" value="0"/>
<UML:TaggedValue tag="ea_localid" value="115"/>
<UML:TaggedValue tag="ea_eleType" value="element"/>
<UML:TaggedValue tag="stateflags" value="ThisIsInstanceState"/>
<UML:TaggedValue tag="style" value="BackColor=-1;BorderColor=-1;BorderWidth=1;FontColor=-1;VSwimLanes=1;HSwimLanes=1;BorderStyle=0;"/>
<UML:TaggedValue tag="$ea_xref_property" value="$XREFPROP=$XID={F0DE9AFC-6769-43b3-92AA-725A85DC7929}$XID;$NAM=Stereotypes$NAM;$TYP=element property$TYP;$VIS=Public$VIS;$PAR=0$PAR;$DES=@STEREO;Name=AValueObject;FQName=Astrakan::AValueObject;@ENDSTEREO;$DES;$CLT={AA4F78A0-7A0B-481e-8ED3-A4AF2F924EF7}$CLT;$SUP=<none>$SUP;$ENDXREF;$XREFPROP=$XID={276F3CFC-917E-4043-B08F-B9524DF94E10}$XID;$NAM=CustomProperties$NAM;$TYP=element property$TYP;$VIS=Public$VIS;$PAR=0$PAR;$DES=@PROP=@NAME=_defaultDiagramType@ENDNAME;@TYPE=string@ENDTYPE;@VALU=Astrakan Method::ProcessModel@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;$DES;$CLT={AA4F78A0-7A0B-481e-8ED3-A4AF2F924EF7}$CLT;$SUP=<none>$SUP;$ENDXREF;"/>
<UML:TaggedValue tag="modeldocument"/>
</UML:ModelElement.taggedValue>
</UML:ClassifierRole>

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to change the instance state for a element using vbscript
« Reply #3 on: August 18, 2023, 11:42:06 pm »
Sorry, wrote this offline. The value is stored in t_object.stateflags. I currently have trouble retrieving that from EAElement. Will update this later...

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to change the instance state for a element using vbscript
« Reply #4 on: August 18, 2023, 11:56:08 pm »
Strange. Actually (I think) I've never used StateFlags. But EA won't give me that though the documentation tells it's there. Well, I usually just take the shortcut and issue a query to return the value (from t_object.stateflags). Vice versa I issue a Repository.Execute in order to set the desired value.

q.

P.S. Oh, the stateflags is only in EAMethods, not in EAElement. EA... So the query/execute is the only solution.
« Last Edit: August 18, 2023, 11:58:06 pm by qwerty »