Results 1 to 5 of 5

Thread: region problem

  1. #1
    Join Date
    Dec 2008
    Posts
    3

    Post region problem

    Dear all
    Im a new user of Autocad VBA
    i have aproblem on making region
    i make code for making lines and arcs and make region for there
    but it make aproblem " Run-time error13" type mismatch


    Private Sub CommandButton1_Click()
    ' declear variabales
    Const PI = 3.14159265358979
    Dim line1 As AcadLine
    Dim line2 As AcadLine
    Dim line3 As AcadLine
    Dim arc1 As AcadArc
    Dim center1(2) As Double
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    Dim point3(0 To 2) As Double
    Dim point4(0 To 2) As Double

    point1(0) = 10: point1(1) = 10: point1(2) = 0
    point2(0) = 50: point2(1) = 10: point2(2) = 0
    point3(0) = 50: point3(1) = 20: point3(2) = 0
    point4(0) = 10: point4(1) = 20: point4(2) = 0

    Set line1 = ThisDrawing.ModelSpace.AddLine(point1, point2)
    Set line2 = ThisDrawing.ModelSpace.AddLine(point3, point4)
    Set line3 = ThisDrawing.ModelSpace.AddLine(point4, point1)
    center1(0) = line1.EndPoint(0): center1(1) = line1.EndPoint(1) + 5
    center1(2) = 0
    Set arc1 = ThisDrawing.ModelSpace.AddArc(center1, 5, 3 / 2 * PI, 1 / 2 * PI)
    ' make array for region
    Dim arrayobj(3) As AcadEntity
    Set arrayobj(0) = line1
    Set arrayobj(1) = arc1
    Set arrayobj(2) = line2
    Set arrayobj(3) = line3
    ' make the region from the array

    Set regn = ThisDrawing.ModelSpace.AddRegion(arrayobj)
    end sub

  2. #2
    Join Date
    Nov 2008
    Posts
    3
    Code:
    Dim regn As Variant
    ska

  3. #3
    Join Date
    Dec 2008
    Posts
    3

    Post Many thanks from Tarek

    many thanks for you
    i forget to mention this in my code
    the ( dim regn as variable ) is already in my code but it make the same problem
    please see the code
    Const PI = 3.14159265358979
    Dim line1 As AcadLine
    Dim line2 As AcadLine
    Dim line3 As AcadLine
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    Dim point3(0 To 2) As Double
    Dim point4(0 To 2) As Double
    point1(0) = 10: point1(1) = 10: point1(2) = 0
    point2(0) = 50: point2(1) = 10: point2(2) = 0
    point3(0) = 50: point3(1) = 20: point3(2) = 0
    point4(0) = 10: point4(1) = 20: point4(2) = 0
    Set line1 = ThisDrawing.ModelSpace.AddLine(point1, point2)
    Set line2 = ThisDrawing.ModelSpace.AddLine(point3, point4)
    Set line3 = ThisDrawing.ModelSpace.AddLine(point4, point1)
    'drraw arc
    Dim arc1 As AcadArc
    Dim center1(2) As Double
    center1(0) = line1.EndPoint(0): center1(1) = line1.EndPoint(1) + 5: center1(2) = 0
    Set arc1 = ThisDrawing.ModelSpace.AddArc(center1, 5, 3 / 2 * PI, 1 / 2 * PI)
    ' make array for region
    Dim arrayobj(3) As AcadEntity
    Set arrayobj(0) = line1
    Set arrayobj(1) = arc1
    Set arrayobj(2) = line2
    Set arrayobj(3) = line3
    ' make the region from the array
    Dim regn As Variant
    Set regn = ThisDrawing.ModelSpace.AddRegion(arrayobj)

  4. #4
    Join Date
    Nov 2008
    Posts
    3
    Change
    Code:
    Set regn = ThisDrawing.ModelSpace.AddRegion(arrayobj)
    To
    Code:
    regn = ThisDrawing.ModelSpace.AddRegion(arrayobj)
    ska

  5. #5
    Join Date
    Dec 2008
    Posts
    3

    Smile thanks for you efforts

    Dear Aka
    Have a nice day
    many thanks for your efforts it is so good and worked
    please accept my best regards
    Eng / Tarek Said

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •