run-time error no database

Discussion in 'AutoCAD' started by Leonard Johnson, Jul 28, 2004.

  1. I'm new to programming. Any thoughts as to why I getting this error?
    Thanks.
     
    Leonard Johnson, Jul 28, 2004
    #1
  2. Leonard Johnson

    Joe Sutphin Guest

    Just a couple of questions.

    First, are we talking about VBA or VB?

    Second, do you have a drawing open?

    Third, can you perhaps post the offending code?

    Joe
     
    Joe Sutphin, Jul 28, 2004
    #2
  3. The code worked for me.

    Try using the <F8> to step thru your code, line by line. What line does the
    error occur on?

    --
    R. Robert Bell


    VBA I believe because its within AutoCAD. The code I'm using is from the
    samples that Autodesk provides. Yes I have a drawing open.

    Here is the code:

    Sub Example_Layer()
    ' This example creates a new layer named "ABC" (colored red.)
    ' It then creates a circle and assigns it to layer "ABC"

    ' Create new layer
    Dim layerObj As AcadLayer
    Set layerObj = ThisDrawing.Layers.Add("ABC")
    layerObj.Color = acRed

    ' Create Circle
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 3: center(1) = 3: center(2) = 0
    radius = 1.5
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
    ZoomAll
    MsgBox "The circle has been created on layer " & circleObj.Layer, ,
    "Layer Example"

    ' Set the layer of new circle to "ABC"
    circleObj.Layer = "ABC"

    ' Refresh view
    ThisDrawing.Regen (True)
    MsgBox "The circle is now on layer " & circleObj.Layer, , "Layer
    Example"

    End Sub
     
    R. Robert Bell, Jul 28, 2004
    #3
  4. Are you *sure* you are using AutoCAD's VBA?

    Command: VBAIDE
     
    R. Robert Bell, Jul 28, 2004
    #4
  5. Leonard Johnson

    Joe Sutphin Guest

    Did you properly declare the aline, startpoint, and endpoint variables like
    the following

    Dim aline As AcadLine
    Dim StartPoint(2) As Double
    Dim EndPoint(2) As Double

    and did you initialize the StartPoint and EndPoint variables with values
    like the following

    StartPoint(0)=0:StartPoint(1)=0:StartPoint(2)=0
    EndPoint(0)=1:EndPoint(1)=1:EndPoint(2)=0

    This would be the coordinates to draw a line at 45 degrees from 0,0 to 1,1

    Joe
    --
     
    Joe Sutphin, Jul 28, 2004
    #5
  6. That line is *not* in the code you posted.
     
    R. Robert Bell, Jul 28, 2004
    #6
  7. VBA I believe because its within AutoCAD. The code I'm using is from the
    samples that Autodesk provides. Yes I have a drawing open.

    Here is the code:

    Sub Example_Layer()
    ' This example creates a new layer named "ABC" (colored red.)
    ' It then creates a circle and assigns it to layer "ABC"

    ' Create new layer
    Dim layerObj As AcadLayer
    Set layerObj = ThisDrawing.Layers.Add("ABC")
    layerObj.Color = acRed

    ' Create Circle
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 3: center(1) = 3: center(2) = 0
    radius = 1.5
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
    ZoomAll
    MsgBox "The circle has been created on layer " & circleObj.Layer, ,
    "Layer Example"

    ' Set the layer of new circle to "ABC"
    circleObj.Layer = "ABC"

    ' Refresh view
    ThisDrawing.Regen (True)
    MsgBox "The circle is now on layer " & circleObj.Layer, , "Layer
    Example"

    End Sub
     
    Leonard Johnson, Jul 28, 2004
    #7
  8. Set aline = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
     
    Leonard Johnson, Jul 28, 2004
    #8
  9. Sorry, its

    Set layerObj = ThisDrawing.Layers.Add("ABC")
     
    Leonard Johnson, Jul 28, 2004
    #9
  10. I give. The only thing I can suggest is to restart your computer and try the
    code again.
     
    R. Robert Bell, Jul 28, 2004
    #10
  11. No matter what code I use, I'm getting the same error with any line that
    starts with Set.
     
    Leonard Johnson, Jul 28, 2004
    #11
  12. Yes, I have same thing showing.

     
    Leonard Johnson, Jul 28, 2004
    #12
  13. I have re-installed AuoCAD and it works fine now.
    sorry for the bother.
     
    Leonard Johnson, Jul 28, 2004
    #13
  14. No bother. Happy to have "helped".

    --
    R. Robert Bell


    I have re-installed AuoCAD and it works fine now.
    sorry for the bother.
     
    R. Robert Bell, Jul 29, 2004
    #14
  15. Thanks Terry. I was just verifying that we were on the same tree.

    --
    R. Robert Bell


    I've had the same error, yes in VBA.

    Terry
     
    R. Robert Bell, Jul 29, 2004
    #15
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.