AutoCAD Land Desktop (Read Only)
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using AeccApplication

1 REPLY 1
Reply
Message 1 of 2
Andrea1
225 Views, 1 Reply

Using AeccApplication

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
1 REPLY 1
Message 2 of 2
Anonymous
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report