Ejemplo n.º 1
0
        /// <summary>
        /// Get the absolute path of the linked DWG file (ver.2010 or below)
        /// </summary>
        public static string GetCADPath(UIDocument uidoc, ImportInstance import)
        {
            Document doc = uidoc.Document;
            //Element ele = import as ImportInstance;
            CADLinkType cadLinkType = doc.GetElement(import.GetTypeId()) as CADLinkType;

            return(ModelPathUtils.ConvertModelPathToUserVisiblePath(cadLinkType.GetExternalFileReference().GetAbsolutePath()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Collects non-RVT link and imports
        /// </summary>
        /// <param name="doc">The active document</param>
        /// <returns>Dictionary</returns>
        public static Dictionary <string, IList <Element> > NonRVTLinkCollector(Document doc)
        {
            // initiate a dictionary of element lists to hold collected links
            Dictionary <string, IList <Element> > linkDictionary = new Dictionary <string, IList <Element> >()
            {
                { RevitConstants.Strings.linkedCAD, new List <Element>() },
                { RevitConstants.Strings.importedCAD, new List <Element>() },
                { RevitConstants.Strings.importedSKP, new List <Element>() },
            };

            // collect all import instances
            FilteredElementCollector importInstances = new FilteredElementCollector(doc).OfClass(typeof(ImportInstance)).WhereElementIsNotElementType();

            // loop through the import instances
            foreach (Element i in importInstances)
            {
                // get the type of the import instance
                CADLinkType linkType = doc.GetElement(i.GetTypeId()) as CADLinkType;

                // if it's an external file reference, then it is a linked CAD
                if (linkType.IsExternalFileReference())
                {
                    linkDictionary[RevitConstants.Strings.linkedCAD].Add(i);
                }
                // if it is NOT an external file reference and the type name contains ".skp", then it is is an imported SKP
                else if (!linkType.IsExternalFileReference() && linkType.Name.Contains(".skp"))
                {
                    linkDictionary[RevitConstants.Strings.importedSKP].Add(i);
                }
                // if it is NOT an external file reference and the type name DOESN'T contain ".skp", then it is is an imported CAD
                else if (!linkType.IsExternalFileReference() && !linkType.Name.Contains(".skp"))
                {
                    linkDictionary[RevitConstants.Strings.importedCAD].Add(i);
                }
            }
            // return
            return(linkDictionary);
        }
Ejemplo n.º 3
0
 public CadLinkTypeWrapper(CADLinkType type)
 {
     Name = type.Name;
     Id   = type.Id;
 }