Reply
Solved! Go to solution

Get the files properties from a .par without having solid edge install

Hi

 

So my problem is that i try to write a program in C#  to get the custom file propertie of a .par (like the length, width, etc ... ) but i haven't solid edge on this pc i got the file from another pc on our network. Is there a way to get the properties without using solid edge. 

 

i am using this line of code to get the file property :

application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
// Get a reference to the active document
document = (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;
// Get a reference to the document's property sets collection
propertySets = (SolidEdgeFramework.PropertySets)document.Properties;

 

Thanks for your help.

 

5 REPLIES

Re: Get the files properties from a .par without having solid edge install

[ Edited ]

Hi CM, welcome to the forum.

 

You can use the File Properties API or the Revision Manager which is a part of Solid Edge, only that Solid Edge may not be required to be running to extract custom properties, though SE must be installed on the PC.

 

At the bottom of this page are links, titled Recommendations, which most probably contain the answer you are seeking, like this one.

 

Else, at the top of the page is the search box where you can use keywords like 'custom file properties revision manager' that will give you more hints and possibly code snippets.

 

If you still don't get the answer, post an update here.

 

Best Wishes,

Tushar Suradkar

www.SurfAndCode.in

 

Re: Get the files properties from a .par without having solid edge install

[ Edited ]

Thanks for your answer, i will try that, just need to install SE on my pc

Solution
Solution
Accepted by topic author CM
‎08-26-2015 04:32 AM

Re: Get the files properties from a .par without having solid edge install

[ Edited ]

So i found a solution which doesn't need to launch SE (i don't know if you have to install it or not) EDIT : yes you need it install but you don't have to  launch it. 

here is the code : 

 

if (extension.Equals(".par"))
            {
                
                propertySets.Open(@"" + getreper + "\\" + fichier);//go to the location of my .par file
          
                for (int i = 0; i < propertySets.Count; i++)
                {
                    properties = (SolidEdgeFileProperties.Properties)propertySets[i];//here i get all the property of the file
                    for (int j = 0; j < properties.Count; j++)
                    {
                        property = (SolidEdgeFileProperties.Property)properties[j];//and here just take one property
                        
                        if(properties.Name.ToString().Equals("Custom"))//i take only the custom property
                        {
                            if (property.Name.ToString().Equals("Désignation1"))
                            {
                                 designation = property.Value.ToString();
                            }
                            else if (property.Name.ToString().Equals("Techno"))
                            {
                                matiere = property.Value.ToString();
                            }
                            else if (property.Name.ToString().Equals("Traitement"))
                            {
                                traitement = property.Value.ToString();
                            }
                            else if (property.Name.ToString().Equals("LONG"))
                            {
                                longeur = property.Value.ToString();
                            }
                            else if (property.Name.ToString().Equals("LARG"))
                            {
                                largeur = property.Value.ToString();
                            }
                            else if (property.Name.ToString().Equals("EPAIS"))
                            {
                                epaisseur = property.Value.ToString();
                            }
                            
                        }
                    }
                } 
            

for the using : 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Windows;
using System.Runtime.InteropServices;

i almost forgot the variables : 

SolidEdgeFileProperties.PropertySets propertySets = null;
SolidEdgeFileProperties.Properties properties = null;
SolidEdgeFileProperties.Property property = null;

 

 

not sure all are important but the last one is obligatory. You'll need to add the Interop.Solidedge.dll into your reference.

 

But i still have one problem if i use my method twice on the same file i got on an error on the line : 

   propertySets.Open(@"" + getreper + "\\" + fichier);

which is :  (Exception de HRESULT : 0x80030020 (STG_E_SHAREVIOLATION))

 

EDIT : it happend sometimes also on different files

 

thanks for the help.

CM

Re: Get the files properties from a .par without having solid edge install

[ Edited ]

I think you need to use propertySets.Close() to avoid the share violation error.

 

~Tushar Suradkar

www.SurfAndCode.in

 

Re: Get the files properties from a .par without having solid edge install

 

yeah i think that's it.

 

Thanks for  your help Tushar.

 

CM