- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to write an iLogic that inputs the "Pattern" custom iProperty into the view label and turns it on. If the Pattern iProperty is not found, I want it to not change the label, turn off the label visibility, and move on to the next view. I want it linked to the iProperty rather than just the value because I don't want people to have to run the iLogic all over again if the pattern letter changes on one of the parts.
The issue I am having is this: The code works just fine when every view on the drawing has the Pattern custom iProperty. However, when the first placed view (or maybe any view, I'm not sure) does not have this custom property, the code selects the wrong custom property on all the views that have the custom property and also turns off the view label on those views.
It seems that when the code can't find the "PATTERN" iProperty, it selects a different one and then doesn't look for the "PATTERN" iProperty on the following iterations, but I'm not sure why this would happen.
What am I doing wrong?
Here is my code:
Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView
Dim oPatProp As Inventor.Property
Dim oPat As String
For Each oView In oSheet.DrawingViews
Dim oMDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oCProps As Inventor.PropertySet = oMDoc.PropertySets.Item("Inventor User Defined Properties")
Try
oView.ShowLabel = True
oPatProp = oCProps.Item("PATTERN")
oPat = "<Property Document='model' FormatID='" & oCProps.InternalName & _
"' PropertyID='" & oPatProp.PropId & "' />"
'check if input is correct (will remove from final code)
a = InputBox("", "Before Changes:", oView.Label.FormattedText)
oView.Label.FormattedText = oPat
Catch
oView.ShowLabel = False
End Try
Next
After running the code, all the views have their view labels hidden, and this in the view label text:
This is a list of the custom iProperties in the view that doesn't have "PATTERN":
This is a list of our custom iProperties in the views that do have "PATTERN":
Solved! Go to Solution.