Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

MText "lines" of text

Status
Not open for further replies.

CanonShooter

Structural
Joined
Oct 14, 2005
Messages
39
Location
US
Any way on ACAD 2004 VBA to find the number of text lines in an MText "paragraph", or do ya just have to figure it out somehow by using the bounding box and text height?
 
You can check the text sting for delimiters as a method (depends on how the string was made)

"Everybody is ignorant, only on different subjects." — Will Rogers
 
I did the following (I guess it works all the time):

Dim blockObj As AcadBlock
Dim mtextObj As AcadMText
Dim insertPoint(0 To 2) As Double
Dim txwid As Variant
Dim txht as Variant
Dim txstr as String
Dim minExt As Variant
Dim maxExt As Variant
Dim junk as Variant

'set text data
insertPoint(0) = 0
insertPoint(1) = 0
insertPoint(2) = 0
txwid = 3 'sets text box width
txht = 0.25
txstr = "THIS PLACE IS NICE" 'sets text

'Create a text Object in the blocks model space
Set mtextObj = blockObj.AddMText(insertPoint, txwid, txstr)
mtextObj.Height = txht
'set ratio between text lines (1 = 0.66666 times height)
mtextObj.LineSpacingFactor = "1"

'Get bounding box info
mtextObj.GetBoundingBox minExt, maxExt

junk = Int((maxExt(1) - minExt(1)) / (txht * 1.66667) + 1)

MsgBox "MText lines = " & junk, vbInformation, "MText"

 
A little rough around the edges but efficient..
[copy] paragraph out of the way..
[explode] copied mtext to dtext..
[erase] dtext and refer to command line for how many entities were erased
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top