Can it be done?
I've seen snipppets of code to get the Sheet name but is there a way to set it via code?
I'm thinking it might be useful to set the sheet names to the chosen sheet format (as opposed to just 'Sheet').
I'm sprucing up my drawing template...
Rule #1 is for selecting sheet format (which title block/sheet size/oreintation)
Rule #2 is for setting iproperty values to populate the titleblock with info. (if required)
Rule #1 was based on code from S.Bixler & inventortrenches
Rule#2 was based on more code taken from here, thanks forum users.
Solved! Go to Solution.
Solved by mrattray. Go to Solution.
Hi Mike
I am currently using the below rule to label my drawing sheets. I have some larger assemblies where some components are set to reference for that particular configuration. It would be really handy to see this in the sheet name so I can move these all to the end of the set so I know to ignore them for that particular configuration.
So I want to add the BOMStructure type to the sheet name, I am struggling to access this and add it to the rule, are you able to help. It doesn't matter if it read its id number or "Reference/Normal", its just to differentiate from each other.
SyntaxEditor Code Snippet
Sub Main If TypeOf ThisDoc.Document Is DrawingDocument Then Dim dwgDoc as DrawingDocument = ThisDoc.Document Dim BOMStructure As Object 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(32).Value + "-" + modelDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(43).Value If Not String.IsNullOrEmpty(prtNumber) Then dwgSheet.Name = prtNumber End If End If Next End If End Sub
Regards,
Travis
A new company I am working with has a, oxyfuel cutting table and their software on the cnc machine only accepts 1 .dxf file at a time to import.
Is there a way to change the sheet name to reflect the Part Number of an .ipt that is placed on the sheet, then to do it for multiple sheets? So I can export to .dxf and the filenames will be base off of the Sheet Names?
Here is a bit of code i cobbled together to do just that. I've finaly got so 'upset' with the generic SHEET in the browser, making it hard to find the part sheet i'm looking for that i just went looking for code. I used the above code and copied some of my other ilogic rules that sets the iproperties based (in part) on the assembly iproperties. and now it renames the browser to the part name.
Do note that some might not get renemed due to illegal characters in the property name.
Sub Main
If TypeOf ThisDoc.Document Is DrawingDocument Then
Dim dwgDoc As DrawingDocument = ThisDoc.Document
Dim BOMStructure As Object
For Each dwgSheet As Sheet In dwgDoc.Sheets
If dwgSheet.DrawingViews.Count > 0 Then
FNamePos = InStrRev(dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName, "\", - 1)
docFName = Mid(dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName, FNamePos + 1, Len(dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName) - FNamePos)
' prtNumber = iProperties.Value(docFName, "Summary", "Title")
prtNumber = iProperties.Value(docFName,"Project", "Part number")
If Not String.IsNullOrEmpty(prtNumber) Then
dwgSheet.Name = prtNumber
' MessageBox.Show(prtNumber)
End If
End If
Next
End If
End Sub
Hi! I think it should be doable via iLogic. However, sheet names have to be unique. If there is already an existing sheet with the same name, the renamed name will be rejected.
Many thanks!
I DID IT!!
Sub Main If TypeOf ThisDoc.Document Is DrawingDocument Then Dim dwgDoc As DrawingDocument = ThisDoc.Document Dim BOMStructure As Object For Each dwgSheet As Sheet In dwgDoc.Sheets If dwgSheet.DrawingViews.Count > 0 Then FNamePos = InStrRev(dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName, "\", - 1) docFName = Mid(dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName, FNamePos + 1, Len(dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName) - FNamePos) prtNumber = iProperties.Value(docFName, "Project", "Part number") stockNumber = iProperties.Value(docFName, "Project", "Stock number") If Not String.IsNullOrEmpty(prtNumber) Then Dim newSheetName As String = prtNumber & " " & stockNumber If IsAssemblyDocument(docFName) And Not newSheetName.EndsWith("ASS'Y") Then newSheetName = newSheetName & " ASS'Y" End If dwgSheet.Name = newSheetName End If End If Next End If End Sub Function IsAssemblyDocument(docName As String) As Boolean Dim fileExtension As String = System.IO.Path.GetExtension(docName).ToUpper() Return fileExtension = ".IAM" End Function