GetEntity Fails
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
GetEntity Fails

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
Allen Johnson
Guest





Posted: Fri Dec 03, 2004 7:46 pm    Post subject: GetEntity Fails Reply with quote

Seems that the first time this command button gets fired, I get an error at
the line

ThisDrawing.Utility.GetEntity entObj, txtpp, "Select text to insert:"

Method 'GetEntity' of object 'IAcadUtility' failed

Any ideas what I'm doing wrong?

----------------------------------------------------------------------------
----------------
Private Sub cmdAppend_Click()
Dim entObj As AcadObject, txtpp As Variant

Me.Hide
'On Error Resume Next
Err.Clear
ThisDrawing.Utility.GetEntity entObj, txtpp, "Select text to insert:"
If Err.Number <> 0 Then
Label1.Caption = "Nothing selected..."
Me.Show
Exit Sub
End If

If entObj.ObjectName = "AcDbText" Then
txtNotes.SelText = " " & Trim(entObj.TextString) & " "
TextString = txtNotes.Text
If chkDelAppendText.Value = True Then entObj.Delete
Else
ThisDrawing.Utility.Prompt "Not a text object..."
Label1.Caption = "Not a text object..."
End If

Me.Show
End Sub

Back to top
VBA
Guest





Posted: Fri Dec 03, 2004 9:06 pm    Post subject: Re: GetEntity Fails Reply with quote

Private Sub cmdAppend_Click()
Dim entObj As AcadObject, txtpp As Variant
Dim TextString As String

Me.Hide

On Error Resume Next

ThisDrawing.Utility.GetEntity entObj, txtpp, "Select text to insert:"

If Err.Number <> 0 Then
Label1.Caption = "Nothing selected..."
Me.Show
Exit Sub
End If

If entObj.ObjectName = "AcDbText" Then
txtNotes.SelText = " " & Trim(entObj.TextString) & " "
TextString = txtNotes.Text
If chkDelAppendText.Value = True Then entObj.Delete

Else
ThisDrawing.Utility.Prompt "Not a text object..."
Label1.Caption = "Not a text object..."
End If

Me.Show
End Sub


"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b07c58$1_2@newsprd01...
Quote:
Seems that the first time this command button gets fired, I get an error
at
the line

ThisDrawing.Utility.GetEntity entObj, txtpp, "Select text to insert:"

Method 'GetEntity' of object 'IAcadUtility' failed

Any ideas what I'm doing wrong?

--------------------------------------------------------------------------
--
----------------
Private Sub cmdAppend_Click()
Dim entObj As AcadObject, txtpp As Variant

Me.Hide
'On Error Resume Next
Err.Clear
ThisDrawing.Utility.GetEntity entObj, txtpp, "Select text to insert:"
If Err.Number <> 0 Then
Label1.Caption = "Nothing selected..."
Me.Show
Exit Sub
End If

If entObj.ObjectName = "AcDbText" Then
txtNotes.SelText = " " & Trim(entObj.TextString) & " "
TextString = txtNotes.Text
If chkDelAppendText.Value = True Then entObj.Delete
Else
ThisDrawing.Utility.Prompt "Not a text object..."
Label1.Caption = "Not a text object..."
End If

Me.Show
End Sub

Back to top
Allen Johnson
Guest





Posted: Fri Dec 03, 2004 9:13 pm    Post subject: Re: GetEntity Fails Reply with quote

Are you saying to remove the remark comment on the On Error Resume Next?
Also TextString is a Public variable of the form, so it isn't that it is not
declared in the routine.
By not using Option Explicit would fix that anyway, but that is getting off
topic!

Neither fixes the problem of why the GetEntity method errors out in the
first place.
Why do I get that error to begin with?

Back to top
VBA
Guest





Posted: Sat Dec 04, 2004 12:56 am    Post subject: Re: GetEntity Fails Reply with quote

Uncomment the On Error ....

Delete the Err.Clear statement, it's not needed.

Do that and it works as prescribed.

"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b090a7_1@newsprd01...
Quote:
Are you saying to remove the remark comment on the On Error Resume Next?
Also TextString is a Public variable of the form, so it isn't that it is
not
declared in the routine.
By not using Option Explicit would fix that anyway, but that is getting
off
topic!

Neither fixes the problem of why the GetEntity method errors out in the
first place.
Why do I get that error to begin with?

Back to top
Allen Johnson
Guest





Posted: Sat Dec 04, 2004 1:10 am    Post subject: Re: GetEntity Fails Reply with quote

Not on my machine... That's why I posted.


"VBA" <nospam@nowhere.com> wrote in message news:41b0c4e2$1_3@newsprd01...
Quote:
Uncomment the On Error ....

Delete the Err.Clear statement, it's not needed.

Do that and it works as prescribed.
Back to top
VBA
Guest





Posted: Mon Dec 06, 2004 5:47 pm    Post subject: Re: GetEntity Fails Reply with quote

Then I'd say you have a problem with your install.

Re-install AutoCAD.


"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b0c84c$1_3@newsprd01...
Quote:
Not on my machine... That's why I posted.


"VBA" <nospam@nowhere.com> wrote in message news:41b0c4e2$1_3@newsprd01...
Uncomment the On Error ....

Delete the Err.Clear statement, it's not needed.

Do that and it works as prescribed.


Back to top
Allen Johnson
Guest





Posted: Mon Dec 06, 2004 7:16 pm    Post subject: Re: GetEntity Fails Reply with quote

You're funny.

"VBA" <nospam@nowhere.com> wrote in message news:41b454e2_3@newsprd01...
Quote:
Then I'd say you have a problem with your install.

Re-install AutoCAD.


"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b0c84c$1_3@newsprd01...
Not on my machine... That's why I posted.


"VBA" <nospam@nowhere.com> wrote in message
news:41b0c4e2$1_3@newsprd01...
Uncomment the On Error ....

Delete the Err.Clear statement, it's not needed.

Do that and it works as prescribed.




Back to top
VBA
Guest





Posted: Mon Dec 06, 2004 7:24 pm    Post subject: Re: GetEntity Fails Reply with quote

Well, maybe so - but I'll bet ya I'm right!

"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b469c3$1_1@newsprd01...
Quote:
You're funny.

"VBA" <nospam@nowhere.com> wrote in message news:41b454e2_3@newsprd01...
Then I'd say you have a problem with your install.

Re-install AutoCAD.


"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b0c84c$1_3@newsprd01...
Not on my machine... That's why I posted.


"VBA" <nospam@nowhere.com> wrote in message
news:41b0c4e2$1_3@newsprd01...
Uncomment the On Error ....

Delete the Err.Clear statement, it's not needed.

Do that and it works as prescribed.






Back to top
R. Robert Bell
Guest





Posted: Tue Dec 07, 2004 2:32 am    Post subject: Re: GetEntity Fails Reply with quote

Allen,

I have no trouble running your code, stripped down, so something is odd on
your end. Are you running the VBA directly from a macro, or with a LISP
wrapper? What version of AutoCAD?

P.S. I would declare entObj as AcadEntity, not AcadObject. AcadObject
includes non-graphical objects such as dictionaries.

--
R. Robert Bell


"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b07c58$1_2@newsprd01...
Seems that the first time this command button gets fired, I get an error at
the line

ThisDrawing.Utility.GetEntity entObj, txtpp, "Select text to insert:"

Method 'GetEntity' of object 'IAcadUtility' failed

Any ideas what I'm doing wrong?

----------------------------------------------------------------------------
----------------
Private Sub cmdAppend_Click()
Dim entObj As AcadObject, txtpp As Variant

Me.Hide
'On Error Resume Next
Err.Clear
ThisDrawing.Utility.GetEntity entObj, txtpp, "Select text to insert:"
If Err.Number <> 0 Then
Label1.Caption = "Nothing selected..."
Me.Show
Exit Sub
End If

If entObj.ObjectName = "AcDbText" Then
txtNotes.SelText = " " & Trim(entObj.TextString) & " "
TextString = txtNotes.Text
If chkDelAppendText.Value = True Then entObj.Delete
Else
ThisDrawing.Utility.Prompt "Not a text object..."
Label1.Caption = "Not a text object..."
End If

Me.Show
End Sub
Back to top
Allen Johnson
Guest





Posted: Tue Dec 07, 2004 3:41 am    Post subject: Re: GetEntity Fails Reply with quote

Yeah, it seems to generate the error on my machine only (of course!)
The entire routine is called from within lisp.
But if I click the button a second time, the routine works.

Guess I'll try VBA's suggestion of re-installing AutoCAD... then again,
maybe I'll wait until R2006!
Probably less of a hassle!



"R. Robert Bell" <NOT.RobertB@MWEngineers.com> wrote in message
news:41b4d001$1_2@newsprd01...
Quote:
Allen,

I have no trouble running your code, stripped down, so something is odd on
your end. Are you running the VBA directly from a macro, or with a LISP
wrapper? What version of AutoCAD?

P.S. I would declare entObj as AcadEntity, not AcadObject. AcadObject
includes non-graphical objects such as dictionaries.

--
R. Robert Bell
Back to top
R. Robert Bell
Guest





Posted: Tue Dec 07, 2004 3:45 am    Post subject: Re: GetEntity Fails Reply with quote

What happens when you load the form using -VBARun at the command prompt
(skipping the LISP wrapper)?

--
R. Robert Bell


"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b4e023$1_1@newsprd01...
Yeah, it seems to generate the error on my machine only (of course!)
The entire routine is called from within lisp.
But if I click the button a second time, the routine works.

Guess I'll try VBA's suggestion of re-installing AutoCAD... then again,
maybe I'll wait until R2006!
Probably less of a hassle!



"R. Robert Bell" <NOT.RobertB@MWEngineers.com> wrote in message
news:41b4d001$1_2@newsprd01...
Quote:
Allen,

I have no trouble running your code, stripped down, so something is odd on
your end. Are you running the VBA directly from a macro, or with a LISP
wrapper? What version of AutoCAD?

P.S. I would declare entObj as AcadEntity, not AcadObject. AcadObject
includes non-graphical objects such as dictionaries.

--
R. Robert Bell
Back to top
Allen Johnson
Guest





Posted: Tue Dec 07, 2004 4:00 am    Post subject: Re: GetEntity Fails Reply with quote

Then that portion of the code seems to work. But it still errors out when
calling the .GetDistance method (which is used in another routine on the
form). TextObj and TextString are public variables.

Private Sub cmdPickSplitDist_Click()
Dim PickDistance As Double
Me.Hide
TextString = txtNotes.Text
On Error Resume Next
Err.Clear
PickDistance = ThisDrawing.Utility.GetDistance(TextObj.InsertionPoint,
"Maximum text length:")
If Err.Number <> 0 Then
Label1.Caption = "Try again..."
Me.Show
Exit Sub
End If
txtSplitDist.Text = Format(PickDistance, "0.00")
Call cmdSplitText_Click
Me.Show

End Sub


"R. Robert Bell" <NOT.RobertB@MWEngineers.com> wrote in message
news:41b4e0f3$1_3@newsprd01...
Quote:
What happens when you load the form using -VBARun at the command prompt
(skipping the LISP wrapper)?

--
R. Robert Bell
Back to top
R. Robert Bell
Guest





Posted: Tue Dec 07, 2004 7:02 am    Post subject: Re: GetEntity Fails Reply with quote

Your original posted code does not show the global variable being assigned
to the picked object. Heavy pre-post editing I assume, but that's all I can
surmise given the posted code.

--
R. Robert Bell


"Allen Johnson" <ajohnson@dwase> wrote in message
news:41b4e49f$1_1@newsprd01...
Then that portion of the code seems to work. But it still errors out when
calling the .GetDistance method (which is used in another routine on the
form). TextObj and TextString are public variables.

Private Sub cmdPickSplitDist_Click()
Dim PickDistance As Double
Me.Hide
TextString = txtNotes.Text
On Error Resume Next
Err.Clear
PickDistance = ThisDrawing.Utility.GetDistance(TextObj.InsertionPoint,
"Maximum text length:")
If Err.Number <> 0 Then
Label1.Caption = "Try again..."
Me.Show
Exit Sub
End If
txtSplitDist.Text = Format(PickDistance, "0.00")
Call cmdSplitText_Click
Me.Show

End Sub


"R. Robert Bell" <NOT.RobertB@MWEngineers.com> wrote in message
news:41b4e0f3$1_3@newsprd01...
Quote:
What happens when you load the form using -VBARun at the command prompt
(skipping the LISP wrapper)?

--
R. Robert Bell
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB