Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sheet name to equal active model file name & revision number

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
GKPByDesign
323 Views, 2 Replies

Sheet name to equal active model file name & revision number

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
2 REPLIES 2
Message 2 of 3

@GKPByDesign,

 

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,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 3 of 3

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.

Post to forums  

Technology Administrators


Autodesk Design & Make Report