Hello all!
I create variant of EPC-model. This EPC-model (variant) (A) contain objects, they types are functions (interface).
Then I have to delete this objects (interfaces) and copy on they places objects (functions) from source EPC-model (B).
Also I need to create relationships of this object, as it was in EPC-model (A) before deleting objects (interfaces).
Tell me please how can I copy this objects (interfaces) from source EPC-model (B) to variant EPC-model (A) and create relationships of this objects using script?
Hi,
well, if you use the merge component to create the variant model, I think it is possible to set the objects that are to be used as occurrences instead of variants...
Report class Merge - Method createVariant
createVariant ( ArisObject[] p_sourceElements, Group p_targetGroup, Map < ArisObject , ArisObject > p_itemsForOccCopy, GroupScriptInfo p_groupInfo )
BR Robert
Could you tell us a bit about how your objects are associated? Like when you pick a process interface from your variant A, how do you want to identify the function from the source B, that should appear in place of the interface, in variant A?
One thing to note already: from what I can read (delete occurrence, place occurrence, recreate connection), you would have an easier time treating the existing occurrence as an “hull”, and using
ObjOcc.ReplaceObjDef(newObjDef)
and maybe
ObjOcc.setSymbol(Constants.ST_FUNC)
(the second method only in case you actually want to place standard functions there - you weren't very clear about if you mean "object type Function | symbol type Function" or "object type Function | symbol type Interface" to appear in place of the original interfaces).
This allows you to just swap out the underlying object definition (occurrence – object definition re-mapping). Saves you from having to recreate connections. The only thing missing now is how you would identify newObjectDef, which is why I asked about their association.
Hello Kay and Robert, thanks for your answers!
Sorry, I make a mistake, when explain my problem. Now I try to correct this.
1. Create a variant of the VAD-model (V1) from the original VAD-model (V2)
2. In the original VAD-model (V2), some functions have detail (EPC-model). I need to go through all these functions and create variants of their EPC models.
3. I take the first such function from the VAD-model (V2), open its EPC-mode
4. I create its variant, moreover, I create objects of the function, rule, event again, and the other objects I make as "copies of instances"
5. Among the objects of the function type are interfaces, also "Copies of instances"
6. On the variant of the EPC model (A), select the function-interface, and copy its name
7. On the original VAD-model (V2) by this name I find the desired function and copy it
8. On the EPC-model variant (A), I delete the object-interface function with this name and paste the function from the original VAD-model (V2) in its place (after this inserted object takes the form of an interface), restore the relationships as in the original EPC-model (B).
9. So to do with all objects with the functions-interfaces of the EPC-model variant (A)
10. When all changes on the EPC model version (A) are made, we save it and connect it as a detail to the desired function of the variant VAD model (V1)
It would be great if it were possible to simply change the definition of the function-interface object to the definition of the original function-object from the VAD model (V2), it would not be necessary to re-create the connection.
Any help towards achieving that would be greatly appreciated.
Thank you for your help!
I can realized this script with your answers.
1. Get objects from VAD model:
function getVADData( aModels ){
var SummOfVad = 0;
var aFuncObjVAD;
for (var i = 0; i < aModels.length; i++) {
var oModel = aModels[i];
if(oModel.TypeNum() == 12){
if (SummOfVad > 0){
return false;
}
SummOfVad++;
aFuncObjVAD = oModel.ObjOccListFilter(Constants.OT_FUNC);
}
}
if(SummOfVad == 0){
return;
}
return aFuncObjVAD;
}
2. This function get from EPC-models objects, which types is function and TypeNumber of this icon is 94,
and ID is started STD or it length < 4 (found internal system interfaces)
function getEPCData( aModels ){
var SummOfEpc = 0;
var aObjectVI = new Array(); // internal system interfaces
for (var i = 0; i < aModels.length; i++) {
var oModel = aModels[i]; // Current model
if(oModel.TypeNum() == 13){ // if type of the model is EPC - go on
SummOfEpc++; // Count EPC-models
var aFuncObj = oModel.ObjOccListFilter(Constants.OT_FUNC);
for (var j = 0; j < aFuncObj.length; j++) {
var id = getId(aFuncObj[j].ObjDef());
id = id.toString();
if((aFuncObj[j].SymbolNum() == 94)&&(id != "" && (id.length() < 4 || id.substring(0, 4) == "STD."))){
aObjectVI.push(aFuncObj[j]);
}
}
}
}
if(SummOfEpc == 0){
return;
}
return aObjectVI;
}
3. Replace
function replaceVIDefOnEPC( objectVI, aFuncObjVAD ){
for (var i = 0; i < objectVI.length; i++){
for (var j = 0; j < aFuncObjVAD.length; j++){
if(getName(objectVI[i].ObjDef()) == getName(aFuncObjVAD[j].ObjDef())){
objectVI[i].ReplaceObjDef(aFuncObjVAD[j].ObjDef());
break;
}
}
}
}
4. main()
function main(){
var aModels = ArisData.getSelectedModels(); // All selected models
var aFuncVAD = getVADData( aModels ); // Array of VAD objects-functions
var aFuncEPC = getEPCData( aModels ); // Array of EPC's objects-interfaces
replaceVIDefOnEPC( aFuncEPC , aFuncVAD ); // Replace objects in EPC by objects from VAD
}