AutoCAD Land Desktop

Reply
Contributor
Andrea1
Posts: 15
Registered: ‎03-21-2003
Message 1 of 2 (66 Views)

Using AeccApplication

66 Views, 1 Replies
03-13-2002 01:01 AM
Hello All,

I'm kind of new to VBA with AutoCAD programming...
What I'm trying to do seems easy enough - obtain info about the current active project in land-desktop. I have a form with a button that just flashes the name of the active project. When I execute this code, it fails on line 4 saying that the class factory can't supply the requested class. I am referencing the following libraries:
VBA, AutoCAD 2000 Type Library, OLE Automation, Microsoft Forms 2.0 Object Library, AEC Base 3.0 Application Library, AEC Base 3.3 Object Library, Autodesk Land 1.2 Type Library

1 Private Sub CommandButton1_Click()

2 ' This example returns the name of the ActivProject.
3 Dim activeProj As AeccProject
4 Set activeProj = AeccApplication.ActiveProject

5 MsgBox "The ActiveProject is: " & activeProj.Name, _
6 vbInformation, "ActiveProject Example"


7 End Sub

I guess what I need to know is how to use Aecc objects from the VBA editor in land desktop. When I use the ThisDrawing.Application.GetInterfaceObject("Aecc.Application") method of obtaining AeccApplication, I get an error saying it can't load the application. These are being launched from a macro within the open ldd, so I can't figure out what's wrong.

Any help would be appreciated!

Andrea
*Albert, Glen
Message 2 of 2 (66 Views)

Re: Using AeccApplication

03-18-2002 09:36 PM in reply to: Andrea1
Andrea

 

Try this. I also threw in a basic error trap to
abort if the dwg isn't attached to a project.

 

Private Sub CommandButton1_Click()

 

    Dim AecApp As new
AeccApplication

    Dim activeProj As
AeccProject 
    

    AecApp .Init
ThisDrawing.Application

    On Error GoTo
noProject
    Set Proj = AeccApp.ActiveProject

    On Error Goto 0

 

   
size=2>MsgBox "The ActiveProject is: " & activeProj.Name,

    vbInformation, "ActiveProject Example"

   

Exit Sub

 

NoProject:

'  abort if it's an unamed drawing, or it
isn't assoc with a proj

     MsgBox "Error: There must
be an active Land Project.", vbOKOnly

 

End Sub

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hello
All,

I'm kind of new to VBA with AutoCAD programming...
What I'm trying to
do seems easy enough - obtain info about the current active project in
land-desktop. I have a form with a button that just flashes the name of the
active project. When I execute this code, it fails on line 4 saying that the
class factory can't supply the requested class. I am referencing the following
libraries:
VBA, AutoCAD 2000 Type Library, OLE Automation, Microsoft Forms
2.0 Object Library, AEC Base 3.0 Application Library, AEC Base 3.3 Object
Library, Autodesk Land 1.2 Type Library

1 Private Sub CommandButton1_Click()

2 ' This example returns the name of the ActivProject.
 3 Dim
activeProj As AeccProject
 4 Set activeProj =
AeccApplication.ActiveProject

5 MsgBox "The ActiveProject is: " & activeProj.Name, _

  6 vbInformation, "ActiveProject Example"


7 End Sub

I guess what I need to know is how to use Aecc objects from the VBA editor
in land desktop. When I use the
ThisDrawing.Application.GetInterfaceObject("Aecc.Application") method of
obtaining AeccApplication, I get an error saying it can't load the
application. These are being launched from a macro within the open ldd, so I
can't figure out what's wrong.

Any help would be appreciated!

Andrea

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!