×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

MText "lines" of text

MText "lines" of text

MText "lines" of text

(OP)
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?

RE: MText "lines" of text

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

RE: MText "lines" of text

(OP)
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"

RE: MText "lines" of text

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources