- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was wondering if someone could write an iLogic code that would rename a drawing sheet name to match the file name of the part detailed on that sheet. In this case, there would only be one part per sheet, ( no multiple parts per sheet), however, the first few sheets might have assembly views. so the code would need to only rename sheets that has parts only, not assemblies.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
Run this iLogic rule in your drawing:
This rule will rename the sheet name to the name of the model (part or assembly) present in the main view of each sheet.
If ThisApplication.ActiveDocument.DocumentType <> kDrawingDocumentObject Then MessageBox.Show("Please run this rule from the Multi-Sheet DRAWING file.", "iLogic") Exit Sub End If 'ilogic rule renames each drawing sheet to first part/model/ipn/etc view inserted into each drawing sheet 'Purpose: Push file name to sheet name Dim oDoc As Document oDoc = ThisApplication.ActiveDocument Dim oSheets As Sheets oSheets = oDoc.Sheets Dim oSheet As Sheet Dim oDrawingView As DrawingView 'Iterate through sheets For Each oSheet In oSheets Try '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) Catch 'There is no drawing views End Try Next InventorVb.DocumentUpdate()
Tip:
You can add this rule to your template and start to use it in the new files, or use it as an external rule to use it when you like in any drawing.
I use it as an external Rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Many thanks for sharing this awesome code.
Could you set this code to rename sheets from custom iProperties ?