/// <summary>
        /// Adds or modifies a custom property.
        /// </summary>
        internal static SolidEdgeFileProperties.Property InternalUpdateCustomProperty(this SolidEdgeFileProperties.PropertySets propertySets, string propertyName, object propertyValue)
        {
            SolidEdgeFileProperties.Properties customPropertySet = null;
            SolidEdgeFileProperties.Property   property          = null;

            try
            {
                // Get a reference to the custom property set.
                customPropertySet = (SolidEdgeFileProperties.Properties)propertySets["Custom"];

                // Attempt to get the custom property.
                property = (SolidEdgeFileProperties.Property)customPropertySet[propertyName];

                // If we get here, the custom property exists so update the value.
                property.Value = propertyValue;
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                // If we get here, the custom property does not exist so add it.
                property = (SolidEdgeFileProperties.Property)customPropertySet.Add(propertyName, propertyValue);
            }
            catch
            {
                throw;
            }

            return(property);
        }
Beispiel #2
0
        public static CadPart ParseItem(string partCachePath)
        {
            SolidEdgeFileProperties.PropertySets propertySets = null;
            SolidEdgeFileProperties.Properties   properties   = null;
            SolidEdgeFileProperties.Property     JDE          = null;
            SolidEdgeFileProperties.Property     REVISION     = null;
            //SolidEdgeFileProperties.Property FILENAME = 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["ProjectInformation"];

                //// Jde
                JDE = (SolidEdgeFileProperties.Property)properties["Document Number"];

                //// Revision
                REVISION = (SolidEdgeFileProperties.Property)properties["Revision"];

                //// filename
                string filename = System.IO.Path.GetFileName(partCachePath);

                // formatting for json extraction
                var part = new CadPart
                {
                    JdeNumber = (string)JDE.Value,
                    Revision  = (string)REVISION.Value,
                    Filename  = filename
                };

                return(part);

                //Console.WriteLine(JDE.Value);
                //Console.WriteLine(REVISION.Value);
                //Console.WriteLine(filename);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
                var part = new CadPart
                {
                    JdeNumber = null,
                    Revision  = null,
                    Filename  = null
                };

                return(part);
            }
        }
Beispiel #3
0
        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);
                }
            }
        }