what is wrong with my program.

Discussion in 'AutoCAD' started by youngman, Aug 19, 2003.

  1. youngman

    youngman Guest

    hi,here is my problem.

    the following items are all ok firt time i run it,but when i start the for
    for a second time ,fatal error will appaer.
    what is wrong with my program.
    thank you.



    Dim Obj1 As AcadEntity
    Dim datax As Double
    Dim datay As Double
    Dim dataz As Double
    Dim returnPnt1 As Variant
    Dim returnPnt2 As Variant
    Dim copyCircleObj As AcadCircle
    Dim I As Integer
    Dim returnPnt3(0 To 2) As Double
    Dim ssetObj1 As AcadSelectionSet
    Sub basicpnt()
    Set ssetObj1 = ThisDrawing.SelectionSets.Add("00")
    ssetObj1.SelectOnScreen
    returnPnt1 = ThisDrawing.Utility.GetPoint(, "Enter a point: ")
    returnPnt2 = ThisDrawing.Utility.GetPoint(, "Enter a point: ")
    End Sub
    Sub objcopy()
    x = returnPnt1(0) - returnPnt2(0)
    y = returnPnt1(1) - returnPnt2(1)
    z = returnPnt1(2) - returnPnt2(2)
    'MsgBox x
    returnPnt3(0) = returnPnt1(0) - I * x
    returnPnt3(1) = returnPnt1(1) - I * y
    returnPnt3(2) = returnPnt1(2) - I * z
    'MsgBox ssetObj.Count
    For Each obj In ssetObj1
    On Error GoTo out
    Set Obj1 = obj.copy()
    Obj1.Layer = obj.Layer '
    Obj1.Move returnPnt1, returnPnt3
    Obj1.Color = acRed
    Update
    Next
    'ssetObj.Delete
    out:
    End Sub
    Private Sub CommandButton1_Click()
    For Each selset In ThisDrawing.SelectionSets
    If selset.name = "00" Then
    selset.Delete
    End If
    Next
    Me.Hide
    I = 1
    basicpnt
    objcopy
    CommandButton2.Enabled = True
    CommandButton1.Enabled = False
    Me.Show
    End Sub
    Private Sub CommandButton2_Click()
    Me.Hide
    I = I + 1
    objcopy
    TextBox1.value = I
    Me.Show
    End Sub

    Private Sub CommandButton3_Click()
    Me.Hide
    UserForm1.Show
    End Sub

    Private Sub UserForm_Initialize()
    CommandButton2.Enabled = False
    For Each selset In ThisDrawing.SelectionSets
    If selset.name = "00" Then
    selset.Delete
    End If
    Next
    TextBox1.value = 0
    End Sub
     
    youngman, Aug 19, 2003
    #1
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.