Exemplo n.º 1
0
        protected override void DoAction()
        {
            string filename = Path.GetFullPath(Filename);

            //tidy appearance
            SolidWorksDoc.ViewDisplayShaded();
            SolidWorksDoc.ShowNamedView2("*Isometric", -1);
            SolidWorksDoc.ViewZoomtofit2();

            var options = (int)swSaveAsOptions_e.swSaveAsOptions_Silent + (SaveAsCopy
                                                ? (int)swSaveAsOptions_e.swSaveAsOptions_Copy
                                                : 0);

            string path = Path.GetDirectoryName(filename);

            if (path != null && !Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }


            int  errs = 0, warns = 0;
            bool success = SolidWorksDoc.SaveAs4(filename, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, options,
                                                 ref errs, ref warns);

            if (!success)
            {
                throw new SolidWorksActionException(this);
            }
        }
Exemplo n.º 2
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();
     }
 }
Exemplo n.º 3
0
        protected override void DoAction()
        {
            var dimension = SolidWorksDoc.Parameter(DimensionName) as Dimension;

            if (dimension == null)
            {
                throw new SolidWorksActionException(String.Format("Dimension named {0} not found", DimensionName), this);
            }
            if (dimension.ReadOnly)
            {
                //Message(String.Format("Changed dimension {0} is read only.", DimensionName));
            }

            Double val;

            if (!Double.TryParse(Value, out val))
            {
                throw new SolidWorksActionException(String.Format("Invalid Value for value: {0}", Value), this);
            }
            if ((swSetValueReturnStatus_e)dimension.SetSystemValue2(val, (int)swSetValueInConfiguration_e.swSetValue_UseCurrentSetting) != swSetValueReturnStatus_e.swSetValue_Successful)
            {
                throw new SolidWorksActionException(this);
            }
            if (dimension.IsAppliedToAllConfigurations())
            {
                //Message("Dimension update was limited to active configuration.");
            }
            if (!SolidWorksDoc.EditRebuild3())
            {
                throw new SolidWorksActionException(this);
            }
        }
Exemplo n.º 4
0
 protected override void DoAction()
 {
     if (!SolidWorksDoc.InsertFamilyTableOpen(Filename))
     {
         throw new SolidWorksActionException(this);
     }
 }
Exemplo n.º 5
0
        protected override void DoAction()
        {
            Message("Closing file: \"" + SolidWorksDoc.GetTitle() + "\"");

            if (SaveChanges)
            {
                const int options = (int)swSaveAsOptions_e.swSaveAsOptions_Silent |
                                    (int)swSaveAsOptions_e.swSaveAsOptions_SaveReferenced;
                int  errs = 0, warnings = 0;
                bool saved = SolidWorksDoc.Save3(options, ref errs, ref warnings);
                if (!saved || errs != 0)
                {
                    throw new SolidWorksActionException(this);
                }
            }
            if (SolidWorksDoc.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();
            SolidWorksDoc = null;
        }
Exemplo n.º 6
0
        protected override void DoAction()
        {
            Message("Rebuilding");

            if (!SolidWorksDoc.ForceRebuild3(TopOnly))
            {
                throw new SolidWorksActionException("Cannot force rebuild", this);
            }
        }
Exemplo n.º 7
0
        protected override void DoAction()
        {
            IEnumerable <String> configNames = (string[])SolidWorksDoc.GetConfigurationNames();
            string activeConfigName          = SolidWorksDoc.ConfigurationManager.ActiveConfiguration.Name;

            foreach (string name in configNames.Where(name => name != activeConfigName))
            {
                SolidWorksDoc.DeleteConfiguration2(name);
            }
        }
Exemplo n.º 8
0
 protected override void DoAction()
 {
     if (((Configuration)SolidWorksDoc.GetActiveConfiguration()).Name == ConfigName)
     {
         return;
     }
     if (!SolidWorksDoc.ShowConfiguration2(ConfigName))
     {
         throw new SolidWorksActionException(this);
     }
 }
Exemplo n.º 9
0
        protected override void DoAction()
        {
            string myFileName = ParseStringForVariable(Filename);

            Message("Inserting design table \"" + myFileName + "\"");

            if (!SolidWorksDoc.InsertFamilyTableOpen(myFileName))
            {
                throw new SolidWorksActionException(this);
            }
        }
Exemplo n.º 10
0
        protected override void DoAction()
        {
            const int options = (int)swSaveAsOptions_e.swSaveAsOptions_Silent |
                                (int)swSaveAsOptions_e.swSaveAsOptions_SaveReferenced;
            int  errs = 0, warnings = 0;
            bool saved = SolidWorksDoc.Save3(options, ref errs, ref warnings);

            if (!saved || errs != 0)
            {
                throw new SolidWorksActionException(this);
            }
        }
Exemplo n.º 11
0
 protected override void DoAction()
 {
     SolidWorksWrapper.SelectFeature(SolidWorksDoc, FeatureName, InstanceID, ItemType);
     if (Suppress)
     {
         SolidWorksDoc.EditSuppress();
     }
     else
     {
         SolidWorksDoc.EditUnsuppress();
     }
 }
Exemplo n.º 12
0
        protected override void DoAction()
        {
            string myConfigName = ParseStringForVariable(ConfigName);

            Message("Setting active configuration to \"" + myConfigName + "\"");

            Configuration configuration = (Configuration)SolidWorksDoc.GetActiveConfiguration();

            if (configuration.Name == myConfigName)
            {
                return;
            }
            if (!SolidWorksDoc.ShowConfiguration2(myConfigName))
            {
                throw new SolidWorksActionException(this);
            }
        }
Exemplo n.º 13
0
        protected override void DoAction()
        {
            string myFeatureName = ParseStringForVariable(FeatureName);
            string myInstanceId  = ParseStringForVariable(InstanceId);
            string myItemType    = ParseStringForVariable(ItemType);

            Message("Setting suppression state of \"" + myFeatureName + ":" + myInstanceId + "\" to " + Convert.ToString(Suppress));

            SolidWorks.SelectFeature(SolidWorksDoc, myFeatureName, myInstanceId, myItemType);
            if (Suppress)
            {
                SolidWorksDoc.EditSuppress();
            }
            else
            {
                SolidWorksDoc.EditUnsuppress();
            }
        }