Displayname code issue

Displayname code issue

alex_hiis6PJP6
Enthusiast Enthusiast
189 Views
1 Reply
Message 1 of 2

Displayname code issue

alex_hiis6PJP6
Enthusiast
Enthusiast

Hi

 

I have this code snippet that I have been using to overwrite the Displayname of the active document in the model browser. Code works as intended when I trigger it in existing documents but I have a problem with new documents that require an initial save.
Most probably the cause is that Part number is generated after the rule is ran.

Dim oDoc As Document = ThisDoc.Document
 
Try
	oDoc.DisplayName = iProperties.Value("Project", "Part Number") & " (" & iProperties.Value("Custom", "Part Name") & ")"
Catch
	iProperties.Value("Custom", "Part Name") = ""
End Try
 
oDoc.Update

 

My intended use would be to embed the rule into a template file and trigger it when iProperties are changed.

When a user creates a new document, fills out the iProperites (rule trigger), saves and checks the file into Vault the Displayname should be filled like Part number (Part name) (picture).

alex_hiis6PJP6_1-1762935143674.png

 

 

0 Likes
190 Views
1 Reply
Reply (1)
Message 2 of 2

Curtis_Waguespack
Consultant
Consultant

@alex_hiis6PJP6, I think you can use one of these examples to catch the situation where a file has not been saved yet, so that your code does not cause issues due to information that is not yet present.

Hope that helps, Curtis

If ThisDoc.Document.FullFileName = Nothing Then
'do something, or don't do something
End If

 

If ThisDoc.Document.FileSaveCounter = 0 Then 
 'do something, or don't do something
End If

 

0 Likes