private static void DisconnectEntity(IModelDoc2 doc, Func <object> getEntity)
        {
            // switch to new config
            var defaultConfig = doc.ConfigurationManager.ActiveConfiguration;
            var newConfig     = doc.ConfigurationManager.AddConfiguration("TestConfig", "", "", 0, "Default", "");

            doc.ConfigurationManager.ActiveConfiguration.Should().Be(newConfig);

            // delete body
            doc.AddSelections(0, new[] { getEntity() });
            var deleteFeature = doc.FeatureManager.InsertDeleteBody2(false);

            doc.GetBodiesTs().Should().BeEmpty();

            // switch back to default config
            doc.ShowConfiguration2(defaultConfig.Name).Should().BeTrue();
            doc.ConfigurationManager.ActiveConfiguration.Should().Be(defaultConfig);
        }
        /// <summary>
        /// Add
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="selections"></param>
        public static void AddSelections(this IModelDoc2 doc, IEnumerable <SelectionData> selections)
        {
            var selectionMgr    = (ISelectionMgr)doc.SelectionManager;
            var selectedObjects = selectionMgr.GetAllSelectedObjects();

            selections
            .GroupBy(p => p.Mark)
            .Select(p =>
            {
                var objects = p
                              .SelectMany(selectionData => selectionData
                                          .GetObjects(doc)
                                          .Except(selectedObjects))
                              .ToArray();
                return(new { Mark = p.Key, Objects = objects });
            })
            .Where(p => p.Objects.Length > 0)
            .ForEach(o => doc.AddSelections(o.Mark, o.Objects));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Add
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="selections"></param>
        public static IDisposable AddSelections(this IModelDoc2 doc, IReadOnlyCollection <SelectionData> selections)
        {
            {
                var selectionMgr    = (ISelectionMgr)doc.SelectionManager;
                var selectedObjects = selectionMgr
                                      .GetSelectedObjects((_, __) => true)
                                      .ToList();
                selections
                .GroupBy(p => p.Mark)
                .Select(p =>
                {
                    var objects = p
                                  .SelectMany(selectionData => selectionData
                                              .GetObjects(doc)
                                              .Except(selectedObjects))
                                  .ToArray();
                    return(new { Mark = p.Key, Objects = objects });
                })
                .Where(p => p.Objects.Length > 0)
                .ForEach(o => doc.AddSelections(o.Mark, o.Objects));
            }

            return(Disposable.Create(() => doc.ClearSelections(selections)));
        }
Ejemplo n.º 4
0
 public static IDisposable AddSelection(this IModelDoc2 doc, SelectionData selection)
 {
     return(doc.AddSelections(new[] { selection }));
 }
Ejemplo n.º 5
0
        public static IDisposable AddSelectionsFromModel(this IModelDoc2 doc, object model)
        {
            var selections = SelectionDataExtensions.GetSelectionsFromModel(model).ToList();

            return(doc.AddSelections(selections));
        }
 public static void AddSelection(this IModelDoc2 doc, SelectionData selection)
 {
     doc.AddSelections(new[] { selection });
 }
        public static void AddSelectionsFromModel(this IModelDoc2 doc, object model)
        {
            var selections = SelectionDataExtensions.GetSelectionsFromModel(model).ToList();

            doc.AddSelections(selections);
        }
        private static void DisconnectEntity(IModelDoc2 doc, Func<object> getEntity)
        {
            // switch to new config
            var defaultConfig = doc.ConfigurationManager.ActiveConfiguration;
            var newConfig = doc.ConfigurationManager.AddConfiguration("TestConfig", "", "", 0, "Default", "");
            doc.ConfigurationManager.ActiveConfiguration.Should().Be(newConfig);

            // delete body
            doc.AddSelections(0, new[] { getEntity() });
            var deleteFeature = doc.FeatureManager.InsertDeleteBody2(false);
            doc.GetBodiesTs().Should().BeEmpty();

            // switch back to default config
            doc.ShowConfiguration2(defaultConfig.Name).Should().BeTrue();
            doc.ConfigurationManager.ActiveConfiguration.Should().Be(defaultConfig);
        }