Hi Inventor Community,
I am currently using the following logic to rename my sheets to the "Part Number - iproperty"
SyntaxEditor Code Snippet
Dim oSheets As Sheets = ThisDrawing.Document.sheets Dim oSheet As Sheet For Each oSheet In oSheets oSheet.activate Dim oDrawingView As DrawingView = oSheet.DrawingViews(1) oModel = ActiveSheet.View(oDrawingView.Name).ModelDocument partnum = iProperties.Value(oModel.DisplayName, "Project", "Part Number") ActiveSheet.Sheet.Name = partnum Next
This works great, but I would like to revise my current rule (but don't know how) to include the Revision Number (from the Part / Assembly iproperty).
Ideally my sheet name would read "Part Number" _REV "Revision Number". e.g. ATA101_REV1
Is this possible?
Solved! Go to Solution.
Solved by mcgyvr. Go to Solution.
This should do it..
I'm in a rush but I think its right..
Let me know if its not and I will fix it.
Dim oSheets As Sheets = ThisDrawing.Document.Sheets Dim oSheet As Sheet For Each oSheet In oSheets oSheet.activate Dim oDrawingView As DrawingView = oSheet.DrawingViews(1) oModel = ActiveSheet.View(oDrawingView.Name).ModelDocument partnum = iProperties.Value(oModel.DisplayName, "Project", "Part Number") oRev = iProperties.Value(oModel.DisplayName, "Project", "Revision Number") ActiveSheet.Sheet.Name = partnum & "_REV" & oRev Next
I was looking to do the exact same operation as the original poster which is to change the sheet names to the respective part number in that sheet.
I created a rule in my drawing template with the exact syntax as previously posted.
However I get the following error while running the rule;
"Object reference not set to an instance of an object."
Any help would be greatly appreciated 🙂
@Anonymous wrote:
I was looking to do the exact same operation as the original poster which is to change the sheet names to the respective part number in that sheet.
I created a rule in my drawing template with the exact syntax as previously posted.
However I get the following error while running the rule;
"Object reference not set to an instance of an object."
Any help would be greatly appreciated 🙂
@Anonymous Have you placed drawing views into each sheet? (That code doesn't have any error checking which it really should)
Can you post your idw file here?
What version of Inventor?
You may have copied/pasted incorrectly too or something..
Yes there are drawing views in the sheet.
Currently using Inventor Professional 2018.
I cannot post my drawing template but here is a screenshot of the code;
@Anonymous wrote:
Yes there are drawing views in the sheet.
Currently using Inventor Professional 2018.
I cannot post my drawing template but here is a screenshot of the code;
@Anonymous The issue is specific to your files.
Have you tried the code with a different drawing/model?
Can you strip out anything proprietary and post the drawing? (Model a simple cube and send a drawing of that and strip out the titleblock or whatever is preventing you from sharing it)
Try this and let us know where it craps out..
Dim oSheets As Sheets = ThisDrawing.Document.Sheets
Dim oSheet As Sheet
MessageBox.Show("Preparing to start the loop", "Step 0")
For Each oSheet In oSheets
MessageBox.Show ("Sheet " & oSheet.Name, "Sheet Name")
oSheet.Activate
Dim oDrawingView As DrawingView = oSheet.DrawingViews(1)
MessageBox.Show("Got a drawing View", "Step 1")
oModel = ActiveSheet.View(oDrawingView.Name).ModelDocument
MessageBox.Show("Got a model document", "Step 2")
partnum = iProperties.Value(oModel.DisplayName, "Project", "Part Number")
MessageBox.Show("Got a part number", "Step 3")
ActiveSheet.Sheet.Name = partnum
Next
Yes I have tried different parts/assemblies, same error message.
I inserted the test code and the last message box displayed prior to receiving the error message was;
Step 2
Got a model document
Would you still need me to post a drawing?
@Anonymous Try this (if this doesn't work then yes please post a drawing)
Dim oSheets As Sheets = ThisDrawing.Document.Sheets
Dim oSheet As Sheet
MessageBox.Show("Preparing to start the loop", "Step 0")
For Each oSheet In oSheets
MessageBox.Show ("Sheet " & oSheet.Name, "Sheet Name")
oSheet.Activate
Dim oDrawingView As DrawingView = oSheet.DrawingViews(1)
MessageBox.Show("Got a drawing View", "Step 1")
oModel = ActiveSheet.View(oDrawingView.Name).ModelDocument
MessageBox.Show("Got a model", "Step 2")
' partnum = iProperties.Value(oModel.DisplayName, "Project", "Part Number")
partnum = oModel.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
MessageBox.Show("Got a part number", "Step 3")
ActiveSheet.Sheet.Name = partnum
Next
Can't find what you're looking for? Ask the community or share your knowledge.