private List <RevitLinkInstance> GetLinkInstances() { // verzamel de te exporteren links List <string> linkedProjects = ElementCollectionHelper.GetLinkedFiles(UIDoc.Application, false); List <RevitLinkInstance> instances = ElementCollectionHelper.GetAllProjectElements(UIDoc.Document) .OfType <RevitLinkInstance>() .Where(c => c.Name.ToLower().Contains(".rvt")) .ToList(); for (int i = instances.Count - 1; i >= 0; i--) { RevitLinkInstance inst = instances[i]; if (null == inst) { instances.RemoveAt(i); continue; } ElementId id = inst.GetTypeId(); ElementType etype = UIDoc.Document.GetElement(id) as ElementType; string instName = etype?.Name; if (string.IsNullOrEmpty(instName)) { instances.RemoveAt(i); continue; } if (!linkedProjects.Contains(instName, StringComparer.InvariantCultureIgnoreCase)) { instances.RemoveAt(i); } } if (instances.Count > 0) { StringBuilder builder = new StringBuilder(); builder.AppendLine("De following linked files are exported:"); foreach (RevitLinkInstance rli in instances) { builder.AppendLine(rli.Name); } Cmd.ShowResult(builder.ToString()); } return(instances); }
internal List <IFCExporterLinkedFileData> GetAllLinkedFiles() { // this assumes that GetLinkInstances returns both found and missing instances otherwise we must write a different method to find the missing ones List <RevitLinkInstance> instances = GetLinkInstances(); if (null == instances || instances.Count <= 0) { return(null); } XYZ viewDirection = UIDoc.Document.ActiveView.ViewDirection; XYZ rightDirection = UIDoc.Document.ActiveView.RightDirection; List <IFCExporterLinkedFileData> res = new List <IFCExporterLinkedFileData>(); foreach (RevitLinkInstance inst in instances) { // dit is een extension method? Document doc = inst.GetLinkDocument(UIDoc.Application); if (null == doc) { continue; } string path = doc.PathName; if (string.IsNullOrEmpty(path)) { continue; } IFCExporterLinkedFileData data = new IFCExporterLinkedFileData(path); res.Add(data); if (!data.Found) { continue; } List <BasePoint> points = ElementCollectionHelper.GetAllProjectElements(doc).OfType <BasePoint>().ToList(); if (points.Count <= 0) { continue; } Transform toWcs = inst.GetTotalTransform(); foreach (BasePoint point in points) { if (point.Category.Name != "Project Base Point") { continue; } XYZ pOrg; double hoek = toWcs.BasisX.AngleOnPlaneTo(rightDirection, viewDirection); if (Math.Abs(Math.Round(hoek, 2)) > 1e-6) { //voor hoeken gaan we de survey punten op elkaar leggen. Dat verrekenen we verder op pOrg = new XYZ(0, 0, 0); } else { //FamilyParametersHandler fph = new FamilyParametersHandler(point); //ParameterHandler ph = fph.Get(BuiltInParameter.BASEPOINT_EASTWEST_PARAM); //double x = ph?.AsRawDouble() ?? 0.0; Parameter ph = point.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM); double x = ph?.AsDouble() ?? 0.0; //ph = fph.Get(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM); //double y = ph?.AsRawDouble() ?? 0.0; ph = point.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM); double y = ph?.AsDouble() ?? 0.0; //ph = fph.Get(BuiltInParameter.BASEPOINT_ELEVATION_PARAM); //double z = ph?.AsRawDouble() ?? 0.0; ph = point.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM); double z = ph?.AsDouble() ?? 0.0; pOrg = new XYZ(x, y, z); } XYZ p = toWcs.OfPoint(pOrg); XYZ pos = p - 2 * pOrg; data.Angle = hoek; data.Position = pos; break; } } return(res); }