6 Replies Latest reply on Feb 22, 2018 9:15 AM by Scott Giffin

    How to populate the title in summary information using custom property

    Derek Parks

      I currently have several templates that use custom properties to auto populate the title block with the part or assembly information so I have a basic understanding of mapping. What I need to be able to do is link a custom property name to the title section in the summary tab of the information within a part or assembly. For example in a model I have a custom property name labeled "Description" that I would like to get to auto populate the "Title" section in the Summary tab of the information. This would all occur within a part or assembly model and keep me from having to fill in two separate sections with the same information. It would also be acceptable if I could work this vice versa essentially achieving the same result. Any ideas or other suggestions are appreciated.

        • Re: How to populate the title in summary information using custom property
          Dwight Livingston

          The custom property window won't take string variables.

           

          The equation editor doesn't handle strings.

           

          Design tables don't take any input and can only assign configuration specific properties, not custom properties.

           

          I know of no way to do what you want. I would like to do such things, too, so I could make the drawing file Description equal the model file Description, make a configuration-specific Description equal the file Description plus additional text, and probably other useful stuff.

           

          I'd make an ER but I don't know the best way to phrase it. There are a few ERs in there talking about custom properties and equations, but it seems they are talking about numeric values.

           

          If anyone has a suggestion, or I am wrong in the top three lines above, I'd liek to know.

           

          Thanks

           

          Dwight

          • Re: How to populate the title in summary information using custom property
            Ian McLean

            Yes, I would like to do the same thing.

            It seems strange that Microsoft has all these properties and there seems to be so little interest in using them.

            It seems to be common practice in many organisations to add long winded descriptions to the end of file numbers instead.

            In Windows 7 it seems finally you can add a column in explorer to see Solidworks Description, but it would be nice to have it in the Title column like all other types of file.

              • Re: How to populate the title in summary information using custom property
                Greg Rupp

                It would take a macro to do that. Here is an example of how to set the "Title" equal to the custom property "Description".

                 

                Note, in order to use this, you must install dsofile.dll and add it as a reference.

                 

                Precondition: a solidworks file is open in solidworks and has a custom property "Description".

                Postcondition: active solidworks file is closed, the files title is set equal to the c.p. "Description", the files comment is set.

                 

                 

                Dim swApp As SldWorks.SldWorks

                 

                'Requires DSOFile.dll
                'See microsoft kb 224351


                Sub main()

                Dim swModel As ModelDoc2
                Dim cpm As CustomPropertyManager

                 

                Dim sFilePath As String
                Dim sFileDesc As String
                Dim DSO As DSOFile.OleDocumentProperties
                Set DSO = New DSOFile.OleDocumentProperties

                Set swApp = Application.SldWorks
                Set swModel = swApp.ActiveDoc
                If swModel Is Nothing Then
                    MsgBox "No file open. Exiting."
                    Exit Sub
                End If

                Set cpm = swModel.Extension.CustomPropertyManager("")

                sFilePath = swModel.GetPathName
                sFileDesc = cpm.Get("Desciption")


                swModel.SaveSilent
                swApp.CloseDoc (sFilePath)
                Set swModel = Nothing
                Set swApp = Nothing


                DSO.Open sfilename:=sFilePath
                DSO.SummaryProperties.Comments = "Title set by macro"
                Debug.Print DSO.SummaryProperties.Comments
                DSO.SummaryProperties.Title = sFileDesc

                DSO.Save
                DSO.Close


                End Sub

                  • Re: How to populate the title in summary information using custom property
                    Deepak Gupta

                    I always wonder as what is the need of DSOfile when it can be done without that.

                     

                    Sub main()

                        Dim swApp             As SldWorks.SldWorks

                        Dim swModel          As SldWorks.ModelDoc2

                        Dim swCustProp     As CustomPropertyManager

                        Dim val                   As String

                        Dim valout              As String

                        Dim bool                As Boolean

                     

                        Set swApp = CreateObject("SldWorks.Application")

                        Set swModel = swApp.ActiveDoc

                        Set swCustProp = swModel.Extension.CustomPropertyManager("")

                           

                        bool = swCustProp.Get4("Description", False, val, valout)

                        swModel.SummaryInfo(swSumInfoTitle) = valout

                       

                        swModel.ForceRebuild3 (False)

                        swModel.Save

                     

                    End Sub

                      • Re: How to populate the title in summary information using custom property
                        Greg Rupp

                        Your solution is definately better.

                         

                        I'd go with Deepak's code!

                        • Re: How to populate the title in summary information using custom property
                          Scott Giffin

                          As usual Deepak's code is awesome. Thanks for this one my friend. I'd like to give a little back to the community by sharing my addition to the code of adding the "Author" to the Summary Information assuming the DrawnBy has already been filled in on the custom property field.

                           

                          'Precondition: Document open needing the summary information populated. Custom property fields "Description" and "DrawnBy" must already be filled in

                          'Postcondition: Summary information is filled in

                           

                          Dim swApp As Object
                          Sub main()

                              Dim swApp             As SldWorks.SldWorks
                              Dim swModel          As SldWorks.ModelDoc2
                              Dim swCustProp     As CustomPropertyManager
                              Dim val                   As String
                              Dim valout              As String
                              Dim bool                As Boolean


                              Set swApp = CreateObject("SldWorks.Application")
                              Set swModel = swApp.ActiveDoc
                              Set swCustProp = swModel.Extension.CustomPropertyManager("")

                          'Gets the title information from the description in the custom property field
                              bool = swCustProp.Get4("Description", False, val, valout)
                              swModel.SummaryInfo(swSumInfoTitle) = valout

                              bool = swCustProp.Get4("DrawnBy", False, val, valout)
                              swModel.SummaryInfo(swSumInfoAuthor) = valout
                             
                              swModel.ForceRebuild3 (False)
                              swModel.Save


                          End Sub