Example #1
0
        protected override void DoAction()
        {
            string myFeatureName = ParseStringForVariable(FeatureName);
            string myInstanceId  = ParseStringForVariable(InstanceId);
            string myItemType    = ParseStringForVariable(ItemType);

            Message("Deleting item \"" + myFeatureName + ":" + myInstanceId + "\"");

            SolidWorks.SelectFeature(SolidWorksDoc, myFeatureName, myInstanceId, myItemType);
            if (!SolidWorksDoc.Extension.DeleteSelection2((int)swDeleteSelectionOptions_e.swDelete_Absorbed | (int)swDeleteSelectionOptions_e.swDelete_Children))
            {
                throw new SolidWorksActionException(this);
            }
        }
Example #2
0
        protected override void DoAction()
        {
            string myFileName = Path.GetFullPath(ParseStringForVariable(FileName));

            Message("Opening file \"" + myFileName + "\"");

            try
            {
                SolidWorksDoc = SolidWorks.OpenFile(myFileName);
            }
            catch (SolidWorksException e)
            {
                throw new SolidWorksActionException(e, this);
            }
        }
Example #3
0
        /// <summary>
        /// Cleans up the SolidWorks instance
        /// </summary>
        public static void TearDown()
        {
            // If we have an reference...
            if (SolidWorks != null)
            {
                // Log it
                Logger.LogDebugSource($"Disposing SolidWorks COM reference...");

                // Dispose SolidWorks COM
                SolidWorks?.Dispose();
            }

            // Set to null
            SolidWorks = null;
        }
Example #4
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();
            }
        }
Example #5
0
        /// <summary>
        /// Called when SolidWorks is about to unload our add-in and wants us to do our disconnection logic
        /// </summary>
        /// <returns></returns>
        public bool DisconnectFromSW()
        {
            // Inform listeners
            DisconnectedFromSolidWorks();

            // And plug-in domain listeners
            PlugInIntegration.DisconnectedFromSolidWorks();

            // Clean up plug-in app domain
            PlugInIntegration.Teardown();

            // Dipose SolidWorks COM
            SolidWorks?.Dispose();
            SolidWorks = null;

            // Return ok
            return(true);
        }
        private MemoryStream GetSolidWorksZipStream(Material material, IList <Property> properties)
        {
            bool isSteel = material.MaterialInfo.TypeId == 710 ? true : false;

            IList <ExportPropertyGeneral> propertiesMapped = MapProperites(properties, material.MaterialInfo.SourceId);

            XDocument    sldmat = SolidWorks.FillXMLSolidWork(material.MaterialInfo.Standard, material.MaterialInfo.Name, isSteel, propertiesMapped);
            MemoryStream memoryStreamSolidWorks = new MemoryStream();
            TextWriter   twSolidWorks           = new StreamWriter(memoryStreamSolidWorks);

            twSolidWorks.Write(System.Text.ASCIIEncoding.ASCII.GetString(Encoding.ASCII.GetBytes(sldmat.ToString())));
            twSolidWorks.Flush();
            MemoryStream zipStreamSolidWorks = new MemoryStream();

            using (ZipFile zip = new ZipFile())
            {
                memoryStreamSolidWorks.Seek(0, SeekOrigin.Begin);
                zip.AddEntry("SolidWorks " + material.MaterialInfo.Name.Replace("/", "") + " " + material.MaterialInfo.Standard.Replace("-", "") + ".sldmat", memoryStreamSolidWorks);
                zip.Save(zipStreamSolidWorks);
            }
            return(zipStreamSolidWorks);
        }
Example #7
0
        protected override void DoAction()
        {
            string myComponentName = ParseStringForVariable(ComponentName);
            string myInstanceId    = ParseStringForVariable(InstanceId);
            string myConfigName    = ParseStringForVariable(ConfigName);

            Message("Setting component \"" + myComponentName + ":" + myInstanceId + "\" to reference configuration \"" + myConfigName + "\"");

            if (!(SolidWorksDoc is AssemblyDoc))
            {
                throw new SolidWorksActionException("Cannot set component config because current document is not an assembly.", this);
            }
            SolidWorks.SelectFeature(SolidWorksDoc, myComponentName, myInstanceId, "COMPONENT");
            var selectionMgr = SolidWorksDoc.SelectionManager as SelectionMgr;

            if (selectionMgr != null)
            {
                var component = selectionMgr.GetSelectedObjectsComponent2(1) as Component2;
                if (component != null)
                {
                    component.ReferencedConfiguration = myConfigName;
                }
            }
        }
 public ModifyTableNotifyEventArgs (SolidWorks.Interop.sldworks.TableAnnotation TableAnnotation, System.Int32 TableType, System.Int32 reason, System.Int32 RowInfo, System.Int32 ColumnInfo, System.String DataInfo)
 {
     this.TableAnnotation = TableAnnotation;
     this.TableType = TableType;
     this.reason = reason;
     this.RowInfo = RowInfo;
     this.ColumnInfo = ColumnInfo;
     this.DataInfo = DataInfo;
 }
 public InsertTableNotifyEventArgs (SolidWorks.Interop.sldworks.TableAnnotation TableAnnotation, System.String TableType, System.String TemplatePath)
 {
     this.TableAnnotation = TableAnnotation;
     this.TableType = TableType;
     this.TemplatePath = TemplatePath;
 }
        /// <summary>
        /// Pull the description string from a part/assembly in a View.
        /// </summary>
        /// <param name="v">A View object.</param>
        /// <returns>A description string.</returns>
        public static string get_description(SolidWorks.Interop.sldworks.View v)
        {
            ModelDoc2 md = (ModelDoc2)v.ReferencedDocument;
              ConfigurationManager cfMgr = md.ConfigurationManager;
              Configuration cf = cfMgr.ActiveConfiguration;

              CustomPropertyManager gcpm = md.Extension.get_CustomPropertyManager(string.Empty);
              CustomPropertyManager scpm;

              string _value = "PART";
              string _resValue = string.Empty;
              bool wasResolved;
              bool useCached = false;

              if (cf != null) {
            scpm = cf.CustomPropertyManager;
              } else {
            scpm = gcpm;
              }
              int res;

              res = gcpm.Get5("Description", useCached, out _value, out _resValue, out wasResolved);
              if (_value == string.Empty) {
            res = scpm.Get5("Description", useCached, out _value, out _resValue, out wasResolved);
              }
              return _value;
        }