Esempio n. 1
0
        public void Main()
        {
            List <DispatchWrapper> swObjects = new List <DispatchWrapper>();

            IModelDoc2 model = swApp.IActiveDoc2;

            if (model != null)
            {
                ISelectionMgr selMgr = model.ISelectionManager;

                for (int i = 0; i < selMgr.GetSelectedObjectCount2(-1); i++)
                {
                    object swSelObj = selMgr.GetSelectedObject6(i + 1, -1);
                    swObjects.Add(new DispatchWrapper(swSelObj));//it is required to wrap dispatch pointers to allow selection of objects of different types (i.e. faces, annotations, components etc.) together
                }

                model.ClearSelection2(true);

                Debugger.Break();

                model.Extension.MultiSelect2(swObjects.ToArray(), false, null);
            }
            else
            {
                swApp.SendMsgToUser("Please open the model");
            }
        }
        public static IEnumerable <ObjectSelection> GetObjectSelections(this ISelectionMgr selMgr)
        {
            var count = selMgr.GetSelectedObjectCount2(AnyMark);

            selMgr.EnableContourSelection = true;
            return(Enumerable.Range(StartIndex, count)
                   .Select(index =>
            {
                var type = (swSelectType_e)selMgr.GetSelectedObjectType3(index, AnyMark);
                var mark = selMgr.GetSelectedObjectMark(index);
                var obj = selMgr.GetSelectedObject6(index, AnyMark);
                //var typeList = ComWangling.GetComTypeFor<Surface>(obj).ToList();

                //LogViewer.Log($"Type of selection is {string.Join(", ", typeList)}");

                //if (type==swSelectType_e.swSelREFEDGES || type == swSelectType_e.swSelEDGES)
                //{
                //    var edge = obj.DirectCast<IEdge>();
                //}else if (type == swSelectType_e.swSelHELIX)
                //{
                //    var foo = obj.DirectCast<IFeature>();
                //}

                return new ObjectSelection(obj, type, mark, index);
            }));
        }
Esempio n. 3
0
        public static IEnumerable <ObjectSelection> GetObjectSelections(this ISelectionMgr selMgr)
        {
            var count = selMgr.GetSelectedObjectCount2(AnyMark);

            return(Enumerable.Range(StartIndex, count)
                   .Select(index =>
            {
                var type = (swSelectType_e)selMgr.GetSelectedObjectType3(index, AnyMark);
                var mark = selMgr.GetSelectedObjectMark(index);
                var obj = selMgr.GetSelectedObject6(index, AnyMark);
                return new ObjectSelection(obj, type, mark, index);
            }));
        }
Esempio n. 4
0
 /// <summary>
 /// Get the count of the selected objects
 /// </summary>
 /// <returns></returns>
 public int SelectedCount() => _selectionMgr.GetSelectedObjectCount2(0);
Esempio n. 5
0
 public bool MoveNext()
 {
     m_CurSelIndex++;
     return(m_SelMgr.GetSelectedObjectCount2(-1) >= m_CurSelIndex);
 }