Tools.AddtoModelSpace throws an unhandled exception

Jun 12, 2008 at 11:21 AM

Hi All,
I'm a complete newbie with VB.Net & ARX.Net.  I am using VS2008 and trying to put together my first .net app for Acad 2008.  I have downloaded and installed the ObjectARX app wizard for VS2008 & Acad2008 and have used the autogenerated Class as my starting point.  I have also downloaded and installed DotNetARX.
I have written a simple Sub in a code module as below.  When I call this sub directly from within a <CommandMethod()> within the Class built by the objectarx app wizard it runs without problem.  When it is called by an 'on click' event handler of a button on a form which is loaded using Application.ShowModelessDialog() within the <CommandMethod()> of the autogenerated class it throws an un-handled exception at the first call to Tools.AddtoModelSpace().  Note that the preceding Tools.ZoomWindow() does not throw the exception.
Can anyone tell me what I am doing wrong or what I might have to do to the Form module in order to successfully write to the active modelspace from an event triggered by the form.
Thanks
G.



Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Geometry
Imports DNA

Module Module1
    Sub DoIt()

        Dim ln As Line = New Line(New Point3d(0, 0, 0), New Point3d(1000, 1000, 0))
        Dim db As Database = HostApplicationServices.WorkingDatabase
        Tools.ZoomWindow(New Point3d(0, 0, 0), New Point3d(1000, 1000, 0))
        Tools.AddToModelSpace(ln, db)
        Tools.ZoomCenter(New Point3d(500, 500, 0), 1100)

        For x As Integer = 0 To 1000 Step 10
            For y As Integer = 0 To 1000 Step 10
                Dim circ As Circle = New Circle
                circ.Center = New Point3d(x, y, 0)
                circ.Radius = 0.5
                Tools.AddToModelSpace(circ, db)
                Application.UpdateScreen()
            Next
        Next

    End Sub

End Module

Coordinator
Jun 20, 2008 at 3:23 PM
You must lock the document.

 

Jul 9, 2008 at 10:41 PM

Thanks for your reply csharpbird. 
I have not figured out what you mean but will be researching 'locking the document'.  Any further help would be greatly appreciated.  Thanks again.

G.


csharpbird wrote:
You must lock the document.