Inheritance: System.Windows.Forms.Form
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet highlightElements)
        {
            /*

              // retrieve all link elements:

              Document doc = app.ActiveUIDocument.Document;
              List<Element> links = GetElements(
            BuiltInCategory.OST_RvtLinks,
            typeof( Instance ), app, doc );

              // determine the link paths:

              DocumentSet docs = app.Documents;
              int n = docs.Size;
              Dictionary<string, string> paths
            = new Dictionary<string, string>( n );

              foreach( Document d in docs )
              {
            string path = d.PathName;
            int i = path.LastIndexOf( "\\" ) + 1;
            string name = path.Substring( i );
            paths.Add( name, path );
              }
              */

              // Retrieve lighting fixture element
              // data from linked documents:

              List<ElementData> data = new List<ElementData>();
              UIApplication app = commandData.Application;
              DocumentSet docs = app.Application.Documents;

              foreach( Document doc in docs )
              {
            FilteredElementCollector a
              = Util.GetElementsOfType( doc,
            typeof( FamilyInstance ),
            BuiltInCategory.OST_LightingFixtures );

            foreach( FamilyInstance e in a )
            {
              string name = e.Name;
              LocationPoint lp = e.Location as LocationPoint;
              if( null != lp )
              {
            XYZ p = lp.Point;
            data.Add( new ElementData( doc.PathName, e.Name,
              e.Id.IntegerValue, p.X, p.Y, p.Z, e.UniqueId ) );
              }
            }
              }

              // Display data:

              using( CmdLinkedFileElementsForm dlg = new CmdLinkedFileElementsForm( data ) )
              {
            dlg.ShowDialog();
              }

              return Result.Succeeded;
        }
Exemple #2
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet highlightElements)
        {
            /*
             *
             * // retrieve all link elements:
             *
             * Document doc = app.ActiveUIDocument.Document;
             * List<Element> links = GetElements(
             * BuiltInCategory.OST_RvtLinks,
             * typeof( Instance ), app, doc );
             *
             * // determine the link paths:
             *
             * DocumentSet docs = app.Documents;
             * int n = docs.Size;
             * Dictionary<string, string> paths
             * = new Dictionary<string, string>( n );
             *
             * foreach( Document d in docs )
             * {
             * string path = d.PathName;
             * int i = path.LastIndexOf( "\\" ) + 1;
             * string name = path.Substring( i );
             * paths.Add( name, path );
             * }
             */

            // Retrieve lighting fixture element
            // data from linked documents:

            List <ElementData> data = new List <ElementData>();
            UIApplication      app  = commandData.Application;
            DocumentSet        docs = app.Application.Documents;

            foreach (Document doc in docs)
            {
                FilteredElementCollector a
                    = Util.GetElementsOfType(doc,
                                             typeof(FamilyInstance),
                                             BuiltInCategory.OST_LightingFixtures);

                foreach (FamilyInstance e in a)
                {
                    string        name = e.Name;
                    LocationPoint lp   = e.Location as LocationPoint;
                    if (null != lp)
                    {
                        XYZ p = lp.Point;
                        data.Add(new ElementData(doc.PathName, e.Name,
                                                 e.Id.IntegerValue, p.X, p.Y, p.Z, e.UniqueId));
                    }
                }
            }

            // Display data:

            using (CmdLinkedFileElementsForm dlg = new CmdLinkedFileElementsForm(data))
            {
                dlg.ShowDialog();
            }

            return(Result.Succeeded);
        }