Example #1
0
 protected override void DoAction()
 {
     foreach (ModelDoc2 doc in SolidWorksWrapper.GetOpenDocuments())
     {
         if (SaveChanges)
         {
             const int options = (int)swSaveAsOptions_e.swSaveAsOptions_Silent |
                                 (int)swSaveAsOptions_e.swSaveAsOptions_SaveReferenced;
             int  errs = 0, warnings = 0;
             bool saved = doc.Save3(options, ref errs, ref warnings);
             if (!saved || errs != 0)
             {
                 throw new SolidWorksActionException(this);
             }
         }
         if (doc.GetSaveFlag())
         {
             AskEventEnums.DialogResult result =
                 Ask(string.Format("Closing {0} without saving changes.", SolidWorksDoc.GetPathName()),
                     "Closing document", AskEventEnums.AskType.OKCancel);
             if (result == AskEventEnums.DialogResult.Cancel)
             {
                 return;
             }
         }
         SolidWorksDoc.Quit();
     }
 }
Example #2
0
 protected override void DoAction()
 {
     SolidWorksWrapper.SelectFeature(SolidWorksDoc, FeatureName, InstanceID, ItemType);
     if (!SolidWorksDoc.Extension.DeleteSelection2((int)swDeleteSelectionOptions_e.swDelete_Absorbed | (int)swDeleteSelectionOptions_e.swDelete_Children))
     {
         throw new SolidWorksActionException(this);
     }
 }
Example #3
0
        protected override void InitAction()
        {
            SolidWorks = SolidWorksWrapper.Instance;

            Object obj;

            Variables.TryGetValue(SolidWorksDocVar, out obj);
            SolidWorksDoc = obj as ModelDoc2;
        }
Example #4
0
 protected override void DoAction()
 {
     try
     {
         SolidWorksDoc = SolidWorksWrapper.OpenFile(Filename);
     }
     catch (SolidWorksException e)
     {
         throw new SolidWorksActionException(e, this);
     }
 }
Example #5
0
 protected override void DoAction()
 {
     SolidWorksWrapper.SelectFeature(SolidWorksDoc, FeatureName, InstanceID, ItemType);
     if (Suppress)
     {
         SolidWorksDoc.EditSuppress();
     }
     else
     {
         SolidWorksDoc.EditUnsuppress();
     }
 }
Example #6
0
        protected override void DoAction()
        {
            if (!(SolidWorksDoc is AssemblyDoc))
            {
                throw new SolidWorksActionException("Cannot set component config because current document is not an assembly.", this);
            }
            SolidWorksWrapper.SelectFeature(SolidWorksDoc, ComponentName, InstanceID, "COMPONENT");
            var selectionMgr = (SelectionMgr)SolidWorksDoc.SelectionManager;
            var component    = (Component2)selectionMgr.GetSelectedObjectsComponent2(1);

            component.ReferencedConfiguration = ConfigName;
        }
Example #7
0
 public SolidWorksActionException(Exception inner, Action action)
     : base(String.Format("Error from Solidworks:\n{0}",
                          String.Join("\n", SolidWorksWrapper.GetErrors())), inner, action)
 {
 }
Example #8
0
 protected override void DoAction()
 {
     SolidWorksWrapper.Quit();
 }
// ReSharper disable UnusedMember.Global
        public SolidWorksException()
            : base(String.Format("Error from Solidworks:\n{0}",
                                 String.Join("\n", SolidWorksWrapper.GetErrors())))
        {
        }