Color and Rotation of TextBox on DrawingSketch

Color and Rotation of TextBox on DrawingSketch

martin_mmj
Enthusiast Enthusiast
971 Views
5 Replies
Message 1 of 6

Color and Rotation of TextBox on DrawingSketch

martin_mmj
Enthusiast
Enthusiast
Hi all. I have two questions.

1) I want to change color of textbox on DrawingSketch. But still without any efect.

Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(oSheet.Width / 2, oSheet.height / 2), "<StyleOverride FontSize='2' Bold='True'>Vzor</StyleOverride>")

oTextBox.Color = Color(128, 128, 128)
oTextBox.VerticalJustification = kAlignTextMiddle

2) Exist any way to rotate this text to 45deg? I know that rotation of textbox object is limited to 0, pi/2, pi, and 1.5pi

Can you help me? Thanks

Martin
0 Likes
972 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Hi Martin,

 

For the firtst question, you can try following code
to generate the Color object:

 

Dim oColor As Color
Set oColor =
ThisApplication.TransientObjects.CreateColor(128, 128, 128)

 

For the second one, I have no method to solve it as
you said rotation of textbox object is limited to 0, pi/2, pi, and
1.5pi.

 

Thanks,

Lisa


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi
all. I have two questions.

1) I want to change color of textbox on
DrawingSketch. But still without any efect.

Set oTextBox =
oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(oSheet.Width / 2, oSheet.height
/ 2), "<StyleOverride FontSize='2'
Bold='True'>Vzor</StyleOverride>")

oTextBox.Color = Color(128,
128, 128)
oTextBox.VerticalJustification = kAlignTextMiddle

2) Exist
any way to rotate this text to 45deg? I know that rotation of textbox object
is limited to 0, pi/2, pi, and 1.5pi

Can you help me?
Thanks

Martin
0 Likes
Message 3 of 6

Anonymous
Not applicable

For rotating the text box, you can use the API
equivalent of the 'Rotate' command in the sketch environment. For the rotate
command to work on text boxes, the boundary of the text box must be displayed.
See sample below that rotates the first text box on the active sketch. Note that
it leaves the boundary on after the rotation. You can choose to turn it off
after rotation.

 

Sanjay-

 

 

Sub RotateText()

 

    Dim oDoc As
DrawingDocument
    Set oDoc =
ThisApplication.ActiveDocument
   
    Dim
oSketch As Sketch
    Set oSketch =
ThisApplication.ActiveEditObject
           

    Dim oTextBox As TextBox
    Set
oTextBox = oSketch.TextBoxes.Item(1)
   

    oTextBox.ShowBoundaries = True
   

    Dim oCollection As ObjectCollection
   
Set oCollection =
ThisApplication.TransientObjects.CreateObjectCollection
   

    Call oCollection.Add(oTextBox)
   

    Dim oPoint As Point2d
    Set oPoint =
oTextBox.Origin
   
    Call
oSketch.RotateSketchObjects(oCollection, oPoint, 3.14159 /
4)
   
End Sub
0 Likes
Message 4 of 6

martin_mmj
Enthusiast
Enthusiast
1) Hi Lisa, thanks for your reply. Yesterday I found another way for color of textbox
Call oTextBox.SetColor(128, 128, 128)
But I think that your way is more professional.

2) Hi Sanjay, thanks for RotateText procedure. It works fine, without problem.

I appreciate your help.

Martin


0 Likes
Message 5 of 6

Anonymous
Not applicable
I am trying to change the background color of a drawing and am having some issues. Please take a look at the code below. The oSheetColor Changes to the new numbers, but the oDoc.SheetSettings.SheetColor does not (in the locals window). Shouldn't these be the same object? In the end, the drawing background does not change. Any help would be appreciated.

Public Sub whiteBack()

'Set a reference to the active document.
Dim oDoc As Object
Set oDoc = ThisApplication.ActiveDocument

Set oSheetColor = oDoc.SheetSettings.SheetColor
Call oSheetColor.SetColor(255, 255, 255)
oDoc.Update

End Sub
0 Likes
Message 6 of 6

Anonymous
Not applicable

oSheetColor is a transient tear-off object. So changing the color on it
will not reflect on the sheet settings. You need to set the color object back to
the SheetSettings object:

 

Call oSheetColor.SetColor(255, 255, 255)
oDoc.SheetSettings.SheetColor
= oSheetColor
 

Sanjay-
0 Likes