I have a pretty straight forward Rule that replaces the standard detail view scale (12:1) with a relative detail view scale (2X). The rule does this by comparing the deatil view scale to the base view scale and outputing the relationship, see below.
oView.Label.FormattedText = ("<StyleOverride FontSize = '.48'>" & "<StyleOverride Underline = 'true'>" & _
"DETAIL <DrawingViewName/><Br/>" & "</StyleOverride>" & "</StyleOverride>" & Round((oView.Scale / oView.ParentView.Scale),1) &"X")
This works perfect so long as my users arent changing the "stock" detail view label, the rub, they change them all the time and my rule conveniently overwrites them.
Does iLogic allow the programmatic copy and paste of an existing view label, line by line?
Or, better yet, is there a method to force the view scale property to accept a string?
Solved! Go to Solution.
Solved by ebuckner. Go to Solution.
Hi ebuckner,
I think you can capture the current view label and then reuse it when you set the formatted text, as in this example where sLabel captures the current view label value.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
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
'get label as string
sLabel = oView.Label.FormattedText
oModelName = _
oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
Try
'set the view label
oView.Label.FormattedText = ("<StyleOverride FontSize = '.48'>" & _
"<StyleOverride Underline = 'true'>" & sLabel & "<Br/>" & _
"</StyleOverride>" & "</StyleOverride>" & _
Round((oView.Scale / oView.ParentView.Scale),1) &"X")
Catch
'do nothing if error
MessageBox.Show("Error", "Title")
End Try
Else
MessageBox.Show("The selected object is not a drawing view", "iLogic")
End If
Thanks Curtis!
That worked great for "cutting and pasting" the existing label however, the existing label includes a scale which is then included above the new scale value. I need to figure out how to delete a line or only capture all but the bottom line of text. Great start though, thanks again!
After some research into what excel guys are doing I've figured out how to grab a portion of our labels and replace it.
the keys are the INSTR, INSTRREV, and MID vba commands.
I'm attaching the entire iLogic rule which should make following easy enough. If you have questions about how any of this works let me know.
Here is the part that was hard to track down. The label in formatted form included <Br/>SCALE <*>X followed by either nothing or another line of text. The chunk below searches for the beginning and end of the target string and then determines if it's at the end of the entire string or within a larger string and reacts accordingly.
Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 7016 StartFragment: 314 EndFragment: 6984 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet
If InStr(sPLabelFix2, "<Br/>SCALE") Then Start = InStr (sPLabelFix2, "<Br/>SCALE") 'MsgBox (Start,,"Start") Finish = InStrRev(sPLabelFix2, "X<Br/>") 'MsgBox (Finish,,"Finish") If Finish = 0 Then sGrab = Mid(sPLabelFix2, Start) ElseIf Finish <> 0 Then sGrab = Mid(sPLabelFix2, Start, Finish-Start+1) End If 'MsgBox (sGrab,,"Grab") sPLabelFix3 = Replace(sPLabelFix2, sGrab, "") oView.Label.FormattedText = (sPLabelFix3) End If