SolidWorks Properties

Hello

Without MyCAD Utilities (otherwise it's too easy!!!) I'd like to know if there is a possibility to bulk extract one or more custom properties from SolidWorks parts.

Yes under VB.Net if you know I can give you some pieces of codes that I used to :)

1 Like

Yes I want to, it would be nice.

Thank you

Hello

There was a tutorial on a VBA code for that.

http://www.lynkoa.com/tutos/import-export-formats-neutres/macro-solidworks-exporter-les-propri%C3%A9t%C3%A9s-personnalis%C3%A9e-vers-exce

1 Like

It is indeed this macro but it does not process bulk files and I am forced to open SolidWorks.

I wish I could do it without opening SolidWorks.

1 Like

I don't use this code anymore but  at the time it worked kept me informed

    ''' <summary>
    ''' Renvoi la propriete selectionner dans un fichier Solidworks Donnée
    ''' swSumInfoTitle = 0
    ''' swSumInfoSubject = 1
    ''' swSumInfoAuthor = 2
    ''' swSumInfoKeywords = 3
    ''' swSumInfoComment = 4
    ''' swSumInfoSavedBy = 5
    ''' swSumInfoCreateDate = 6
    ''' swSumInfoSaveDate = 7
    ''' swSumInfoCreateDate2 = 8
    ''' swSumInfoSaveDate2 = 9
    ''' </summary>
    ''' <param name="File">Fichier a controller</param>
    ''' <param name="PropNumber">Type d'info a recupere</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function ReadProperties(File As String, PropNumber As Integer) As String
        If File = Nothing Or PropNumber = Nothing Then Return Nothing
        Dim swDocSpecification As SldWorks.DocumentSpecification = swApp.GetOpenDocSpec(File)
        swDocSpecification.Silent = True : swDocSpecification.ReadOnly = True : swApp.OpenDoc7(swDocSpecification)
        Dim swModel As ModelDoc2 = swApp.ActiveDoc
        Dim Properties As String = swModel.SummaryInfo(PropNumber)
        swApp.CloseDoc(File) 'Fermeture de la piece
        If Not Properties = Nothing Then Return Properties Else Return Nothing
    End Function

    ''' <summary>
    ''' Inscrit la propriete selectionner dans un fichier Solidworks Donnée
    ''' swSumInfoTitle = 0
    ''' swSumInfoSubject = 1
    ''' swSumInfoAuthor = 2
    ''' swSumInfoKeywords = 3
    ''' swSumInfoComment = 4
    ''' </summary>
    ''' <param name="File">Fichier a éditer</param>
    ''' <param name="PropNumber">Type d'info a renseigner</param>
    ''' <param name="PropValue">Info a renseigner</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function WriteProperties(File As String, PropNumber As Integer, PropValue As String) ' As String
        Dim swDocSpecification As SldWorks.DocumentSpecification = swApp.GetOpenDocSpec(File)
        swDocSpecification.Silent = True : swDocSpecification.ReadOnly = False : swApp.OpenDoc7(swDocSpecification)
        Dim swModel As ModelDoc2 = swApp.ActiveDoc
        swModel.SummaryInfo(PropNumber) = PropValue
        Dim fileerror, filewarning As Integer
        swModel.Save3(SwConst.swSaveAsOptions_e.swSaveAsOptions_Silent, fileerror, filewarning)
        swApp.CloseDoc(File) 'Fermeture de la piece
        Return Nothing
        'If ReadProperties(File, PropNumber) = PropValue Then Return PropValue Else Return Nothing
    End Function
    Delegate Sub dEditDrawingProperties(DrawingToEdit As String)
    Function EditDrawingProperties(DrawingToEdit As String)
        Dim swDmDoc As SwDocumentMgr.ISwDMDocument18 = swDmGetDocument(DrawingToEdit, False) 'Ouverture du document
        'MAJ propriété général
        swDmSetCustomProperty(swDmDoc, "LBM_DWG", Regex.Match(DrawingToEdit, "N°([0-9]+)-0.SLDDRW", RegexOptions.IgnoreCase).Groups(1).Value, SwDocumentMgr.SwDmCustomInfoType.swDmCustomInfoText)
        swDmSetCustomProperty(swDmDoc, "LBM_REV", "0", SwDocumentMgr.SwDmCustomInfoType.swDmCustomInfoText)
        swDmSetCustomProperty(swDmDoc, "LBM_REV1", "0", SwDocumentMgr.SwDmCustomInfoType.swDmCustomInfoText)
        swDmSetCustomProperty(swDmDoc, "LBM_DATE1", Dateddmmyy, SwDocumentMgr.SwDmCustomInfoType.swDmCustomInfoText)
        swDmSetCustomProperty(swDmDoc, "LBM_MEMO1", "First Issue", SwDocumentMgr.SwDmCustomInfoType.swDmCustomInfoText)
        swDmSetCustomProperty(swDmDoc, "LBM_ISSUED1", User(), SwDocumentMgr.SwDmCustomInfoType.swDmCustomInfoText)
        swDmSetCustomProperty(swDmDoc, "LBM_PROJECT", DrawingToEdit.Split(New Char() {"\"c})(5), SwDocumentMgr.SwDmCustomInfoType.swDmCustomInfoText)
        swDmDoc.Save() : swDmDoc.CloseDoc() 'Sauvegarde du document'Fermeture du document
        Return Nothing
    End Function

Otherwise look at the swDocMgr http://help.solidworks.com/2016/english/api/swdocmgrapi/get_configuration_information_example_vbnet.htm

1 Like

Hi flegendre,

To access the properties of SW files without opening them, you must use the Document Manager API.

As mentioned in the help, you must apply for a free license by logging in to your SW customer area.

Then in "My Support" click on "API Assistance". Then on " Document Manager Key Request "

You will be asked for information about your company and for what purpose you wish to use this license.

There are rainy access levels. We use the Basic and Preview features. Which is more than enough.

You will receive an email with your license number that must be integrated into your code. You will have to make this request every year to access the SW files with the new version, and therefore modify the key in your code.

Have you ever coded in Vb.Net?

Do you already use an EDI?

What do you want to do in detail?

 

Have a nice day

 

2 Likes

@remrem,

Personally I don't program but my engineer colleague knows how to code in VBA.

What is EDI?

What I want to do exactly is this:

I would like to be able to do 2 things (without opening SoloidWorks):

  •  list the custom properties of the SW parts present in a single directory, send them to an Excel file (to be able to sort them by type of properties)
  • Be able to search via one or more properties from a SW parts directory

 

 

1 Like

An IDE is an "Integrated Development Environment".

Personally, I use Visual Studio. But there are many others. This allows you to create a small app that then installs like any other app.

Do you want to list all the properties of each file or do you already know the name of the properties you want to read?

Want to read the properties of .sldprt, sldasm, and and slddw?

Be careful, the Vb.net is still very different from the VBA.

3 Likes

"Want to read the properties of .sldprt, sldasm, and and slddrw?"

I only want to read the properties of SLDPRT parts

"Do you want to list all the properties of each file or do you already know the name of the properties you want to read?"

In case N°1, I want to list "stupidly" all the properties of each part.

Example: I want to list all the parts with the value FUNVISIO in one of the properties.

In case N°2, I know the names of the properties and I want to quickly highlight the one with a known value.

Example: I want to list all the parts with the property Material = Alu