Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using the function IsLink to differentiate between CAD links and CAD Imports

1 REPLY 1
SOLVED
Reply
Message 1 of 2
tjhogan2
547 Views, 1 Reply

Using the function IsLink to differentiate between CAD links and CAD Imports

I am trying to check for CADLinkTypes and have them seperated into two lists, one for the links and one for the imports.  According to the Revit API environment(when you hover over the CADLinkType) this can be done with the IsLink function, but I cannot figure out how to actually deploy this function.  When I try to call it like another function I am told that it is not defined.  This is what I have so far:

 

 

 

            public void findLinks()
        {
            Document doc = this.ActiveUIDocument.Document;
            string info = "";
            
            foreach (Element e in new FilteredElementCollector(doc)
                     .OfClass(typeof(CADLinkType)))
                
            {
                CADLinkType fi = e as CADLinkType;
                info += fi.Name + Environment.NewLine;
            }
            
            TaskDialog.Show("elements",info);
            
        }

 

 

 

 

 

 

Any help on this would be greatly appreciated.

1 REPLY 1
Message 2 of 2
tjhogan2
in reply to: tjhogan2

An update for anyone else who might be curious on this matter, it seems like th isLink function may be obsolete/no longer available in the Revit api(not sure why it is still suggested when you hover over the text though).  Instead I used IsExternalFileReference:

 

        public void findLinkedCAD()
        {
            Document doc = this.ActiveUIDocument.Document;
            string info = "";
            
            foreach (Element e in new FilteredElementCollector(doc)
                     .OfClass(typeof(CADLinkType)))
                     
            {
                if (e.IsExternalFileReference())
                
                    info += e.Name + " - " + e.Id + Environment.NewLine;
                            
            }
            
            TaskDialog.Show("elements",info);
            
        }

                public void findImportedCAD()
        {
            Document doc = this.ActiveUIDocument.Document;
            string info = "";
            
            foreach (Element e in new FilteredElementCollector(doc)
                     .OfClass(typeof(CADLinkType)))
                     
            {
                if (e.IsExternalFileReference())
                {
                    
                }
                else
                {
                    info += e.Name + " - " + e.Id + Environment.NewLine;
                }
            }
            
            TaskDialog.Show("elements",info);
            
        }

 

 

 

 

I wound up doing the two as seperate macros because that just seemed to fit my needs better, but it shouldn't be to difficult to combine them into one that spits out both.  Hope this helps anyone else having issues with this.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community