Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
2339 Views, 8 Replies

Change Drawing Sheet name to match active file name

I currently have a drawing template that picks up the file of the part on that particular sheet. So i have "part A" on "sheet 1", the file name for "sheet 1" is "part a" - i then have "part b" on "sheet 2", therefore the file name for "sheet 2" is "part b."

 

Now with this in mind i need to modify this code (below) which automatically fills in the sheet name (eg sheet 1, sheet 2, sheet 3, etc) with the relevant part number. But i need to modify it so it picks up the active sheet file name. If i modify the code and put in the " iProperties.Value("Project", "Project") " it picks up the drawing file, and not the part on that drawing. Can someone help by making the code below pick up model information on the active sheet.

 

Sub Main
If TypeOf ThisDoc.Document Is DrawingDocument Then
Dim dwgDoc as DrawingDocument = ThisDoc.Document
For Each dwgSheet As Sheet In dwgDoc.Sheets
If dwgSheet.DrawingViews.Count > 0 Then
modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName
modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
prtNumber = modelDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(5).Value
If Not String.IsNullOrEmpty(prtNumber) Then
dwgSheet.Name = prtNumber
End If
End If
Next
End If
End Sub

 

 

 The information i need to have automatically filled is the code below, but it must be looking at the active sheet file name and not the documemnt file name. Hopefully i've made sense

 

SyntaxEditor Code Snippet

SyntaxEditor Code Snippet
Sub Main
If TypeOf ThisDoc.Document Is DrawingDocument Then
Dim dwgDoc as DrawingDocument = ThisDoc.Document
For Each dwgSheet As Sheet In dwgDoc.Sheets
If dwgSheet.DrawingViews.Count > 0 Then
modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName
modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
prtNumber = modelDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(5).Value
If Not String.IsNullOrEmpty(ThisDoc.FileName) Then
dwgSheet.Name = ThisDoc.FileName
End If
End If
Next
End If
End Sub