Esempio n. 1
0
        void GetKeynotesAssemblyCodesSharedParamAndLinks(IList <Document> targetDocumentsList, IList <string> targetList, Document activeDoc)
        {
            foreach (Document currentDoc in targetDocumentsList)
            {
                ModelPath        targetLocation = ModelPathUtils.ConvertUserVisiblePathToModelPath(currentDoc.PathName);
                TransmissionData targetData     = TransmissionData.ReadTransmissionData(targetLocation);

                if (targetData != null)
                {
                    ICollection <ElementId> externalReferences = targetData.GetAllExternalFileReferenceIds();

                    foreach (ElementId currentFileId in externalReferences)
                    {
                        if (currentFileId != ElementId.InvalidElementId)
                        {
                            ExternalFileReference extRef = targetData.GetLastSavedReferenceData(currentFileId);
                            //TODO CORRECT PROBLEMATIC IF STATEMENT HERE!!!!!!!!!!!!!!!!!!
                            if (extRef.GetLinkedFileStatus() != LinkedFileStatus.Invalid)
                            {
                                ModelPath currenFileLink = extRef.GetAbsolutePath();
                                if (!currenFileLink.Empty)
                                {
                                    string currentFileLinkString = ModelPathUtils.ConvertModelPathToUserVisiblePath(currenFileLink);
                                    CheckStringAValidLinkPathCorrectItAndAddToList(currentFileLinkString, targetList, activeDoc);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private static List <RevitLink> GetLinks(string location)
        {
            List <RevitLink> links = new List <RevitLink>();

            try
            {
                ModelPath path = ModelPathUtils.ConvertUserVisiblePathToModelPath(location);

                TransmissionData        transData          = TransmissionData.ReadTransmissionData(path);
                ICollection <ElementId> externalReferences = default(ICollection <ElementId>);

                if (transData != null)
                {
                    // collect all (immediate) external references in the model

                    externalReferences = transData.GetAllExternalFileReferenceIds();

                    if (externalReferences.Count > 0)
                    {
                        foreach (ElementId refId in externalReferences)
                        {
                            ExternalFileReference extRef = transData.GetLastSavedReferenceData(refId);
                            if (extRef.IsValidObject)
                            {
                                if (extRef.ExternalFileReferenceType == ExternalFileReferenceType.CADLink | extRef.ExternalFileReferenceType == ExternalFileReferenceType.DWFMarkup | extRef.ExternalFileReferenceType == ExternalFileReferenceType.RevitLink)
                                {
                                    RevitLink rl = new RevitLink();
                                    rl.LinkType     = extRef.ExternalFileReferenceType.ToString();
                                    rl.AbsolutePath = ModelPathUtils.ConvertModelPathToUserVisiblePath(extRef.GetAbsolutePath());
                                    rl.Path         = ModelPathUtils.ConvertModelPathToUserVisiblePath(extRef.GetPath());
                                    links.Add(rl);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            return(links);
        }
Esempio n. 3
0
        /// <summary>
        ///    Geef alle gelinkte files
        /// </summary>
        /// <param name="app"></param>
        /// <param name="addProj"></param>
        /// <returns></returns>
        public static List <string> GetLinkedFiles(UIApplication app, bool addProj)
        {
            List <string>            linkedProjects = new List <string>();
            List <RevitLinkInstance> instantiekes   =
                GetAllProjectElements(app.ActiveUIDocument.Document)
                .OfType <RevitLinkInstance>()
                .Where(c => c.Name.ToLower().Contains(".rvt"))
                .ToList();

            foreach (RevitLinkInstance rli in instantiekes)
            {
                if (rli.GetLinkDocument() == null)
                {
                    continue;
                }
                string linknaam = rli.GetLinkDocument().PathName;
                if (!linkedProjects.Contains(linknaam))
                {
                    linkedProjects.Add(linknaam);
                }
            }
            if (linkedProjects.Count == 0)
            {
                // er zijn waarschijnlijk worksets gebruikt
                ModelPath        mdlPath   = ModelPathUtils.ConvertUserVisiblePathToModelPath(app.ActiveUIDocument.Document.PathName);
                TransmissionData transData = TransmissionData.ReadTransmissionData(mdlPath);
                if (transData != null)
                {
                    ICollection <ElementId> externalReferences = transData.GetAllExternalFileReferenceIds();
                    foreach (ElementId refId in externalReferences)
                    {
                        ExternalFileReference curRef = transData.GetLastSavedReferenceData(refId);
                        string refType = curRef.ExternalFileReferenceType.ToString();
                        string refPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(curRef.GetAbsolutePath());
                        if (refType == "RevitLink")
                        {
                            linkedProjects.Add(refPath);
                        }
                    }
                }
            }
            if (addProj)
            {
                linkedProjects.Add(app.ActiveUIDocument.Document.PathName);
            }
            //laatste check om te kijken of de links ook gevonden worden
            return(linkedProjects.Where(File.Exists).ToList());
        }
Esempio n. 4
0
        // bug683 fix: functie toegevoegd zodat IFC exporter selectief kan rapporteren welke files missen
        /// <summary>
        ///    Geef alle gelinkte files die niet langer gevonden kunnen worden
        /// </summary>
        /// <param name="app"></param>
        /// <param name="addProj"></param>
        /// <returns></returns>
        // ReSharper disable once UnusedMember.Global
        public static List <string> GetMissingLinkedFiles(UIApplication app, bool addProj)
        {
            List <string> linkedProjects = new List <string>();

            if (linkedProjects.Count == 0)
            {
                // er zijn waarschijnlijk worksets gebruikt
                ModelPath        mdlPath   = ModelPathUtils.ConvertUserVisiblePathToModelPath(app.ActiveUIDocument.Document.PathName);
                TransmissionData transData = TransmissionData.ReadTransmissionData(mdlPath);
                if (transData != null)
                {
                    ICollection <ElementId> externalReferences = transData.GetAllExternalFileReferenceIds();
                    foreach (ElementId refId in externalReferences)
                    {
                        ExternalFileReference curRef = transData.GetLastSavedReferenceData(refId);
                        string refType = curRef.ExternalFileReferenceType.ToString();
                        string refPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(curRef.GetAbsolutePath());
                        if (refType == "RevitLink")
                        {
                            linkedProjects.Add(refPath);
                        }
                    }
                }
            }

            if (addProj)
            {
                linkedProjects.Add(app.ActiveUIDocument.Document.PathName);
            }

            //laatste check om te kijken of de links ook gevonden worden
            return(linkedProjects.Where(p => (false == File.Exists(p))).ToList());
        }
Esempio n. 5
0
 public string FindDiffuseTextureDecal(Element element)
 {
     //查找漫反射纹理贴图
     try
     {
         // 获取元素ID
         ElementId typeId = element.GetTypeId();
         //获取外部文件参考
         ExternalFileReference externalFileReference = (document.GetElement(typeId) as ElementType).GetExternalFileReference();
         //判断外部文件参考类型是不是
         if (externalFileReference.ExternalFileReferenceType.Equals(AssetPropertyType.Float))
         {
             //是的话将模型路径转换为用户可见路径,(链接模型的完整路径作为参数)
             string inputPath = ModelPathUtils.ConvertModelPathToUserVisiblePath(externalFileReference.GetAbsolutePath());
             //最后返回文件绝对路径。
             return(FixTexturePath(inputPath));
         }
     }
     catch (Exception)
     {
     }
     return("");
 }