Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting custom properties from solidworks files

Status
Not open for further replies.

pag2010

Mechanical
Oct 5, 2010
3
Hi,

I need to extract the custom properties for 2000-3000 soldiworks files ,preferably in a excel .Please let me know what is the best way to do this. If somebody has some program available for this ,would really appreaciate it.

Thanks,
pag
 
Replies continue below

Recommended for you

Thanks fcsuoer for the reply . But these options are good for populating the custom properties for the solidworks file. I want to extract a fixed set of properties for these 2000 files. It's like if I select a folder , the program should select all the solidworks files from it ,and populate the description custom property from the files in a excel.Also all this should happen without opening the files. I am very new to customizations , so not able to figure out a way for this . I will appreciate inputs on this.

Regards,
pag
 
do you have a pdm system?

Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2010 SP 3.1
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
3D Connexion-SpaceExplorer
 
No ...these files are currently outside the pdm....but we do have smarteam...
 
can you batch dump the files into a folder in smart team, and then extract the properties from there?

Colin Fitzpatrick (aka Macduff)
Mechanical Designer
Solidworks 2010 SP 3.1
Dell 490 XP Pro SP 2
Xeon CPU 3.00 GHz 3.00 GB of RAM
nVida Quadro FX 3450 512 MB
3D Connexion-SpaceExplorer
 
Here is a very simple macro that should do what you want. It'll dump the info to a CSV, then you can open it in Excel and save it as an Excel file. If there are any commas in your descriptions and/or filenames, it may take some massaging to clean it up.

There is a way to do this without opening the files, but it requires installing somet stuff, and it's a bit trickier. This macro opens the parts, but won't load them into memory.

Make sure you change the paths to what you need them to be. Also, this is currently for .SLDPRT files. If you want drawings or assemblies, you just have to change to .SLDPRT to .SLDDRW or .SLDASM.


Dim Part As SldWorks.ModelDoc2

Sub main()

Set swApp = Application.SldWorks

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("C:\File.csv", True)

FileName = Dir("C:\*.SLDPRT")
visibility = swApp.DocumentVisible(False, swDocPART)
a.writeline ("Part Number" & "," & "Description")

Do While FileName <> ""
Set Part = swApp.OpenDoc("C:\" & FileName, swDocPART)
Description = Part.GetCustomInfoValue("", "DESCRIPTION")
a.writeline (FileName & "," & Description)
swApp.CloseDoc FileName
FileName = Dir
Loop

visibility = swApp.DocumentVisible(True, swDocPART)

End Sub
 
The macro above does load them into memory. They just won't get a graphics window.

-handleman, CSWP (The new, easy test)
 
Whoops, that's what I meant to say...

It is possible to get the custom properties (as long as they're not configuration specific) using a vbsript file you create in notepad, but it requires installing some .dll file that's actually for reading Office documents. It was a long time ago, and our IT whiz-kid figured it out, but I do know for a fact I didn't need SolidWorks open to do it.
 
There is also the Document Manager API which is part of SolidWorks. I think it allows access to the configuration specific properties. However, one needs to request a license key from SolidWorks to include in any macro.

It is not too much of a hassle to get, but if you are only going to do this once, code like what gopack13 posted should suffice. It is not the fastest way to do it, but you could run it overnight or over the weekend.

Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor