public CAD.AssembliesType ToCADXMLOutput(TestBenchModel.TestBenchBase tb, bool metalink = false)
{
CAD.AssembliesType outputAssembliesType = new CAD.AssembliesType();
outputAssembliesType.VersionInfo = "";
List<CAD.AssemblyType> asmlist = new List<CAD.AssemblyType>();
foreach (var item in assemblies.Values)
{
CAD.AssemblyType assembly = item.ToCADXMLOutput(tb);
asmlist.Add(assembly);
pointCoordinatesList.AddRange(item.PointCoordinatesList);
}
if (asmlist.Count > 1 && metalink)
{
Logger.Instance.AddLogMessage("There's more than one unconnected assembly in the model. Meta-Link may not work with this model.", Severity.Warning);
}
if (orphans.Any())
{
if (metalink)
{
CAD.AssemblyType topAssembly = asmlist.First();
List<CAD.CADComponentType> cadcomponentlist = topAssembly.CADComponent.CADComponent.ToList();
foreach (var orphan in orphans)
{
cadcomponentlist.Add(orphan.ToCADXMLOutput(tb.GetRepresentation(orphan)));
}
topAssembly.CADComponent.CADComponent = cadcomponentlist.ToArray();
}
else
{
List<CAD.CADComponentType> orphanlist = new List<CAD.CADComponentType>();
CAD.UnassembledComponentsType orphancomponentParent = new CAD.UnassembledComponentsType();
orphancomponentParent._id = UtilityHelpers.MakeUdmID();
foreach (var orphan in orphans)
{
orphanlist.Add(orphan.ToCADXMLOutput(tb.GetRepresentation(orphan)));
}
orphancomponentParent.CADComponent = orphanlist.ToArray();
outputAssembliesType.UnassembledComponents = orphancomponentParent;
}
}
outputAssembliesType.Assembly = asmlist.ToArray();
return outputAssembliesType;
}