当前位置: 首页>>代码示例>>C#>>正文


C# FilteredElementCollector.ToElementIds方法代码示例

本文整理汇总了C#中FilteredElementCollector.ToElementIds方法的典型用法代码示例。如果您正苦于以下问题:C# FilteredElementCollector.ToElementIds方法的具体用法?C# FilteredElementCollector.ToElementIds怎么用?C# FilteredElementCollector.ToElementIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FilteredElementCollector的用法示例。


在下文中一共展示了FilteredElementCollector.ToElementIds方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public Result Execute( ExternalCommandData cmdData, ref string msg, ElementSet elems )
        {
            Result result;

              try
              {
            Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application;
            UIDocument revitDoc = cmdData.Application.ActiveUIDocument;
            Document dbdoc = revitDoc.Document;
            Snoop.CollectorExts.CollectorExt.m_activeDoc = dbdoc; // TBD: see note in CollectorExt.cs
            Autodesk.Revit.DB.View view = dbdoc.ActiveView;

            //ElementSet ss = cmdData.Application.ActiveUIDocument.Selection.Elements; // 2015, jeremy: 'Selection.Selection.Elements' is obsolete: 'This property is deprecated in Revit 2015. Use GetElementIds() and SetElementIds instead.'
            //if (ss.Size == 0)
            //{
            //  FilteredElementCollector collector = new FilteredElementCollector( revitDoc.Document, view.Id );
            //  collector.WhereElementIsNotElementType();
            //  FilteredElementIterator i = collector.GetElementIterator();
            //  i.Reset();
            //  ElementSet ss1 = cmdData.Application.Application.Create.NewElementSet();
            //  while( i.MoveNext() )
            //  {
            //    Element e = i.Current as Element;
            //    ss1.Insert( e );
            //  }
            //  ss = ss1;
            //}

            ICollection<ElementId> ids = cmdData.Application.ActiveUIDocument.Selection.GetElementIds(); // 2016, jeremy
            if( 0 == ids.Count )
            {
              FilteredElementCollector collector
            = new FilteredElementCollector( revitDoc.Document, view.Id )
              .WhereElementIsNotElementType();
              ids = collector.ToElementIds();
            }

            //ICollection<Element> elements
            //  = new List<Element>( ids.Select<ElementId,Element>(
            //    id => dbdoc.GetElement( id ) ) );

            Snoop.Forms.Objects form = new Snoop.Forms.Objects( dbdoc, ids );
            ActiveDoc.UIApp = cmdData.Application;
            form.ShowDialog();

            result = Result.Succeeded;
              }
              catch( System.Exception e )
              {
            msg = e.Message;
            result = Result.Failed;
              }

              return result;
        }
开发者ID:jeremytammik,项目名称:RevitLookup,代码行数:55,代码来源:TestCmds.cs

示例2: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
              UIDocument uidoc = uiapp.ActiveUIDocument;
              Application app = uiapp.Application;
              Document doc = uidoc.Document;

              // Construct a parameter filter to get only
              // unnamed reference planes, i.e. reference
              // planes whose name equals the empty string:

              BuiltInParameter bip
            = BuiltInParameter.DATUM_TEXT;

              ParameterValueProvider provider
            = new ParameterValueProvider(
              new ElementId( bip ) );

              FilterStringRuleEvaluator evaluator
            = new FilterStringEquals();

              FilterStringRule rule = new FilterStringRule(
            provider, evaluator, "", false );

              ElementParameterFilter filter
            = new ElementParameterFilter( rule );

              FilteredElementCollector col
            = new FilteredElementCollector( doc )
              .OfClass( typeof( ReferencePlane ) )
              .WherePasses( filter );

              int n = 0;
              int nDeleted = 0;

              // No need to cast ... this is pretty nifty,
              // I find ... grab the elements as ReferencePlane
              // instances, since the filter guarantees that
              // only ReferencePlane instances are selected.
              // In Revit 2014, this attempt to delete the
              // reference planes while iterating over the
              // filtered element collector throws an exception:
              // Autodesk.Revit.Exceptions.InvalidOperationException:
              // HResult=-2146233088
              // Message=The iterator cannot proceed due to
              // changes made to the Element table in Revit's
              // database (typically, This can be the result
              // of an Element deletion).
              //
              //foreach( ReferencePlane rp in col )
              //{
              //  ++n;
              //  nDeleted += DeleteIfNotHosting( rp ) ? 1 : 0;
              //}

              ICollection<ElementId> ids = col.ToElementIds();

              n = ids.Count();

              if( 0 < n )
              {
            using( Transaction tx = new Transaction( doc ) )
            {
              tx.Start( string.Format(
            "Delete {0} ReferencePlane{1}",
            n, Util.PluralSuffix( n ) ) );

              // This also causes the exception "One or more of
              // the elementIds cannot be deleted. Parameter
              // name: elementIds
              //
              //ICollection<ElementId> ids2 = doc.Delete(
              //  ids );
              //nDeleted = ids2.Count();

              List<ElementId> ids2 = new List<ElementId>(
            ids );

              foreach( ElementId id in ids2 )
              {
            try
            {
              ICollection<ElementId> ids3 = doc.Delete(
                id );

              nDeleted += ids3.Count;
            }
            catch( Autodesk.Revit.Exceptions.ArgumentException )
            {
            }
              }

              tx.Commit();
            }
              }

              Util.InfoMsg( string.Format(
//.........这里部分代码省略.........
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:101,代码来源:CmdDeleteUnusedRefPlanes.cs

示例3: Execute


//.........这里部分代码省略.........

              // turn off the far clip plane with standard parameter API
              if (perspView.get_Parameter(BuiltInParameter.VIEWER_BOUND_ACTIVE_FAR).HasValue)
              {
                Parameter m_farClip = perspView.get_Parameter(BuiltInParameter.VIEWER_BOUND_ACTIVE_FAR);
                m_farClip.Set(0);

              }
              perspView.CropBoxActive = true;
              perspView.CropBoxVisible = true;

              trans.Commit();
            }
              }
              uidoc.ActiveView = perspView;
            }
            else if (v.SheetCamera != null)//sheet
            {
              //using (Transaction trans = new Transaction(uidoc.Document))
              //{
              //    if (trans.Start("Open sheet view") == TransactionStatus.Started)
              //    {
              IEnumerable<View> viewcollectorSheet = getSheets(doc, v.SheetCamera.SheetID);
              if (!viewcollectorSheet.Any())
              {
            MessageBox.Show("No Sheet with Id=" + v.SheetCamera.SheetID + " found.");
            return;
              }
              uidoc.ActiveView = viewcollectorSheet.First();
              uidoc.RefreshActiveView();

              //        trans.Commit();
              //    }
              //}
              XYZ m_xyzTl = new XYZ(v.SheetCamera.TopLeft.X, v.SheetCamera.TopLeft.Y,
                      v.SheetCamera.TopLeft.Z);
              XYZ m_xyzBr = new XYZ(v.SheetCamera.BottomRight.X, v.SheetCamera.BottomRight.Y,
                      v.SheetCamera.BottomRight.Z);
              uidoc.GetOpenUIViews().First().ZoomAndCenterRectangle(m_xyzTl, m_xyzBr);

            }
            else
            {
              return;
            }
            //select/hide elements
            if (v.Components != null && v.Components.Any())
            {
              FilteredElementCollector collector = new FilteredElementCollector(doc, doc.ActiveView.Id).WhereElementIsNotElementType();
              ICollection<ElementId> collection = collector.ToElementIds();
              foreach (var e in v.Components)
              {
            var bcfguid = IfcGuid.FromIfcGUID(e.IfcGuid);
            var ids = collection.Where(o => bcfguid == ExportUtils.GetExportId(doc, o));
            if (ids.Any())
            {
              //m_elementsToHide.Add(doc.GetElement(ids.First()));
              elementids.Add(ids.First());
            }
              }
              if (null != elementids && elementids.Count > 0)
              {
            //do transaction only if there is something to hide/select
            using (Transaction trans = new Transaction(uidoc.Document))
            {
              if (trans.Start("Apply visibility/selection") == TransactionStatus.Started)
              {

                if (UserSettings.Get("selattachedelems") == "0")
                {
                  uidoc.ActiveView.IsolateElementsTemporary(elementids);
                }
                else
                {
            #if Version2014
                  uidoc.Selection.Elements.Clear();
                  foreach (var elementid in elementids)
                  {
                    uidoc.Selection.Elements.Add(doc.GetElement(elementid));
                  }
            #elif Version2015
             uidoc.Selection.SetElementIds(elementids);
            #elif Version2016
                  uidoc.Selection.SetElementIds(elementids);
            #endif
                }

              }
              trans.Commit();
            }
              }
            }

            uidoc.RefreshActiveView();
              }
              catch (Exception ex)
              {
            TaskDialog.Show("Error!", "exception: " + ex);
              }
        }
开发者ID:WeConnect,项目名称:issue-tracker,代码行数:101,代码来源:ExtOpenView.cs

示例4: generateViewpoint

        /// <summary>
        /// Generate Viewpoint
        /// </summary>
        /// <param name="elemCheck"></param>
        /// <returns></returns>
        private VisualizationInfo generateViewpoint(int elemCheck)
        {
            try
              {
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Document doc = uidoc.Document;

            VisualizationInfo v = new VisualizationInfo();

            XYZ centerIMP = new XYZ();
            string type = "";
            double zoomValue = 1;

            if (uidoc.ActiveView.ViewType != ViewType.ThreeD) //is a 2D view
            {
              XYZ TL = uidoc.GetOpenUIViews()[0].GetZoomCorners()[0];
              XYZ BR = uidoc.GetOpenUIViews()[0].GetZoomCorners()[1];
              v.SheetCamera = new SheetCamera();
              v.SheetCamera.SheetID = uidoc.ActiveView.Id.IntegerValue;
              v.SheetCamera.TopLeft = new IssueTracker.Data.Point(TL.X, TL.Y, TL.Z);
              v.SheetCamera.BottomRight = new IssueTracker.Data.Point(BR.X, BR.Y, BR.Z);
            }
            else
            {
              View3D view3D = (View3D)uidoc.ActiveView;
              if (!view3D.IsPerspective) //IS ORTHO
              {
            XYZ TL = uidoc.GetOpenUIViews()[0].GetZoomCorners()[0];
            XYZ BR = uidoc.GetOpenUIViews()[0].GetZoomCorners()[1];

            double xO = (TL.X + BR.X) / 2;
            double yO = (TL.Y + BR.Y) / 2;
            double zO = (TL.Z + BR.Z) / 2;
            //converto to METERS
            centerIMP = new XYZ(xO, yO, zO);
            double dist = TL.DistanceTo(BR) / 2; //custom value to get solibri zoom value from Corners of Revit UiView
            XYZ diagVector = TL.Subtract(BR);
            double customZoomValue = (ProjectSettings.Get("useDefaultZoom", doc.PathName) == "1") ? 1 : 2.5;

            zoomValue = UnitUtils.ConvertFromInternalUnits(dist * Math.Sin(diagVector.AngleTo(view3D.RightDirection)), DisplayUnitType.DUT_METERS) * customZoomValue;
            type = "OrthogonalCamera";
              }
              else // it is a perspective view
              {
            centerIMP = uidoc.ActiveView.Origin;
            type = "PerspectiveCamera";
            zoomValue = 45;
              }
              ViewOrientation3D t = ConvertBasePoint(centerIMP, uidoc.ActiveView.ViewDirection, uidoc.ActiveView.UpDirection, false);
              XYZ c = t.EyePosition;
              XYZ vi = t.ForwardDirection;
              XYZ up = t.UpDirection;

              if (type == "OrthogonalCamera")
              {
            v.OrthogonalCamera = new OrthogonalCamera();
            v.OrthogonalCamera.CameraViewPoint.X = UnitUtils.ConvertFromInternalUnits(c.X, DisplayUnitType.DUT_METERS);
            v.OrthogonalCamera.CameraViewPoint.Y = UnitUtils.ConvertFromInternalUnits(c.Y, DisplayUnitType.DUT_METERS);
            v.OrthogonalCamera.CameraViewPoint.Z = UnitUtils.ConvertFromInternalUnits(c.Z, DisplayUnitType.DUT_METERS);
            v.OrthogonalCamera.CameraUpVector.X = UnitUtils.ConvertFromInternalUnits(up.X, DisplayUnitType.DUT_METERS);
            v.OrthogonalCamera.CameraUpVector.Y = UnitUtils.ConvertFromInternalUnits(up.Y, DisplayUnitType.DUT_METERS);
            v.OrthogonalCamera.CameraUpVector.Z = UnitUtils.ConvertFromInternalUnits(up.Z, DisplayUnitType.DUT_METERS);
            v.OrthogonalCamera.CameraDirection.X = UnitUtils.ConvertFromInternalUnits(vi.X, DisplayUnitType.DUT_METERS) * -1;
            v.OrthogonalCamera.CameraDirection.Y = UnitUtils.ConvertFromInternalUnits(vi.Y, DisplayUnitType.DUT_METERS) * -1;
            v.OrthogonalCamera.CameraDirection.Z = UnitUtils.ConvertFromInternalUnits(vi.Z, DisplayUnitType.DUT_METERS) * -1;
            v.OrthogonalCamera.ViewToWorldScale = zoomValue;
              }
              else
              {
            v.PerspectiveCamera = new PerspectiveCamera();
            v.PerspectiveCamera.CameraViewPoint.X = UnitUtils.ConvertFromInternalUnits(c.X, DisplayUnitType.DUT_METERS);
            v.PerspectiveCamera.CameraViewPoint.Y = UnitUtils.ConvertFromInternalUnits(c.Y, DisplayUnitType.DUT_METERS);
            v.PerspectiveCamera.CameraViewPoint.Z = UnitUtils.ConvertFromInternalUnits(c.Z, DisplayUnitType.DUT_METERS);
            v.PerspectiveCamera.CameraUpVector.X = UnitUtils.ConvertFromInternalUnits(up.X, DisplayUnitType.DUT_METERS);
            v.PerspectiveCamera.CameraUpVector.Y = UnitUtils.ConvertFromInternalUnits(up.Y, DisplayUnitType.DUT_METERS);
            v.PerspectiveCamera.CameraUpVector.Z = UnitUtils.ConvertFromInternalUnits(up.Z, DisplayUnitType.DUT_METERS);
            v.PerspectiveCamera.CameraDirection.X = UnitUtils.ConvertFromInternalUnits(vi.X, DisplayUnitType.DUT_METERS) * -1;
            v.PerspectiveCamera.CameraDirection.Y = UnitUtils.ConvertFromInternalUnits(vi.Y, DisplayUnitType.DUT_METERS) * -1;
            v.PerspectiveCamera.CameraDirection.Z = UnitUtils.ConvertFromInternalUnits(vi.Z, DisplayUnitType.DUT_METERS) * -1;
            v.PerspectiveCamera.FieldOfView = zoomValue;
              }
            }

            //COMPONENTS PART
            FilteredElementCollector collector = new FilteredElementCollector(doc, doc.ActiveView.Id).WhereElementIsNotElementType();
            System.Collections.Generic.ICollection<ElementId> collection = null;

            if (elemCheck == 0)
              collection = collector.ToElementIds();
            else if (elemCheck == 1)
              collection = uidoc.Selection.GetElementIds();

            if (null != collection && collection.Any())
            {
              v.Components = new IssueTracker.Data.Component[collection.Count];
//.........这里部分代码省略.........
开发者ID:WeConnect,项目名称:issue-tracker,代码行数:101,代码来源:RevitWindow.xaml.cs

示例5: GetUnusedTextNoteTypesExcluding

        /// <summary>
        /// Return all unused text note types by first
        /// determining all text note types in use and
        /// then collecting all the others using an
        /// exclusion filter.
        /// </summary>
        ICollection<ElementId> GetUnusedTextNoteTypesExcluding(
            Document doc)
        {
            ICollection<ElementId> usedTextNotesTypeIds
            = new Collection<ElementId>();

              FilteredElementCollector textNotes
            = new FilteredElementCollector( doc )
              .OfClass( typeof( TextNote ) );

              foreach( TextNote textNote in textNotes )
              {
            usedTextNotesTypeIds.Add(
              textNote.TextNoteType.Id );
              }

              FilteredElementCollector unusedTypeCollector
            = new FilteredElementCollector( doc )
              .OfClass( typeof( TextNoteType ) );

              if( 0 < usedTextNotesTypeIds.Count )
              {
            unusedTypeCollector.Excluding(
              usedTextNotesTypeIds );
              }

              ICollection<ElementId> unusedTypes
            = unusedTypeCollector.ToElementIds();

              return unusedTypes;
        }
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:37,代码来源:CmdPurgeTextNoteTypes.cs

示例6: OnIFCExport


//.........这里部分代码省略.........
                     failureOptions.SetClearAfterRollback(false);
                     transaction.SetFailureHandlingOptions(failureOptions);

                     // Normally the transaction will be rolled back, but there are cases where we do update the document.
                     // There is no UI option for this, but these two options can be useful for debugging/investigating
                     // issues in specific file export.  The first one supports export of only one element
                     //exportOptions.AddOption("SingleElement", "174245");
                     // The second one supports export only of a list of elements
                     //exportOptions.AddOption("ElementsForExport", "174245;205427");

                     if (multipleFiles)
                     {
                        fileName = GenerateFileNameFromDocument(document, exportedFileNames) + "." + defaultExt;
                        fullName = path + "\\" + fileName;
                     }

                     // Prepare the export options
                     IFCExportOptions exportOptions = new IFCExportOptions();
                     
                     ElementId activeViewId = GenerateActiveViewIdFromDocument(document);
                     selectedConfig.UpdateOptions(exportOptions, activeViewId);
                     selectedConfig.ActiveViewId = selectedConfig.UseActiveViewGeometry ? activeViewId.IntegerValue : -1;

                     bool result = document.Export(path, fileName, exportOptions);

                     Dictionary<ElementId, string> linksGUIDsCache = new Dictionary<ElementId, string>();
                     if (result)
                     {
                        // Cache for links guids
                        if (selectedConfig.ExportLinkedFiles == true)
                        {
                           Autodesk.Revit.DB.FilteredElementCollector collector = new FilteredElementCollector(document);
                           collector.WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_RvtLinks);
                           System.Collections.Generic.ICollection<ElementId> rvtLinkInstanceIds = collector.ToElementIds();
                           foreach (ElementId linkId in rvtLinkInstanceIds)
                           {
                              Element linkInstance = document.GetElement(linkId);
                              if (linkInstance == null)
                                 continue;
                              Parameter parameter = linkInstance.get_Parameter(BuiltInParameter.IFC_GUID);
                              if (parameter != null && parameter.HasValue && parameter.StorageType == StorageType.String)
                              {
                                 String sGUID = parameter.AsString(), sGUIDlower = sGUID.ToLower();
                                 foreach (KeyValuePair<ElementId, string> value in linksGUIDsCache)
                                    if (value.Value.ToLower().IndexOf(sGUIDlower) == 0)
                                       sGUID += "-";
                                 linksGUIDsCache.Add(linkInstance.Id, sGUID);
                              }
                           }
                        }
                     }
                     else
                     {
                        unsuccesfulExports += fullName + "\n";
                     }

                     // Roll back the transaction started earlier, unless certain options are set.
                     if (result && (use2009BuildingStoreyGUIDs || selectedConfig.StoreIFCGUID))
                        transaction.Commit();
                     else
                        transaction.RollBack();

                     // Export links
                     if (selectedConfig.ExportLinkedFiles == true)
                     {
                        exportOptions.AddOption("ExportingLinks", true.ToString());
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:67,代码来源:IFCCommandOverrideApplication.cs

示例7: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref String message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              Document doc = app.ActiveUIDocument.Document;

              FilteredElementCollector a;
              Parameter p;
              int n;

              #region Using the obsolete TitleBlocks property
            #if BEFORE_REVIT_2015
              // The TitleBlocks property was declared deprecated
              // in the Revit 2014 API, and removed in Revit 2015.

              // Using the obsolete deprecated TitleBlocks property

              FamilySymbolSet titleBlocks = doc.TitleBlocks;

              n = titleBlocks.Size;

              Debug.Print(
            "{0} title block element type{1} listed "
            + "in doc.TitleBlocks collection{2}",
            n,
            ( 1 == n ? "" : "s" ),
            ( 0 == n ? "." : ":" ) );

              string s;

              foreach( FamilySymbol tb in titleBlocks )
              {
            // these are the family symbols,
            // i.e. the title block element types,
            // i.e. not instances, i.e. not sheets,
            // and they obviously do not have any sheet
            // number, width or height, so 's' ends up empty:

            s = GetParameterValueString( tb, BuiltInParameter.SHEET_NUMBER )
              + GetParameterValueString( tb, BuiltInParameter.SHEET_WIDTH )
              + GetParameterValueString( tb, BuiltInParameter.SHEET_HEIGHT );

            Debug.Print(
              "Title block element type {0} {1}" + s,
              tb.Name, tb.Id.IntegerValue );
              }
            #endif // BEFORE_REVIT_2015
              #endregion // Using the obsolete TitleBlocks property

              // Using this filter returns the same elements
              // as the doc.TitleBlocks collection:

              a = new FilteredElementCollector( doc )
            .OfCategory( BuiltInCategory.OST_TitleBlocks )
            .OfClass( typeof( FamilySymbol ) );

              n = a.ToElementIds().Count;

              Debug.Print( "{0} title block element type{1} "
            + "retrieved by filtered element collector{2}",
            n,
            ( 1 == n ? "" : "s" ),
            ( 0 == n ? "." : ":" ) );

              foreach( FamilySymbol symbol in a )
              {
            Debug.Print(
              "Title block element type {0} {1}",
              symbol.Name, symbol.Id.IntegerValue );
              }

              // Retrieve the title block instances:

              a = new FilteredElementCollector( doc )
            .OfCategory( BuiltInCategory.OST_TitleBlocks )
            .OfClass( typeof( FamilyInstance ) );

              Debug.Print( "Title block instances:" );

              foreach( FamilyInstance e in a )
              {
            p = e.get_Parameter(
              BuiltInParameter.SHEET_NUMBER );

            Debug.Assert( null != p,
              "expected valid sheet number" );

            string sheet_number = p.AsString();

            p = e.get_Parameter(
              BuiltInParameter.SHEET_WIDTH );

            Debug.Assert( null != p,
              "expected valid sheet width" );

            string swidth = p.AsValueString();
            double width = p.AsDouble();

//.........这里部分代码省略.........
开发者ID:JesseMom,项目名称:the_building_coder_samples,代码行数:101,代码来源:CmdSheetSize.cs

示例8: OnIFCExport


//.........这里部分代码省略.........

                        // Call this before the Export IFC transaction starts, as it has its own transaction.
                        IFCClassificationMgr.DeleteObsoleteSchemas(doc);

                        // IFC export requires an open transaction, although no changes should be made
                        Transaction transaction = new Transaction(doc, "Export IFC");
                        transaction.Start();
                        FailureHandlingOptions failureOptions = transaction.GetFailureHandlingOptions();
                        failureOptions.SetClearAfterRollback(false);
                        transaction.SetFailureHandlingOptions(failureOptions);

                        // There is no UI option for this, but these two options can be useful for debugging/investigating
                        // issues in specific file export.  The first one supports export of only one element
                        //exportOptions.AddOption("SingleElement", "174245");
                        // The second one supports export only of a list of elements
                        //exportOptions.AddOption("ElementsForExport", "174245;205427");

                        bool result = doc.Export(path, fileName, exportOptions); // pass in the options here

                        if (!result)
                        {
                            using (TaskDialog taskDialog = new TaskDialog(Properties.Resources.IFCExport))
                            {
                                taskDialog.MainInstruction = Properties.Resources.IFCExportProcessError;
                                taskDialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
                                TaskDialogResult taskDialogResult = taskDialog.Show();
                            }
                        }

                        // This option should be rarely used, and is only for consistency with old files.  As such, it is set by environment variable only.
                        String use2009GUID = Environment.GetEnvironmentVariable("Assign2009GUIDToBuildingStoriesOnIFCExport");
                        bool use2009BuildingStoreyGUIDs = (use2009GUID != null && use2009GUID == "1");

                        // Cache for links guids
                        Dictionary<ElementId, string> linksGUIDsCache = new Dictionary<ElementId, string>();
                        if (selectedConfig.ExportLinkedFiles == true)
                        {
                            Autodesk.Revit.DB.FilteredElementCollector collector = new FilteredElementCollector(doc);
                            collector.WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_RvtLinks);
                            System.Collections.Generic.ICollection<ElementId> rvtLinkInstanceIds = collector.ToElementIds();
                            foreach (ElementId linkId in rvtLinkInstanceIds)
                            {
                                Element linkInstance = doc.GetElement(linkId);
                                if (linkInstance == null)
                                    continue;
                                Parameter parameter = linkInstance.get_Parameter(BuiltInParameter.IFC_GUID);
                                if (parameter != null && parameter.HasValue && parameter.StorageType == StorageType.String)
                                {
                                    String sGUID = parameter.AsString(), sGUIDlower = sGUID.ToLower();
                                    foreach (KeyValuePair<ElementId, string> value in linksGUIDsCache)
                                        if (value.Value.ToLower().IndexOf(sGUIDlower) == 0)
                                            sGUID += "-";
                                    linksGUIDsCache.Add(linkInstance.Id, sGUID);
                                }
                            }
                        }

                        // Roll back the transaction started earlier, unless certain options are set.
                        if (use2009BuildingStoreyGUIDs || selectedConfig.StoreIFCGUID)
                            transaction.Commit();
                        else
                            transaction.RollBack();
                        
                        // Export links
                        if (selectedConfig.ExportLinkedFiles == true)
                        {
                            exportOptions.AddOption("ExportingLinks", true.ToString());
                            ExportLinkedDocuments(doc, fullName, linksGUIDsCache, exportOptions);
                            exportOptions.AddOption("ExportingLinks", false.ToString());
                        }
                        
                        // Remember last successful export location
                        m_mruExportPath = path;
                    }   
                }

                // The cancel button should cancel the export, not any "OK"ed setup changes.
                if (mainWindow.Result == IFCExportResult.ExportAndSaveSettings || mainWindow.Result == IFCExportResult.Cancel)
                {
                    if (PotentiallyUpdatedConfigurations)
                    {
                        configurationsMap = mainWindow.GetModifiedConfigurations();
                        configurationsMap.UpdateSavedConfigurations();
                    }

                    // Remember last selected configuration
                    m_mruConfiguration = mainWindow.GetSelectedConfiguration().Name;
                }
            }
            catch (Exception e)
            {
                using (TaskDialog taskDialog = new TaskDialog(Properties.Resources.IFCExport))
                {
                    taskDialog.MainInstruction = Properties.Resources.IFCExportProcessError;
                    taskDialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
                    taskDialog.ExpandedContent = e.ToString();
                    TaskDialogResult result = taskDialog.Show();
                }
            }
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:101,代码来源:IFCCommandOverrideApplication.cs

示例9: _get2DViewForElement

        /// <summary>
        /// Gets any 2D view where the element is displayed
        /// </summary>
        /// <param name="element"></param>
        /// <returns>A 2D view where the element is displayed</returns>
        private View _get2DViewForElement( Element element )
        {
            FilteredElementCollector collector;
              ICollection<ElementId> elements_in_view;

              foreach( View view in
            this._2D_views_that_can_display_elements )
              {
            collector = new FilteredElementCollector(
              this._host_document, view.Id )
            .WhereElementIsNotElementType();

            elements_in_view = collector.ToElementIds();

            if( elements_in_view.Contains( element.Id ) )
              return view;
              }

              return null;
        }
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:25,代码来源:CmdCollectorPerformance.cs

示例10: CanExportCurtainWallAsContainer

        /// <summary>
        /// Checks if the curtain element can be exported as container.
        /// </summary>
        /// <remarks>
        /// It checks if all sub elements to be exported have geometries.
        /// </remarks>
        /// <param name="allSubElements">
        /// Collection of elements contained in the host curtain element.
        /// </param>
        /// <param name="document">
        /// The Revit document.
        /// </param>
        /// <returns>
        /// True if it can be exported as container, false otherwise.
        /// </returns>
        private static bool CanExportCurtainWallAsContainer(ICollection<ElementId> allSubElements, Document document)
        {
            Options geomOptions = GeometryUtil.GetIFCExportGeometryOptions();

            FilteredElementCollector collector = new FilteredElementCollector(document, allSubElements);

            List<Type> curtainWallSubElementTypes = new List<Type>();
            curtainWallSubElementTypes.Add(typeof(FamilyInstance));
            curtainWallSubElementTypes.Add(typeof(CurtainGridLine));

            ElementMulticlassFilter multiclassFilter = new ElementMulticlassFilter(curtainWallSubElementTypes, true);
            collector.WherePasses(multiclassFilter);
            ICollection<ElementId> filteredSubElemments = collector.ToElementIds();
            foreach (ElementId subElemId in filteredSubElemments)
            {
                Element subElem = document.GetElement(subElemId);
                GeometryElement geomElem = subElem.get_Geometry(geomOptions);
                if (geomElem == null)
                    return false;
            }
            return true;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:37,代码来源:CurtainSystemExporter.cs

示例11: GetInstanceGeometry

        /// <summary>
        /// Get geometry of family instances and show them in Revit views
        /// </summary>
        public void GetInstanceGeometry()
        {
            FilteredElementCollector instanceCollector = new FilteredElementCollector(RevitDoc);
            instanceCollector.OfClass(typeof(FamilyInstance));

            // create views by different names

            View instanceView = RevitDoc.Create.NewView3D(new XYZ(1, 1, -1));
            instanceView.Name = "InstanceGeometry";

            View originalView = RevitDoc.Create.NewView3D(new XYZ(0, 1, -1));
            originalView.Name = "OriginalGeometry";

            View transView = RevitDoc.Create.NewView3D(new XYZ(-1, 1, -1));
            transView.Name = "TransformedGeometry";

            foreach (FamilyInstance instance in instanceCollector)
            {
                GeometryElement instanceGeo = instance.get_Geometry(m_options);
                GeometryElement slaveGeo = instance.GetOriginalGeometry(m_options);
                GeometryElement transformGeo = slaveGeo.GetTransformed(instance.GetTransform());

                // show family instance geometry
                foreach (GeometryObject obj in instanceGeo.Objects)
                {
                    if (obj is Solid)
                    {
                        Solid solid = obj as Solid;
                        PaintSolid(solid, instanceView);
                    }
                }

                // show geometry that is original geometry
                foreach (GeometryObject obj in slaveGeo.Objects)
                {
                    if (obj is Solid)
                    {
                        Solid solid = obj as Solid;
                        PaintSolid(solid, originalView);
                    }
                }

                // show geometry that was transformed
                foreach (GeometryObject obj in transformGeo.Objects)
                {
                    if (obj is Solid)
                    {
                        Solid solid = obj as Solid;
                        PaintSolid(solid, transView);
                    }
                }
            }
            // remove original instances to view point results.
            RevitDoc.Delete(instanceCollector.ToElementIds());
        }
开发者ID:AMEE,项目名称:revit,代码行数:58,代码来源:SlaveSymbolGeometry.cs

示例12: ElementsWithStorage

 /// <summary>
 /// 
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="schema"></param>
 /// <returns>List of ElementIds that elements contain extensible storage</returns>
 private static List<ElementId> ElementsWithStorage(Document doc, Schema schema)
 {
     List<ElementId> ids = new List<ElementId>();
     FilteredElementCollector fec = new FilteredElementCollector(doc);
     fec.WherePasses(new ExtensibleStorageFilter(schema.GUID));
     ids.AddRange(fec.ToElementIds());
     return ids;
 }
开发者ID:kmorin,项目名称:nwcautoviewexporter,代码行数:14,代码来源:Helpers.cs

示例13: Process

 private static void Process()
 {
     if (_StruColumns.Count() * _StruBeams.Count() == 0) return;
     string FGCode;
     if (!TryGetFGCode(out FGCode)) return;
     int floorNum = MyLevel.GetLevelNum() - 1;
     int[] num = new int[floorNum];
     int totalNum = 0;
     for (int i = 0; i < floorNum; ++i)
     {
         int n, m, k;
         double lowerLevel = _myLevel.GetElevation(i);
         double upperLevel = _myLevel.GetElevation(i + 1);
         double deltaHi = upperLevel - lowerLevel;
         double columnLL = lowerLevel + deltaHi * 0.3;
         double columnUL = upperLevel - deltaHi * 0.3;
         XYZ columnBottom = new XYZ(_maxBB.Min.X, _maxBB.Min.Y, columnLL);
         XYZ columnTop = new XYZ(_maxBB.Max.X, _maxBB.Max.Y, columnUL);
         BoundingBoxIntersectsFilter columnBBFilter = new BoundingBoxIntersectsFilter(new Outline(columnBottom, columnTop));
         FilteredElementCollector columnFec = new FilteredElementCollector(_doc, _StruColumns);
         columnFec.WherePasses(columnBBFilter);
         double beamLL = lowerLevel + deltaHi * 0.7;
         double beamUL = upperLevel + deltaHi * 0.3;
         XYZ beamBottom = new XYZ(_maxBB.Min.X, _maxBB.Min.Y, beamLL);
         XYZ beamTop = new XYZ(_maxBB.Max.X, _maxBB.Max.Y, beamUL);
         BoundingBoxIntersectsFilter beamBBFilter = new BoundingBoxIntersectsFilter(new Outline(beamBottom, beamTop));
         FilteredElementCollector beamFec = new FilteredElementCollector(_doc, _StruBeams);
         beamFec.WherePasses(beamBBFilter);
         if (columnFec.Count() * beamFec.Count() == 0) continue;
         GetNMK(columnFec.ToElementIds().ToList(), beamFec.ToElementIds().ToList(), out n, out m, out k);
         num[i] = m - n + k;
         totalNum += num[i];
     }
     if (totalNum != 0)
     {
         PGItem pgItem = new PGItem();
         pgItem.Code = FGCode;
         pgItem.direction = Direction.Undefined;
         pgItem.PGName = "支撑刚架";
         pgItem.PinYinSuffix = "ZhiChengGangJia";
         pgItem.Price = _addiInfo.prices[(byte)PGComponents.BracedFrame];
         if (pgItem.Price == 0.0) pgItem.IfDefinePrice = false;
         else pgItem.IfDefinePrice = true;
         for (int i = 0; i < floorNum; ++i)
         {
             pgItem.Num[i] = num[i];
         }
         _PGItems.Add(pgItem);
     }
 }
开发者ID:Xiang-Zeng,项目名称:P58_Loss,代码行数:50,代码来源:PBracedFrame.cs


注:本文中的FilteredElementCollector.ToElementIds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。