コード例 #1
0
        ///// <summary>
        ///// Returns all property sets as an IEnumerable.
        ///// </summary>
        ///// <param name="propertySets"></param>
        //public static IEnumerable<SolidEdgeFileProperties.Properties> AsEnumerable(this SolidEdgeFileProperties.PropertySets propertySets)
        //{
        //    List<SolidEdgeFileProperties.Properties> list = new List<SolidEdgeFileProperties.Properties>();

        //    foreach (var properties in propertySets)
        //    {
        //        list.Add((SolidEdgeFileProperties.Properties)properties);
        //    }

        //    return list.AsEnumerable();
        //}

        /// <summary>
        /// Closes an open document with the option to save changes.
        /// </summary>
        /// <param name="propertySets"></param>
        /// <param name="saveChanges"></param>
        public static void Close(this SolidEdgeFileProperties.PropertySets propertySets, bool saveChanges)
        {
            if (saveChanges)
            {
                propertySets.Save();
            }

            propertySets.Close();
        }
コード例 #2
0
ファイル: Cache.cs プロジェクト: recs12/PartReplacer
        public static string GetJde(string partCachePath)
        {
            SolidEdgeFileProperties.PropertySets propertySets = null;
            SolidEdgeFileProperties.Properties   properties   = null;
            SolidEdgeFileProperties.Property     property     = null;

            try
            {
                // Create new instance of the PropertySets object
                propertySets = new SolidEdgeFileProperties.PropertySets();

                // Open a file
                propertySets.Open(partCachePath, true);
                // Get a reference to the SummaryInformation properties
                properties = (SolidEdgeFileProperties.Properties)propertySets["Custom"];

                // Get a reference to the Title property by name
                property = (SolidEdgeFileProperties.Property)properties["JDELITM"];



                // TODO: Print the list of available option.
                return(property.Value.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
            finally
            {
                if (property != null)
                {
                    Marshal.ReleaseComObject(property);
                }
                if (properties != null)
                {
                    Marshal.ReleaseComObject(properties);
                }
                if (propertySets != null)
                {
                    propertySets.Close();
                    Marshal.ReleaseComObject(propertySets);
                }
            }
        }
コード例 #3
0
ファイル: SolidEdgeUtils(old).cs プロジェクト: Fred68/Grafica
 // Lista da doc collegato su discio (poi resta in read only)
 public string CreaListaProprietaDaFile(string fullname)
 {
     string msg = "";
     if(DocumentoAperto(fullname))
         {
         return("Documento aperto");
         }
     SolidEdgeFileProperties.PropertySets propertySets3D = null;	// Oggetti proprieta` del 3D
     SolidEdgeFileProperties.Properties properties3D = null;
     FileInfo dis3D = new FileInfo(fullname);				// Crea rif. al file
     if (dis3D.Exists)										// Se il file esiste
         {
         listaProprietaFile.Clear();									// Cancella la lista delle proprieta  attuale
         try
             {
             propertySets3D = new SolidEdgeFileProperties.PropertySets();					// Oggetto PropertySets
             propertySets3D.Open(fullname, true);											// Apre proprieta` file readonly (true)
             properties3D = (SolidEdgeFileProperties.Properties)propertySets3D["Custom"];	// Custom Property Set
             foreach (SolidEdgeFileProperties.Property pr in properties3D)					// Legge le proprieta`
                 {
                 listaProprietaFile.Add(new ProprietaSolidEdge(pr.Name, pr.Value, pr.ID));			// e le mette in una lista
                 if (pr != null)
                     {
                     Marshal.ReleaseComObject(pr);
                     }
                 }
             msg = "Lettura proprieta` completata";
             }
         catch (System.Exception ex)
             {
             msg += ex.Message + " in CreaListaProprietaDaFile()";
             }
         finally													// ATTENZIONE: NON RILASCIA IL FILE 3D, che rimane read-only !
             {
             if (properties3D != null)
                 {
                 Marshal.ReleaseComObject(properties3D);
                 properties3D = null;
                 }
             if (propertySets3D != null)
                 {
                 propertySets3D.Close();							// Chiude il file prima di rilasciare il COM
                 Marshal.ReleaseComObject(propertySets3D);
                 Marshal.FinalReleaseComObject(propertySets3D);
                 propertySets3D = null;
                 }
             GC.Collect();										// Per evitare errore di share violation dopo rilascio dei COM ?
             GC.WaitForPendingFinalizers();						// Ma il file resta aperto.
             }
         }	// fine blocco if(dis3D.Exists)
     else
         {
         msg = "File inesistente";
         }
     return msg;
 }