Hi,
this is my attribute rule. It seems to work fine, but i can not set the right terminal. I tried different things but I get always errors.
Expression
if ($feature.assetgroup == 1001) {
var update_class = 'ElectricDevice'
var filterDevice = "ASSETGROUP = 854 And DIRECTION = 'Voeding OV'"
var boundaries = FeatureSetByName($datastore, "FLUVIUS_109_DESIGN2.UTARC.StructureBoundary", ["globalid"], true);
if(isempty(boundaries)){
return;
//{"errorMessage": "Error 1"};
};
var intersectBoundaries = Intersects(boundaries, $feature);
if(isempty(intersectBoundaries)){
return;
//{"errorMessage": "Error 2"};
};
var structureBoundary = First(intersectBoundaries);
if(isempty(structureBoundary)){
return;
//{"errorMessage": "Error 3"};
}
var AllDevices = FeatureSetByName($datastore, "FLUVIUS_109_DESIGN2.UTARC.ElectricDevice", ["assetgroup", "globalid"], true);
if(isempty(AllDevices)){
return;
//{"errorMessage": "Error 4"};
}
var XYDevice = Filter(AllDevices, filterDevice)
if(isempty(XYDevice)){
return;
//{"errorMessage": "Error 5"};
};
var intersectDevice = Intersects(XYDevice, structureBoundary);
if(isempty(intersectBoundaries)){
return;
//{"errorMessage": "Error 6"};
};
var DeviceGeo = First(intersectDevice)
if(isempty(DeviceGeo)){
return;
//{"errorMessage": "Error 7"};
}
return {
"edit":
[
{"className": update_class,
"updates":[{"globalid": DeviceGeo.globalid,
"FROMTERMINALID": 13,
"associationType":"connected"}]}
]
}
}
I have tried:
-"fromTerminal": "13"
- "fromTerminal": 13
- "FROMTERMINALID": 13
I get a association without error but, I have topology errors and the terminal is set FromTerminalID 1 ToTerminalID 1
The association rule looks like this:
Thank you for your help!
Solved! Go to Solution.
Think of the dictionary you are authoring as creating an association from $feature to whatever feature you specified in the update_class. Specifying FROMTERMINAL means here you are trying to create an association from the $feature so that terminal should exist on that feature.
If the terminal you are connecting to is at the device then use ToTerminal. and you can safely use the string name
A blog detailing this can be found here.
As Mike said, you can also use ^UN_Association if you want more control. (create associations between two assets other than $feature.
Hope that helps
The terminal id needs to be set on the line class, not the device. If you are trying to create an association, you need to use ^UN_Association
Think of the dictionary you are authoring as creating an association from $feature to whatever feature you specified in the update_class. Specifying FROMTERMINAL means here you are trying to create an association from the $feature so that terminal should exist on that feature.
If the terminal you are connecting to is at the device then use ToTerminal. and you can safely use the string name
A blog detailing this can be found here.
As Mike said, you can also use ^UN_Association if you want more control. (create associations between two assets other than $feature.
Hope that helps
It worked with that retun statement:
return {
"edit":
[
{"className": UpdateClass,
"updates":[{
"globalid": DeviceGeo.globalid,
"fromTerminal": fromTerm,
"toTerminal": toTerm,
"associationType":"connected"}]
}
]
}