This code for Element IDs works for me, not sure if it will work for you:
private string getItem1ElementID(ComApi.InwOpState10 oState, ComApi.InwOclTestResult clashResult) {
List < string > element_1_IDs = new List < string > ();
List < string > element_1_junk = new List < string > ();
string[] properties = {
"LcOaNat64AttributeValue",
"LcRevitPropertyElementName",
"LcRevitPropertyElementType",
"LcRevitPropertyElementFamily",
"LcRevitPropertyElementCategory",
"LcOaNat64AttributeValue"
};
foreach(ComApi.InwOaNode node in clashResult.Path1.Nodes()) {
//System.Diagnostics.Debug.WriteLine("****************");
foreach(ComApi.InwOaAttribute nodeAttr in node.Attributes()) {
ComApi.InwOaPropertyVec pVec = oState.GetAttributeProperties(nodeAttr);
foreach(ComApi.InwOaProperty nodeProp in pVec.Properties()) {
String string_val = nodeProp.value as String;
if (properties.Any(s = >s.Equals(nodeProp.name))) {
//System.Diagnostics.Debug.WriteLine(nodeProp.name + ": " + string_val);
element_1_junk.Add(string_val);
}
}
}
}
int temp;
element_1_IDs = element_1_junk.Where(x = >int.TryParse(x, out temp)).ToList();
if (element_1_IDs.Count > 1) {
return element_1_IDs[1];
} else {
return element_1_IDs[0];
}
}
private string getItem2ElementID(ComApi.InwOpState10 oState, ComApi.InwOclTestResult clashResult) {
List < string > element_2_IDs = new List < string > ();
List < string > element_2_junk = new List < string > ();
string[] properties = {
"LcOaNat64AttributeValue",
"LcRevitPropertyElementName",
"LcRevitPropertyElementType",
"LcRevitPropertyElementFamily",
"LcRevitPropertyElementCategory",
"LcOaNat64AttributeValue"
};
foreach(ComApi.InwOaNode node in clashResult.Path2.Nodes()) {
//System.Diagnostics.Debug.WriteLine("****************");
foreach(ComApi.InwOaAttribute nodeAttr in node.Attributes()) {
ComApi.InwOaPropertyVec pVec = oState.GetAttributeProperties(nodeAttr);
foreach(ComApi.InwOaProperty nodeProp in pVec.Properties()) {
String string_val = nodeProp.value as String;
if (properties.Any(s = >s.Equals(nodeProp.name))) {
//System.Diagnostics.Debug.WriteLine(nodeProp.name + ": " + string_val);
element_2_junk.Add(string_val);
}
}
}
}
int temp;
element_2_IDs = element_2_junk.Where(x = >int.TryParse(x, out temp)).ToList();
if (element_2_IDs.Count > 1) {
return element_2_IDs[1];
} else {
return element_2_IDs[0];
}
}
As for the Types and Names, you might as well extract them from the Item Paths?
// Item 1 Path
private string getItem1Path(ComApi.InwOclTestResult clashResult) {
string Item1_Path = "";
foreach(ComApi.InwOaNode node in clashResult.Path1.Nodes()) {
string username_node = node.UserName;
if (username_node.Length == 0) {
username_node = node.ClassUserName + "_";
}
Item1_Path = Item1_Path + "->" + username_node;
}
return Item1_Path;
}
// Item 2 Path
private string getItem2Path(ComApi.InwOclTestResult clashResult) {
string Item2_Path = "";
foreach(ComApi.InwOaNode node in clashResult.Path2.Nodes()) {
string username_node = node.UserName;
if (username_node.Length == 0) {
username_node = node.ClassUserName + "_";
}
Item2_Path = Item2_Path + "->" + username_node;
}
return Item2_Path;
}