- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I need to write the Id parameter of the collision element from Revit and the GUID of the collision to an XML file using the Navisworks COM. Could you please guide me on how to achieve this correctly?
Thank you!
private static void ExportResultsToXml(NavisworksIntegratedAPI19.InwClashTestsColl clashResults, string filePath)
{
using (var writer = new StreamWriter(filePath))
{
writer.WriteLine("<ClashResults>");
foreach (NavisworksIntegratedAPI19.InwOclClashTest2 clashTest in clashResults)
{
foreach (NavisworksIntegratedAPI19.InwOclTestResult2 clashResult in clashTest.results())
{
writer.WriteLine(" <ClashResult>");
writer.WriteLine($" <Name>{clashResult.name}</Name>");
writer.WriteLine(" <Element1Path>");
NavisworksIntegratedAPI19.InwOaPath2 Path1 = (InwOaPath2)clashResult.Path1;
GetAttributeValue(Path1, "LcRevitPropertyElementId"); //here is a method to find the parameter values
WritePathNodesToXml(writer, Path1);
writer.WriteLine(" </Element1Path>");
// Записываем все узлы для Element2Path
writer.WriteLine(" <Element2Path>");
NavisworksIntegratedAPI19.InwOaPath2 Path2 = (InwOaPath2)clashResult.Path2;
WritePathNodesToXml(writer, Path1);
writer.WriteLine(" </Element2Path>");
string bound = ExtractBoundFromComObject(clashResult.Bound);
writer.WriteLine($" <Bound>{bound}</Bound>");
writer.WriteLine($" <Status>{clashResult.status}</Status>");
writer.WriteLine($" <Distance>{clashResult.distance}</Distance>");
writer.WriteLine(" </ClashResult>");
}
}
writer.WriteLine("</ClashResults>");
}
}
private static string GetAttributeValue(NavisworksIntegratedAPI19.InwOaPath2 inwOaPath2, string attributeName)
{
try
{
var attribute = inwOaPath2.FindAttribute(attributeName, true);
if (attribute != null)
{
return attribute.UserName; // Предполагается, что значение атрибута можно преобразовать в строку
}
}
catch
{
return " NA";
}
return "NA";
}
Solved! Go to Solution.