View label and text box

View label and text box

Anonymous
Not applicable
657 Views
3 Replies
Message 1 of 4

View label and text box

Anonymous
Not applicable
I want to create a view label and a text box using the same string.
The sheet contains a number of parts, the view label is correct but the text box always uses the properties of the first base view on the sheet, is it possable to get the text box to use the same view properties as the view label?

Here is the sample code:

sTextPartNumber = ""
sTextDescription = ""
sTextQty = " Qty " & GlobalQuantity
sTextMaterial = ""
sTextThick = FindTheThickness(Global_Thick)

Dim osketch As DrawingSketch

sText = "" & sTextPartNumber & "," & sTextQty & ",
" & sTextDescription & ",
" & sTextMaterial & ", Thick " & sTextThick & "," & "
"

Set osketch = oDrawDoc.ActiveSheet.Sketches.Add
osketch.Edit

Dim oTextBox As TextBox
Set oTextBox = osketch.TextBoxes.AddFitted(oTransGeom.CreatePoint2d(oDrawView.Center.X, oDrawView.Center.Y - (ViewHeight / 2) - 1), sText)

oDrawView.Label.Position = oTransGeom.CreatePoint2d(oDrawView.Center.X, oDrawView.Center.Y - (ViewHeight / 2) - 1)
oDrawView.ShowLabel = True
oDrawView.Label.FormattedText = sText
0 Likes
658 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Unfotunatly all the XML code has been striped from the code?
0 Likes
Message 3 of 4

Anonymous
Not applicable
Malcolm,

The TextBox Object is not capable of supplying a view’s name or a view’s scale (no association – XML code like DrawingViewLabel) but if you have a way to target the desired view, you could query it for name and scale for the purpose of displaying in your TextBox.

For DrawingViewLabels, don’t strip out the XML tags. Start by saving the FormattedText of the DrawingViewLabel in a variable, modify that text by somehow adding your text then push the modified back in to the FormattedText property of the DrawingViewLabel. These XML tags can vary (style overrides, carriage returns, etc) from drawing to drawing so you don’t want to change them but you do want to add your stuff somehow. Query API Help for “XML Tags for FormattedText” so you understand how they work. Depending on exactly how you want to display the information (default XML code and your text), the task of modifying the FormattedText can be as simply as adding you text to the end of the FormattedText or more difficult if your text has to be added between XML tag beginning and end. I often print (E.G. Debug.Print oDrawingViewLabel.FormattedText) stuff to the Immediate window so I can see everything in order to decide how to approach the FormattedText modification. The first FormattedText line below is not modified. The second FormattedText line below is modified by text to the end of FormattedText. My assumption is you want the parts qty to be added below the SCALE.


SCALE


SCALE
Qty " & GlobalQuantity

oDrawingViewLabel.FormattedText = oDrawingViewLabel.FormattedText & "
Qty " & GlobalQuantity

Here the technique I use to insert my text before something you know is already in the FormattedText (you probably test for it by using the Like Operator). The nice thing about using the Replace function is, you don’t have to care where, what you are try to replace ("
SCALE") is in the FormattedText, if it’s in there it will replace it.

oDrawingViewLabel.FormattedText = Replace(oDrawingViewLabel.FormattedText, "
SCALE", “
Qty " & GlobalQuantity & "
SCALE”)

I hope this helps.
0 Likes
Message 4 of 4

Anonymous
Not applicable
Thanks for the help
0 Likes