Community
Hey I had this code solved on here before which grabs the active model's file name to name the sheet the same name, I now want to add the revision to the file name: eg File name & "-" & Rev number. I know illogic well, but logic in drawings is hard!
Sub Main() 'Purpose: Push file name to sheet name '21-Sept-16 Dim oDoc As Document = ThisApplication.ActiveDocument Dim oSheet As Sheet Dim oDrawingView As DrawingView 'Iterate through sheets For Each oSheet In oDoc.Sheets 'Grab the first drawing view on the sheet oDrawingView = oSheet.DrawingViews(1) 'Grab the model of the first drawing view oModel = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument 'Assign the sheet name based off of the file name, with the path and extension removed oSheet.Name = System.IO.Path.GetFileNameWithoutExtension(oModel.FullFileName) & "-" & o_iProp Next End Sub
Solved! Go to Solution.
Solved by GKPByDesign. Go to Solution.
Try below iLogic code to rename the sheet.
Sub Main() 'Purpose: Push file name to sheet name '21-Sept-16 Dim oDoc As Document = ThisApplication.ActiveDocument Dim oSheet As Sheet Dim oDrawingView As DrawingView 'Iterate through sheets For Each oSheet In oDoc.Sheets 'Grab the first drawing view on the sheet oDrawingView = oSheet.DrawingViews(1) 'Grab the model of the first drawing view Dim oModel As Document oModel = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument Msgbox("1") Dim oRev As String oRev = oModel.PropertySets.Item("Inventor Summary Information").Item("Revision Number").Value 'Assign the sheet name based off of the file name, with the path and extension removed oSheet.Name = System.IO.Path.GetFileNameWithoutExtension(oModel.FullFileName) & "-" & oRev Next End Sub
Thanks and regards,
Hey the code almost worked, but you had a rouge bit of code to show a message box?
Sub Main() 'Purpose: Push file name to sheet name '21-Sept-16 Dim oDoc As Document = ThisApplication.ActiveDocument Dim oSheet As Sheet Dim oDrawingView As DrawingView 'Iterate through sheets For Each oSheet In oDoc.Sheets 'Grab the first drawing view on the sheet oDrawingView = oSheet.DrawingViews(1) 'Grab the model of the first drawing view Dim oModel As Document oModel = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument Dim oRev As String oRev = oModel.PropertySets.Item("Inventor Summary Information").Item("Revision Number").Value 'Assign the sheet name based off of the file name, with the path and extension removed oSheet.Name = System.IO.Path.GetFileNameWithoutExtension(oModel.FullFileName) & "-" & oRev Next End Sub
Can't find what you're looking for? Ask the community or share your knowledge.