Jump to content

Recommended Posts

Posted

Using AutoCAD 12 (64bit), VB 2008 express ed.

 

I am getting HResult 0x800700007E When I use this statement

Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

I am linked to AutoCAD 2012.

 

 

Any suggestions

Posted

Try changing this:

 

Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.D  ocumentManager.MdiActiveDocument

 

... To this:

 

Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

 

** I removed the space after the "D" in "D ocumentManager" :thumbsup:

 

Separately, if you use:

 

Imports Autodesk.AutoCAD.ApplicationServices

 

... At the top of your class (before the namespace), then you can simply use this in your Sub/Function:

 

Dim doc As Document = Application.DocumentManager.MdiActiveDocument

 

HTH

Posted

The space after the d is removed

I have the code

Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

but I cut and Paste it in this post I see a space. Maybe there is a hidden character there?

Any other suggestions?

Thank you

Posted

You did it again... You state that there's no space, yet you post code WITH the space.

 

Try this:

 


Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime

Imports System

'This line is not mandatory, but improves loading performance
<Assembly: CommandClass(GetType(Foo.FooCLass))> 

Namespace Foo

   Public Class FooCLass

       <CommandMethod("FOO")> _
       Public Sub FOO()
           Dim doc As Document = _
               Application.DocumentManager.MdiActiveDocument
           If doc <> Nothing Then
               MsgBox("Yay!")
           Else
               MsgBox("Boo!")
           End If
       End Sub

   End Class

End Namespace

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...