Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Insert and Explode MText Blocks

128 views
Skip to first unread message

Rob Peterson

unread,
Dec 2, 2002, 11:44:17 AM12/2/02
to
I have a vba program the creates general notes by inserting mulitple blocks
of Mtext. I would like to have these blocks exploded right away so that if
they have to be "tweaked", it can be done with the multiline text editor.

Is there a way through vba to insert an exploded block? I have tried naming
the block with a "*" in front of it but I get a "Filer Error" when I run the
program. I have also tried objBlock.Explode but that leaves individual
lines of text not Mtext.


Kevin Terry

unread,
Dec 2, 2002, 1:17:52 PM12/2/02
to
Set aBlock = mcFile.ModelSpace.InsertBlock(insPt,
"yourblocknamehere", 1, 1, 1, 0)
aBlock.Explode

can you post your code if the above doesn't work?

--
Kevin


"Rob Peterson" <autodesk.autocad.customization.vba> wrote in message
news:D1DC52420CD44D9D...@in.WebX.maYIadrTaRb...

Rob Peterson

unread,
Dec 3, 2002, 12:56:57 PM12/3/02
to
Kevin,

What you suggested did not work, the mcFile in place of ThisDrawing gave me
an error message of "variable not defined". Below is the part of the code
that I am using to insert the blocks. What is mcFile? I have looked in the
Object Browser and nothing shows up. Let me know if you (or anybody else)
has any suggestions.


Private Sub cmdCreate_Click()

frmNotes.Hide

With ThisDrawing.Utility
.InitializeUserInput 1
StartPnt = .GetPoint(, vbCr & "Pick starting point: ")
End With

' Header
TextPortion = "general"

Set objText = ThisDrawing.ModelSpace.InsertBlock(StartPnt, TextPortion &
".dwg", 1, 1, 1, 0)

Dim minExt As Variant
Dim maxExt As Variant

objText.GetBoundingBox minExt, maxExt

TextPnt(0) = StartPnt(0)
TextPnt(1) = minExt(1) - 3.75
TextPnt(2) = StartPnt(2)

' Design Stresses
If optAisc.Value = True Then
TextPortion = "aisc"
Else
TextPortion = "aashto"
End If

Set objText = ThisDrawing.ModelSpace.InsertBlock(TextPnt, TextPortion &
".dwg", 1, 1, 1, 0)

End Sub


"Kevin Terry" <kev...@jaypro.com> wrote in message
news:0DF55B3E28CA2E51...@in.WebX.maYIadrTaRb...

Laurie Comerford

unread,
Dec 3, 2002, 2:24:07 PM12/3/02
to
Hi,

Another simple approach is to write a program with the text hard coded in
the program, or for the program to read a user selected file and lastly ask
the user for an insertion point.

A user interface could put the relevant default text in a dialog box for
editing prior to insertion in the drawing - also you could set text style
and height parameters and select layer from the interface.

--


Laurie Comerford
CADApps
www.cadapps.com.au


"Mark_Abercrombie" <r23...@email.sps.mot.com> wrote in message
news:f128...@WebX.maYIadrTaRb...
> You might consider saving the notes as text files. You can then read the
text file and create an MTEXT object directly without inserting a block.


Vaughn Hamilton

unread,
Dec 3, 2002, 3:37:10 PM12/3/02
to
I agree with Laurie's idea of reading the text in from a file and adding the
text directly to the drawing as an mtext entity. However give this a try
after you insert your block...

ThisDrawing.SendCommand "explode" & vbCr & "l" & vbCr & vbCr

This should explode the last object created in the drawing...your block.

Hope this helps...Vaughn

"Rob Peterson" <autodesk.autocad.customization.vba> wrote in message
news:D1DC52420CD44D9D...@in.WebX.maYIadrTaRb...

Kevin Terry

unread,
Dec 3, 2002, 4:46:17 PM12/3/02
to
Rob,
"What is mcFile?" -
that's just the file reference (you are using ThisDrawing, that's the same
thing):
Dim mcFile As AcadDocument
Set mcFile = Application.ActiveDocument
...therefore mcFile = ThisDrawing

I'm not sure why your code won't work as is, I can't tell for sure because
you have used some global or form level variables (objText) that could
either be text objects or blocks (or they are simply not defined). Are you
using Option Explicit at the top of your form? Can you post any global
declarations you are using? Then I might better see what you are trying to
do here, and/or offer a solution.

I'm going to take a stab here, don't hold me responsible if it doesn't work
exactly as desired though:
'your code, slightly changed:
Private Sub cmdCreate_Click()

Dim aBlock As AcadBlockReference

frmNotes.Hide

With ThisDrawing.Utility
.InitializeUserInput 1
StartPnt = .GetPoint(, vbCr & "Pick starting point: ")
End With

' Header
TextPortion = "general"

'what kind of variable is objText?
Set aBlock = ThisDrawing.ModelSpace.InsertBlock(StartPnt, TextPortion &


".dwg", 1, 1, 1, 0)

aBlock.Explode
aBlock.Delete

Dim minExt As Variant
Dim maxExt As Variant

aBlock.GetBoundingBox minExt, maxExt

TextPnt(0) = StartPnt(0)
TextPnt(1) = minExt(1) - 3.75
TextPnt(2) = StartPnt(2)

' Design Stresses
If optAisc.Value = True Then
TextPortion = "aisc"
Else
TextPortion = "aashto"
End If

Set aBlock = ThisDrawing.ModelSpace.InsertBlock(TextPnt, TextPortion &


".dwg", 1, 1, 1, 0)

'what's going to happen next?

End Sub

--
Kevin


"Rob Peterson" <autodesk.autocad.customization.vba> wrote in message

news:1B4326015039FC3D...@in.WebX.maYIadrTaRb...

Rob Peterson

unread,
Dec 4, 2002, 6:36:35 AM12/4/02
to
Thanks Vaughn, that line took care of it.

Rob

"Vaughn Hamilton" <vham...@ghpud.org> wrote in message
news:2885BC50A68549D5...@in.WebX.maYIadrTaRb...

0 new messages