TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
All posts discussing pricing or where to buy TurboCAD will be deleted.

AddText Method
Read 4993 times
* November 30, 2009, 05:38:49 AM
Hello,

the member function (method) "AddText" requires in its
Parameter list for the parameter "offset" and "justification"
apparently imsi data types (?). I have these types of data already
sought in the header files and not found.
They are: "ImsiTextOffset" and "ImsiTextJustification"
The SDK Documentation is also not explained or I
understand something wrong. Do you know what exactly should be used as a value
should or can?

Greeting
H.S

Logged


* November 30, 2009, 07:53:04 AM
#1
Hi H.S.
A good way to find out what is not documented is to use the macro-recorder.
Start the recorder
Select a text
Change the justification

Stop the recorder
And have a look to the recorded script.

Best regards
Bernd

Logged


* November 30, 2009, 12:16:20 PM
#2
Hi Bernd,

this is a good idea.  I tried it once
and get integer values.

ActiveDrawing.Properties ( "$ EXTERNALJUSTIFY") = "2050"
ActiveDrawing.Properties ( "$ EXTERNALJUSTIFY") = "514"

These values were in use in a program
the desired text alignment.
Do you know how to compose these values?

Best regards,
H.S.

Logged


* December 03, 2009, 02:54:42 AM
#3
Hi H.S.
when I select a text-item
start the recorder
change the justification from
top left to middle center
it is recorded in this way:

For Each gxChild in Selection
   gxURec.AddGraphicForModify gxChild
   gxChild.Properties("TextFormat") = 514
Next

If you want to change the jusification for single selection (only one item)

ActiveDrawing.selection.item(0).Properties("TextFormat").value = 514


best regards
Bernd

Logged


* December 03, 2009, 07:46:21 AM
#4
A few years ago Tom Snape helped me out with this issue.

The attached Function will return the justification parameters for the AddText method.

Code: [Select]
'**********************************************************************************************************

'**********************************************************************************************************
' Function........: GetJustification
' Description.....: Calculates Justification parameter for
'                   AddText Method
' Arguments.......: strTextJust     -   Justification String
'                   strTextOffset   -   Offset String
'Returns..........: Justification parameter as integer
'Reference........: Tom Snape 2001
Function GetJustification(strTextJust As String, strTextOffset As String) As Long
    Dim hj As Long
    Dim vj As Long
    hj = 0
    vj = 0
    If strTextJust = "Left" Then
        hj = 1
    ElseIf strTextJust = "Center" Then
        hj = 2
    ElseIf strTextJust = "Right" Then
        hj = 4
    End If
    If strTextOffset = "Top" Then
        vj = 256
    ElseIf strTextOffset = "Middle" Then
        vj = 512
    ElseIf strTextOffset = "Baseline" Then
        vj = 1024
    ElseIf strTextOffset = "Bottom" Then
        vj = 2048
    End If
    GetJustification = hj + vj
End Function

'**********************************************************************************************************

an abridged example call follows:

Code: [Select]
Dim lJustOff as Long
lJustOff = GetJustification("Left", "Top")
Set Gr = Grs.AddText(sText, X, Y, Z, Height, Angle, , , lJustOff)


I hope this helps.
CWC
« Last Edit: February 16, 2010, 04:58:10 PM by cwcookman »

Logged


* February 16, 2010, 05:02:33 PM
#5
I just realized there is an error in the GetJustification Function I posted December 03, 2009.

The second to the last line was:
Justification = hj + vj

It should have been:
GetJustification = hj + vj

The code sample now reflects the change.

CWC




CWC

Logged