Hide Form to pick point

Hide Form to pick point

Anonymous
Not applicable
280 Views
2 Replies
Message 1 of 3

Hide Form to pick point

Anonymous
Not applicable
I can't seem to get this... I am loading a list box with notes from a data base. When a user pick a note, I would like to insert said note with a leader... It requires 2 picks. One for the insertion point for the Mtext and 1 for the leader starting point. But when the form is obviously in the way. So I have tried frmSheetNotes.hide... me.hide and even me.show before the drawing with.objUtil statment. I get various errors... the most common being msgbox "AutoCAD is unable to service automation request" command line "** That command may not be invoked transparently **" Here's the code.

Private Sub lstSheetNotes_Click()

Dim objUtil As AcadUtility
Dim objNote As AcadMText
Dim objLeader As AcadLeader
Dim objLayer As AcadLayer
Dim strSheetNote As String
Dim varPnt As Variant
Dim dblPnts(5) As Double
Dim dblMin(2) As Double
Dim strPrompt As String

On Error GoTo ErrControl

Set objUtil = ThisDrawing.Utility
strPrompt = vbCrLf & "Pick Insertion Point for Annotation: "
Me.hide
With objUtil

.InitializeUserInput 32
varPnt = .GetPoint(Prompt:=strPrompt)
strSheetNote = lstSheetNotes.Value
Set objNote = ThisDrawing.ModelSpace.AddMText(varPnt, 0, strSheetNote)
objNote.Width = 90
objNote.StyleName = "Romans"
objNote.Height = 4.5
objNote.AttachmentPoint = acAttachmentPointTopCenter
dblPnts(3) = dblMin(0)
dblPnts(4) = dblMin(1)
dblPnts(5) = dblMin(2)
strPrompt = vbCrLf & "Pick Point for Leader Arrow:"
.InitializeUserInput 32
varPnt = .GetPoint(dblMin, strPrompt)
dblPnts(0) = varPnt(0)
dblPnts(1) = varPnt(1)

End With

Set objLeader = ThisDrawing.ModelSpace.AddLeader(dblPnts, objNote, acLineWithArrow)
objLeader.StyleName = "1_4TH"
Exit Sub

ErrControl:
If Err.Description = "User input is a Keyword" Then
Err.Clear
Exit Sub
Else
MsgBox Err.Description
End If
End Sub
0 Likes
281 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Hi perriwinkle,
I changed several things with your code, most of it was order. I also removed the with, I felt it was getting in the way for now (debugging). where dblPnts(3) = dblMin(0) were being set to 0's Anyway the revised code posted will do what you require.

Private Sub lstSheetNotes_Click()

Dim objUtil As AcadUtility
Dim objNote As AcadMText
Dim objLeader As AcadLeader
Dim objLayer As AcadLayer
Dim strSheetNote As String
Dim varPnt As Variant
Dim dblPnts(5) As Double
Dim dblMin(2) As Double
Dim strPrompt As String

On Error GoTo ErrControl
Me.Hide
Set objUtil = ThisDrawing.Utility
strPrompt = vbCrLf & "Pick Insertion Point for Annotation: "
objUtil.InitializeUserInput 32
varPnt = objUtil.GetPoint(Prompt:=strPrompt)
strSheetNote = lstSheetNotes.Value
'strSheetNote = "Fried Taters" '<-test information
Set objNote = ThisDrawing.ModelSpace.AddMText(varPnt, 0, strSheetNote)
objNote.Width = 90
objNote.StyleName = "Romans"
'objNote.StyleName = "Standard" '<-test information
objNote.Height = 4.5
objNote.AttachmentPoint = acAttachmentPointTopCenter
dblPnts(3) = varPnt(0)
dblPnts(4) = varPnt(1)
dblPnts(5) = varPnt(2)
strPrompt = vbCrLf & "Pick Point for Leader Arrow:"
'.InitializeUserInput 32
varPnt = objUtil.GetPoint(, strPrompt)
dblPnts(0) = varPnt(0)
dblPnts(1) = varPnt(1)

'End With

Set objLeader = ThisDrawing.ModelSpace.AddLeader(dblPnts, objNote, acLineWithArrow)
objLeader.StyleName = "1_4TH"
ThisDrawing.Regen acActiveViewport
Me.Show
Exit Sub

ErrControl:
If Err.Description = "User input is a Keyword" Then
Err.Clear
Exit Sub
Else
MsgBox Err.Description
End If
End Sub
0 Likes
Message 3 of 3

Anonymous
Not applicable
YOU ROCK!! thanks.
0 Likes