02-16-2023
12:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-16-2023
12:16 PM
This rule is making browser tree with some properties. It is working perfect if there is no special characters in material or description. My question is how to remove special characters like (, :& ) only from browser tree.
oDoc = ThisDoc.Document oSheets = oDoc.Sheets For Each oSheet In oSheets oSheet.activate oView = oSheet.DrawingViews.Item(1) modelName = oView.ReferencedDocumentDescriptor.ReferencedDocument oProp = modelName.PropertySets.Item("Design Tracking Properties") 'ocProp = modelName.PropertySets.Item("Inventor User Defined Properties") 'Custom property set ActiveSheet.Sheet.Name = oProp.Item("Part Number").Value & " " & oProp.Item("Description").Value '_ '& " " & "QTY" & " " & ocProp.Item("TTL").Value Next oSheets(1).activate iLogicVb.UpdateWhenDone = True
Solved! Go to Solution.
02-16-2023
12:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-16-2023
12:52 PM
@GosponZ you can try something like this. It is a slight modification to your code. It will not error when it finds a page without a view & it will just remove all characters that are not letters or digits except for spaces.
Dim oDoc As Document = ThisDoc.Document
Dim oSheets As Sheets = oDoc.Sheets
For Each oSheet In oSheets
oSheet.Activate
Dim oView As DrawingView
Try
oView = oSheet.DrawingViews.Item(1)
Catch
'MessageBox.Show("There is no drawing view on " & oSheet.Name)
Continue For
End Try
Dim modelName As Object = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oProp As PropertySet = modelName.PropertySets.Item("Design Tracking Properties")
'ocProp = modelName.PropertySets.Item("Inventor User Defined Properties") 'Custom property set
Try
Dim oSheetName As String = oProp.Item("Part Number").Value & " " & oProp.Item("Description").Value '_
'& " " & "QTY" & " " & ocProp.Item("TTL").Value
Dim oDisplayName As String = ""
For Each letter As Char In oSheetName
If Char.IsLetterOrDigit(letter) Or Char.IsWhiteSpace(letter) Then
oDisplayName = oDisplayName & letter
End If
Next
ActiveSheet.Sheet.Name = oDisplayName
Catch
'MessageBox.Show("Couldn't change sheet name for " & oSheet.Name)
End Try
Next
oSheets(1).Activate
iLogicVb.UpdateWhenDone = True
If this solved your problem or answered your question, please click ACCEPT SOLUTION.
If this helped you, please click LIKE.
If this helped you, please click LIKE.
02-16-2023
05:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-16-2023
05:53 PM
Hi @GosponZ
You can use Regex for this.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Imports System.Text.RegularExpressions
oDoc = ThisDoc.Document
oSheets = oDoc.Sheets
For Each oSheet In oSheets
oSheet.activate
oView = oSheet.DrawingViews.Item(1)
modelName = oView.ReferencedDocumentDescriptor.ReferencedDocument
oProp = modelName.PropertySets.Item("Design Tracking Properties")
sSpecicals = "[#$%&'()*+,-./\\~:;]"
oPN = Regex.Replace(oProp.Item("Part Number").Value, sSpecicals, "")
oDesc = Regex.Replace(oProp.Item("Description").Value , sSpecicals, "")
ActiveSheet.Sheet.Name = oPN & " " & oDesc
Next
oSheets(1).activate
iLogicVb.UpdateWhenDone = True
02-17-2023
04:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-17-2023
04:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report