Hello, i have no experience with iLogic rules and need some help to modify one i found online to suit my needs.
I need to change the view label properties in the styles editor to show custom properties in the view label, Ofcourse the only way to do this is to manualy edit each view label as the styles editor does not allow custom properties.
I need each view label to show the below. (see attached image)
"View" is to be the same value as default. (5mm text size)
"MARK No" should be plane text (5mm text) followed by the custom model property "Mark_No)
"REF" needs to be plane text (3.5mm) followed by the custom model property "CLIENT DRG No)
"SCALE" needs to be 3.5mm text followed by the default view scale parameter
The iLogic rule i found is below and is to be used in the .idw template, I am hoping somebody can decipher it and show me what i need to edit??
'start of ilogic code
Dim oDoc As DrawingDocument: oDoc = ThisDoc.Document
oModel = ThisDoc.ModelDocument
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
oSheets = oDoc.Sheets
For Each oSheet In oSheets
oViews = oSheet.DrawingViews
For Each oView In oViews
oView.ShowLabel = True
Try
'get the property ID for these custom iProperties from the model referenced by the view
o_iPropID_1 = oModel.PropertySets.Item("User Defined Properties").Item("My_iProp_1").PropId
o_iPropID_2 = oModel.PropertySets.Item("User Defined Properties").Item("My_iProp_2").PropId
Catch
'here you could add a message that one or more of the custom iProperties were not found
End Try
Try
'format the custom iproperty string and add the property ID
oString1 = "<Property Document='model' PropertySet='User Defined Properties' " _
& "Property='My_iProp_1' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
& o_iPropID_1 & "'>My_iProp_1</Property><Br/>"
'format the custom iproperty string and add the property ID
oString2 = "<Property Document='model' PropertySet='User Defined Properties' " _
& "Property='My_iProp_2' FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='" _
& o_iPropID_2 & "'>My_iProp_2</Property><Br/>"
'add the custom iproperties to the view label
oView.Label.FormattedText = "<DrawingViewName/><Br/>" & oString1 & oString2
Catch
'do nothing if error
End Try
Next
Next
'end of ilogic code
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi ajcraig99,
Here is a quick example rule to format to your needs. Hopefully you can determine how the code works. but just post back if it does not work for you, or if you have questions.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
'start of ilogic code
'specify font
sFont = "Arial"
sFSize1 = 0.5 'font size in cm
sFSize2 = 0.35 'font size in cm
sString1 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "' Underline='True'>" & _
"<DrawingViewName/></StyleOverride>"
sString2 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'>Mark No: </StyleOverride>"
sString3 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize1 & "'>" _
& "<Property Document='model' PropertySet='User Defined Properties' Property='Mark No' " & _
"FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='7'>Mark No</Property></StyleOverride>"
sString4 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize2 & "'>REF: </StyleOverride>"
sString5 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize2 & "'>" _
& "<Property Document='model' PropertySet='User Defined Properties' Property='Client DRG No' " & _
"FormatID='{D5CDD505-2E9C-101B-9397-08002B2CF9AE}' PropertyID='6'>Client DRG No</Property></StyleOverride>"
sString6 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize2 & "'>SCALE: </StyleOverride>"
sString7 = "<StyleOverride Font='" & sFont & "' FontSize='" & sFSize2 & "'>" & _
"<DrawingViewScale/></StyleOverride>"
Dim oDoc As DrawingDocument: oDoc = ThisDoc.Document
oModel = ThisDoc.ModelDocument
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
oSheets = oDoc.Sheets
For Each oSheet In oSheets
oViews = oSheet.DrawingViews
For Each oView In oViews
'make view label visible
oView.ShowLabel = true
'add lines to the view label
'break line using: "<Br/>"
oView.Label.FormattedText = _
sString1 & "<Br/>" & _
sString2 & sString3 & "<Br/>" & _
sString4 & sString5 & "<Br/>" & _
sString6 & sString7
Next
Next
'end of ilogic code
Thanks Curtis, Much appreciated,
Im having trouble getting the "' Underline='False'>"
value to work on string 2 to string 7. is it also possible to make this for "Base view" only?
P.S how do i sub to your blog without rss feeds?
Hi ajcraig99,
When working with view labels I use an intermediate ilogic rule to capture the text formatting. Here is how I get the formatting to use in the rule:
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet If oSSet.count = 0 Then MessageBox.Show("You must select a drawing view first", "iLogic") Exit Sub End If 'Reference to the drawing view from the 1st selected object Dim oView As DrawingView = trycast(oSSet.item(1), DrawingView) If oView IsNot Nothing Then 'turn view label visibility on oView.ShowLabel = True 'capture the current view label ViewLabel = oView.Label Try 'return the value MessageBox.Show(oView.Label.FormattedText, _ "iLogic - Go to the Summary iproperties to copy this information") 'write the value to the drawings comments property iProperties.Value("Summary", "Comments") = oView.Label.FormattedText Catch 'do nothing if error End Try Else MessageBox.Show("The selected object is not a drawing view", "iLogic") End If
Give this a try and see if you can get the results you're after.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com