Example #1
0
        protected override bool OnEditDefinition(ISldWorks app, IModelDoc2 model, IFeature feature)
        {
            var featData = feature.GetDefinition() as IMacroFeatureData;

            featData.AccessSelections(model, (feature as IEntity).GetComponent());

            var parameters = GetParameters(feature, featData, model);

            var addHeight = parameters.AddHeight;

            var newAddHeight = app.SendMsgToUser2("Add extra height (Yes) or remove extra height (No)?", (int)swMessageBoxIcon_e.swMbQuestion, (int)swMessageBoxBtn_e.swMbYesNo) == (int)swMessageBoxResult_e.swMbHitYes;

            if (newAddHeight != addHeight)
            {
                parameters.AddHeight = newAddHeight;

                SetParameters(model, feature, featData, parameters);

                feature.ModifyDefinition(featData, model, (feature as IEntity).GetComponent());
            }
            else
            {
                featData.ReleaseSelectionAccess();
            }

            return(true);
        }
Example #2
0
        protected void CreatePropertyManagerPage()
        {
            int errors  = -1;
            int options = (int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton |
                          (int)swPropertyManagerPageOptions_e.swPropertyManagerOptions_CancelButton;

            handler        = new PMPHandler(userAddin);
            swPropertyPage = (IPropertyManagerPage2)iSwApp.CreatePropertyManagerPage("Estrusion PMP", options, handler, ref errors);
            if (swPropertyPage != null && errors == (int)swPropertyManagerPageStatus_e.swPropertyManagerPage_Okay)
            {
                try
                {
                    AddControls();
                }
                catch (Exception e)
                {
                    iSwApp.SendMsgToUser2(e.Message, 0, 0);
                }
            }
        }
 /// <summary>
 /// For every command added above, you need to have a callback method.  This is where you do your work.
 /// </summary>
 public void ExecuteAction()
 {
     _swApp.SendMsgToUser2("Addin loaded!", (int)swMessageBoxIcon_e.swMbInformation, (int)swMessageBoxBtn_e.swMbOk);
 }
Example #4
0
        public void GetXML()
        {
            //iSwApp.CommandInProgress = true;
            ModelDoc2   swModel;
            AssemblyDoc swAssy;
            List <Comp> coll;
            XDocument   doc;
            XElement    xml, transaction, project, configurations, configuration, documents, components, component;

            int           errors   = 0;
            int           warnings = 0;
            string        fileName; // GetOpenFileName
            string        path;
            List <string> conf;

            string[] сonfNames;
            swModel = (ModelDoc2)iSwApp.ActiveDoc;
            if (swModel == null)
            {
                fileName = iSwApp.GetOpenFileName("Выберите сборку", "", "SLDASM Files (*.SLDASM)|*.SLDASM|", out _, out _, out _);
                //Проверяем путь
                if (fileName == "")
                {
                    return;
                }
                swModel = (ModelDoc2)iSwApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);
            }

            //Проверяем открыта сборка или нет
            if ((swModel.GetType() != 2) | (swModel == null))
            {
                iSwApp.SendMsgToUser2("Откройте сборку", 4, 2);
                return;
            }

            //iSwApp.UnloadAddIn(sAddinName);
            fileName       = swModel.GetPathName();
            doc            = new XDocument(new XDeclaration("1.0", "Windows-1251", "Yes"));
            xml            = new XElement("xml");
            transaction    = new XElement("transaction", new XAttribute("Type", "SOLIDWORKS"), new XAttribute("version", "1.2"), new XAttribute("Date", DateTime.Now.ToString("d")), new XAttribute("Time", DateTime.Now.ToString("T")));
            project        = new XElement("project", new XAttribute("Project_Path", fileName), new XAttribute("Project_Name", swModel.GetTitle() + ".SldAsm"));
            configurations = new XElement("configurations");
            сonfNames      = (string[])swModel.GetConfigurationNames();
            conf           = new List <string>(сonfNames);
            conf.Sort();
            ConfigForm f = new ConfigForm(conf);

            f.ShowDialog();
            if (f.conf == null)
            {
                return;
            }

            if (f.conf.Count == 0)
            {
                return;
            }
            iSwApp.UnloadAddIn(sAddinName);
            f.conf.Sort();
            for (int i = 0; i < f.conf.Count; i++)
            {
                swModel.ShowConfiguration2(f.conf[i]);
                swAssy        = (AssemblyDoc)swModel;
                configuration = new XElement("configuration", new XAttribute("name", f.conf[i]));
                coll          = Comp.GetColl((SldWorks)iSwApp);
                //iSwApp.SendMsgToUser2("Всего " + coll.Count, 2, 2);
                documents  = Comp.GetDocuments(swAssy);
                components = new XElement("components");
                foreach (Comp k in coll)
                {
                    component = Comp.GetComponent(k);
                    components.Add(component);
                }
                if (i == 0)
                {
                    configuration.Add(Comp.GetGraphs(swAssy));
                }
                configuration.Add(documents);
                configuration.Add(components);
                configurations.Add(configuration);
                //swModel.ShowConfiguration2(f.conf[0]);
            }

            project.Add(configurations);
            transaction.Add(project);
            xml.Add(transaction);
            doc.Add(xml);
            path = fileName.Substring(0, fileName.Length - 7) + ".xml";
            //iSwApp.SendMsgToUser2(path, 4, 2);
            iSwApp.LoadAddIn(sAddinName);
            doc.Save(path);
            //iSwApp.CommandInProgress = false;
        }
Example #5
0
 public static swMessageBoxResult_e SendMsg2User(this ISldWorks app, string message, swMessageBoxIcon_e icon, swMessageBoxBtn_e buttons)
 {
     return((swMessageBoxResult_e)app.SendMsgToUser2(message, (int)icon, (int)buttons));
 }