Rename the sheet with property name

Hi all.

I am looking in vain for a solution to link the name of my drawing sheet to an existing personal property.

I tried in vain to call it in the name of the sheet with the $PRPSHEET: " REFERENCE " but it doesn't seem to work.

I know that I would succeed in doing it via a macro but if I can do this directly in my MEP template it would avoid additional manipulations in the MEP.

Has any of you managed to solve this.

Thank you in advance.

A. Mendes

Hello, I don't think it's possible directly...
While waiting for another answer, here's a macro to start with:
(Gleaned from the Solidworks forum)

' Written by: Deepak Gupta (http://gupta9665.wordpress.com/)

' ------------------------------------------------------------------------------

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.ModelDoc2
Dim swSheet As SldWorks.Sheet
Dim swModelview2 As Configuration
Dim ConfigName As String
Dim vSheets As Variant
Dim swView As SldWorks.View
Dim ConfigProperty As String
Dim i As Integer

Sub main()

Set swApp = Application.SldWorks
Set swDraw = swApp.ActiveDoc

' Is a drawing document active?

If swDraw Is Nothing Then
    swApp.SendMsgToUser2 "A drawing document must be open and the active document.", swMbWarning, swMbOk

    Exit Sub

End If

' Is it a drawing document?

If swDraw.GetType <> SwConst.swDocDRAWING Then
    swApp.SendMsgToUser2 "A drawing document must be open and the active document.", swMbWarning, swMbOk

    Exit Sub

End If

    vSheets = swDraw.GetSheetNames

        For i = 1 To swDraw.GetSheetCount

        swDraw.ActivateSheet vSheets(i - 1)

Set swSheet = swDraw.GetCurrentSheet
Set swView = swDraw.GetFirstView
Set swView = swView.GetNextView
Set swModel = swView.ReferencedDocument

ConfigName = swView.ReferencedConfiguration

' Replace Kod with the required configuration property.

ConfigProperty = swModel.CustomInfo2(ConfigName, "Kod")

swSheet.SetName ConfigProperty

Next i

Set swModel = Nothing

swDraw.EditRebuild3
swDraw.Save2 False    

End Sub

Kind regards

1 Like

Hello

I suggest that you click on the :+1:t2: of this improvement idea:
Allow Linking Sheet Names to Custom Properties (3ds.com)

1 Like

I've broken my nose so many times on this kind of API request...
Never managed to attach a macro to a file type.

Otherwise on this post you can find clues normally ...

But I find these macros more complex, I've never managed to put one :frowning: