DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

What Is the real location of a text entity ?

Started by Hubert, July 12, 2007, 04:51:56 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Hubert

When reading a DesignCad.Entity Text, points are returned as if the text was left justified. So, if it is not the case (Center or Right Justify) I need to know what justification was used when created and I don't find this information in the objects Entity or EntText2D

Can somebody help me

Thanks

Sample of code : (Visual Studio 2005 / Basic for DotNetFramework)

Sub NewText2D(ByRef DCEntity As DesignCAD.Entity)

        Dim Txt As DesignCAD.EntText2D = DCEntity.EntityDataObject
        Dim dX, dY, dZ As Double
        Dim MoyX, MoyY As Double

        DCEntity.GetPoint(1, MoyX, MoyY, dZ)
        m_InsertPoint = New ccPoint(MoyX, MoyY)
        For Ix As Integer = 2 To 4 ' Try to calculate the 'Center' of the text, false when text is not left justify
            DCEntity.GetPoint(Ix, dX, dY, dZ)
            MoyX = MoyX + dX
            MoyY = MoyY + dY
        Next
        MoyX = MoyX / 4
        MoyY = MoyY / 4
...
End Sub

DrollTroll

Sorry, that seems to be an oversight in our development of the EntText and EntText2D classes. It seems that the only way you can get the entity's text justification for now is to use a macro.

Assuming the entity in question is the only one selected, your macro should do the following:

'texjust.d3m
GetSelect 1, j
Entity j
Query &H0503, jus     '0=left, 1=center, 2=right
Sys$(40) = jus    'copies the result to the clipboard (as a string)
End

In your automation code, you'll use something like:
bool gotjust = DcDoc.RunBasicCAD("textjus.d3m") 'adjusting the file's name and path as needed
If gotjust = true Then
' retrieve text from clipboard.
' determine justification.
' adjust points accordingly.
' The retrieved points should give you the correct size and orientation;
' you'll just need to adjust them to the right either by 1/2 the text length
' or the entire length, if center- or right-justified.
End If


25 years with DesignCAD

landonairey

You've created a nice quick workaround with the "Query &H0503, jus" line. Is there any quick workaround like this but for use in an older dcad version? I'm running dcad 3000 which I believe is version 11? I need to extract the justification and angle from a selected 2dtext entity. Any help is appreciated!

DrollTroll

#3
I'm sorry, but to the best of my recollection the justification information just wasn't available (to us) in Dcad3000. Size and angle should still be retrievable from the points. If I get time I'll look into it, but that's not a supported version any more and my time is quite constrained.
25 years with DesignCAD