1) Yes, there is a way to do:
In order to adjust attribute values of the Sub-process to the attribute values of the referring "Sub-Process"-instance you can work with event handler. E.g. the event handler "ActivateModel" is always triggered if one model is activated. Therefore if you follow the model pointer of the "Sub-process"-instance this event is triggered as you activate the referenced model. The following AdoScript code ,which is also integrated in the attached library, is an example that reads the value of the "AdHoc" attribute of the "Sub-Process"-instance and edits the value of the referenced process.
1ON_EVENT "ActivateModelWindow" {
2#save the pregiven parameters
3 SET nModelId: (modelid)
4#get ALL incoming references and assign the result to variables
5 CC "Core" GET_INCOMING_INTERREFS modelid: (nModelId)
6 SET nRefCount: (refcount)
7 SET sRefText: (reftext)
8#if there is no incoming references than exit the algorithm
9 IF (nRefCount=0) {
10 EXIT
11 }
12
13# Parse the above outcome
14 LEO parse: (sRefText) get-int-value:nAttrId:"srcattrid"
15 LEO parse: (sRefText) get-int-value:nObjId:"srcobjid"
16 LEO parse: (sRefText) get-int-value:nRefModelId:"srcmodelid"
17# Get attribute id of the interref "Referenced subprocess"
18 CC "Core" GET_CLASS_ID classname:"Sub-Process"
19 SET nSubProcessClassId: (classid)
20 CC "Core" GET_ATTR_ID classid: (nSubProcessClassId) attrname:"Referenced subprocess"
21 SET nRSp_AttrId: (attrid)
22# If the referencing interref is of type "Referenced subprocess"
23# than read the value of the "Sub-process"-instance and wirte it into the referenced model
24 IF (nAttrId=nRSp_AttrId) {
25# if the model is not opened -> exit
26 CC "Modeling" IS_OPENED modelid: (nRefModelId)
27 SET nIsOpened: (isopened)
28 IF (nIsOpened = 0) {
29 EXIT
30 }
31 CC "Core" GET_ATTR_VAL objid: (nObjId) attrname:"AdHoc"
32 SET sAttrVal: (val)
33 CC "Core" GET_ATTR_ID classid: (nModelId) attrname:"AdHoc"
34 SET nM_AdHoc_AttrId: (attrid)
35 CC "Core" SET_ATTR_VAL objid: (nModelId) attrid: (nM_AdHoc_AttrId) val: (sAttrVal)
36 }
37}
2) Yes this is a good approach.
The question is, if you want to adjust attribute values of two different instances (model, object); "When do you wnat to trigger it?"
- If it should be adjusted after the model is activated than .... see above.
- If you want the adjustment dynamically when the "Sub-Process"-instance-attribute is changed than you can use the events "SetAttributeValue" or "AfterEditAttributeValue". The implementation would be similar as above.
You can find the online AdoScript documentation, where you can find all the events and the Adoscript commands at the following link:
https://www.adoxx.org/live/adoscript-documentation