/// <summary>
        /// 获取选中对象
        /// </summary>
        /// <param name="selMgr"></param>
        /// <returns></returns>
        public static IEnumerable <ObjectSelection> GetObjectSelections(this ISelectionMgr selMgr)
        {
            var count = selMgr.GetSelectedObjectCount();

            for (int i = 1; i < count + 1; i++)
            {
                int            selMark        = selMgr.GetSelectedObjectMark(i);
                swSelectType_e swSelectType_E = (swSelectType_e)selMgr.GetSelectedObjectType3(i, AnyMark);
                object         obj            = selMgr.GetSelectedObject6(i, AnyMark);
                yield return(new ObjectSelection(obj, swSelectType_E, selMark, i, ref selMgr));
            }
        }
        /// <summary>
        /// 获取所有的选择对象
        /// </summary>
        /// <param name="selMgr"></param>
        /// <param name="Mark"></param>
        /// <returns></returns>
        public static List <ObjectSelection> GetAllSelectedObjectsEx(this ISelectionMgr selMgr)
        {
            var count = selMgr.GetSelectedObjectCount();
            List <ObjectSelection> objList = new List <ObjectSelection>();

            for (int i = 1; i < count + 1; i++)
            {
                int            selMark        = selMgr.GetSelectedObjectMark(i);
                swSelectType_e swSelectType_E = (swSelectType_e)selMgr.GetSelectedObjectType3(i, AnyMark);
                object         obj            = selMgr.GetSelectedObject6(i, AnyMark);
                objList.Add(new ObjectSelection(obj, swSelectType_E, selMark, i));
            }
            return(objList);
        }
Ejemplo n.º 3
0
        private Boolean AddMacroFeature()
        {
            IModelDoc2      moddoc;
            IFeatureManager FeatMgr;
            IFeature        MacroFeature;
            Object          paramNames;
            Object          paramTypes;
            Object          paramValues;

            string[] TparamNames  = new string[3];
            int[]    TparamTypes  = new int[3]; //Use int for 64 bit compatibility
            string[] TparamValues = new string[3];
            IBody2   editBody;
            int      opts;

            moddoc  = (IModelDoc2)iSwApp.ActiveDoc;
            FeatMgr = (IFeatureManager)moddoc.FeatureManager;
            ISelectionMgr swSelMgr = (ISelectionMgr)moddoc.SelectionManager;

            if (swSelMgr.GetSelectedObjectCount() != 1)
            {
                iSwApp.SendMsgToUser("Please select one face or plane");

                return(false);
            }

            var selFace = swSelMgr.GetSelectedObject6(1, 1);

            Feature[] swFeature = AddTMPBasePlaneFromSelectFace();

            //Include only data that won't be available from geometry
            TparamNames[0] = "Size";

            TparamTypes[0] = (int)swMacroFeatureParamType_e.swMacroFeatureParamTypeDouble;

            TparamValues[0] = newFeaturePmPage.SizeValue;
            //TparamNames[0] = "Width";
            //TparamNames[1] = "Offset";
            //TparamNames[2] = "Depth";

            //TparamTypes[0] = (int)swMacroFeatureParamType_e.swMacroFeatureParamTypeDouble;
            //TparamTypes[1] = (int)swMacroFeatureParamType_e.swMacroFeatureParamTypeDouble;
            //TparamTypes[2] = (int)swMacroFeatureParamType_e.swMacroFeatureParamTypeDouble;

            ////Hard code the parameters for test,
            ////but in practice get this from Property Manager Page
            //TparamValues[0] = "0.01"; //Width
            //TparamValues[1] = "0.005"; //Offset
            //TparamValues[2] = "0.006"; //Depth

            paramNames  = TparamNames;
            paramTypes  = TparamTypes;
            paramValues = TparamValues;

            string[] icos = new string[9];
            icos[0] = @"FeatureIcon.bmp";
            icos[1] = @"FeatureIcon.bmp";
            icos[2] = @"FeatureIcon.bmp";
            icos[3] = @"FeatureIcon.bmp";
            icos[4] = @"FeatureIcon.bmp";
            icos[5] = @"FeatureIcon.bmp";
            icos[6] = @"FeatureIcon.bmp";
            icos[7] = @"FeatureIcon.bmp";
            icos[8] = @"FeatureIcon.bmp";

            editBody = null;

            opts = 0;

            MacroFeature = FeatMgr.InsertMacroFeature3("New-Feature", "PaineTool.NewFeature.NewFeatureHandler", null, (paramNames), (paramTypes), (paramValues), null, null, editBody, icos, opts);

            //var featureDif = (MacroFeatureData)MacroFeature.GetDefinition();

            // featureDif.GetSelectedObjects(Filter);

            //var selObj = new DispatchWrapper[] { selFace }; ;
            //var selObjMark = new int[] { 0 };
            //var views = new IView[] { null };

            //featureDif.SetSelections2(selObj, selObjMark, views);

            //featureDif.SetSelections(selFace, 1);

            foreach (var item in swFeature)
            {
                // MessageBox.Show(item.Name);

                MacroFeature.MakeSubFeature(item);
            }

            // featureDif.ReleaseSelectionAccess();

            TparamNames  = null;
            TparamTypes  = null;
            TparamValues = null;

            return(true);
        }