I would like to have an iLogic rule that changes the active sheet name to the Models Part Number property.
I tried ActiveSheet.name = iProperties.Value("Project", "Part Number"), but
get an Error: Property 'Name' is 'ReadOnly'.
Any help would be greatly appreciated.
Thanks,
Solved! Go to Solution.
Solved by rjay75. Go to Solution.
http://forums.autodesk.com/t5/Inventor-General/iLogic-to-Change-Sheet-Name/td-p/4581545
"Sheet.Name is a read-write property, setting is as easy as:
Sheet.Name = "My New Sheet Name"
Mike (not Matt) Rattray"
So maybe edit that...?
I got the snippit: ActiveSheet.Sheet.Name = iProperties.Value("Project", "Part Number" to change all the sheet names to the part number of the drawing file iproperty Part number, however...
What I am trying to accomplish is:
I have the assembly view of say a nightstand on sheet 1. On the following sheets I have drawing views for each component (one component per sheet).
I have the Part Number property mapped to my Title Block that populates with the Model property Part Number in each sheet. My rule would need to change the sheet name to that property of the Title block. This would make finding part drawings in the Vault web client a lot easier. And eleviate the manual entry process.
I found this code that works, but it errors out on the sheet that has the assembly view (sheet one). When I deleted the sheet with the assembly view It cycled through and changed the sheet names just fine.
Dim oSheets As Sheets
oSheets = ThisDoc.Document.sheets
Dim oSheet As Sheet
For Each oSheet In oSheets
oSheet.activate
Dim oDrawingView As DrawingView
oDrawingView = oSheet.DrawingViews(1)
oModelName = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
oDesc = iProperties.Value(oModelName, "Project", "Part Number")
oSheet.Name = oDesc
Next
Thanks, Appreciate the help.
Here's some alternate code. Instead looking at the drawing view, and using the display name it just gets the name from the current model being displayed in the first view directly.
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
I’ve been trying to do something like this for the past 3 months without success and this comes very close to what I want. What lines would I need to add to get the “Description” iproperty from the part model and combine it after the “PartNumber” iproperty then use that to rename the drawing sheet?
Thanks for the help.
The other was older code. Here's code to do what you want.
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("Design Tracking Properties").Item("Part Number").Value & " - " & _ modelDoc.PropertySets("Design Tracking Properties").Item("Description").Value If Not String.IsNullOrEmpty(prtNumber) Then dwgSheet.Name = prtNumber End If End If Next End If End Sub
Thank you very much for the quick reply. I'll have to wait until Tuesday when I get back into the office to put this in my template.
Thanks again.
Hi, I have no experiance with I logic, but the code would be incredebly usefull to me.
how do I set up this code in I logic?
Many thanks
Frank
Hi, I have no experiance with I logic, but the code would be incredebly usefull to me.
how do I setup this code in I logic?
Many thanks
Frank
Sorry for my late responce, the allert mail went into my spam folder. This is fantastic, thank you for the advice and the code. If this is posibble that I need to start learning I logic rules and codes. I just changed 180 sheets names with one click of a button, Happy days.
Try this.
Sub Main If TypeOf ThisDoc.Document Is DrawingDocument Then Dim dwgDoc as DrawingDocument = ThisDoc.Document' Dim sheetNames As New Dictionary(Of String, ArrayList) 'Count all the sheets per part 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("Design Tracking Properties").Item("Part Number").Value If Not String.IsNullOrEmpty(prtNumber) Then If Not sheetNames.ContainsKey(prtNumber) Then sheetNames.Add(prtNumber, New ArrayList({1, 0})) Else sheetCount = sheetNames(prtNumber)(0) sheetCount = sheetCount + 1 sheetNames(prtNumber)(0) = sheetCount End If End If End If Next 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("Design Tracking Properties").Item("Part Number").Value prtRev = modelDoc.PropertySets("Summary Information").Item("Revision Number").Value If Not String.IsNullOrEmpty(prtNumber) Then If Not String.IsNullOrEmpty(prtRev) Then prtRev = String.Format(" - Rev {0}", prtRev) End If sheetOf = "" sheetCount = sheetNames(prtNumber)(0) If sheetCount > 1 Then sheetNames(prtNumber)(1) = sheetNames(prtNumber)(1) + 1 sheetOf = String.Format(" Sheet {0}", sheetNames(prtNumber)(1)) End If dwgSheet.Name = prtNumber & sheetOf & prtRev End If End If Next End If End Sub
Cleaned up the spaces to see the lines easier.
I edited the post to clean up the spacing. It may be extra 'returns' in formatting the code.
Attached is the code in a file.
Unfortunately I can't locate the Revision property of a sheet. It seems to not be exposed by the api.