Arc

Discussion in 'AutoCAD' started by Kumar, Feb 28, 2004.

  1. Kumar

    Kumar Guest

    I want to draw arc using VBA. For this required input is center, radius, start and end angles.

    But in my case I have Start point,end point and radius. I can draw arc using theses parameters in Autocad, but don't know how i can draw arc in VBA using these given parameters.

    Does any wany suggest me way to do so ??

    regards
     
    Kumar, Feb 28, 2004
    #1
  2. Kumar

    egc Guest

    Some basic math may help here. Unless one of the points is tangential
    and you also specify CW/CCW order of the points, there are mutiple arcs
    that can be drawn with start/end point and the radius. Try it in
    AutoCAD and you will see what I mean.
     
    egc, Feb 28, 2004
    #2
  3. Kumar

    Kumar Guest

    hello, thanks for reply
    my arc is drawn in counter clock wise and I could not find multiple arcs in Vba. Can you give me more hints about it?

    details
     
    Kumar, Feb 28, 2004
    #3
  4. This might help you. (No error checking at all):


    Public myarc As AcadArc
    Public Const pi As Double = 3.14159265358979

    Public Sub DrawArcSER(sp As Variant, ep As Variant, rad As Double)
    Dim h As Double
    Dim b As Double
    Dim ls As Double
    Dim mp As Variant
    Dim cp As Variant
    Dim sa As Double
    Dim ea As Double

    b = ThisDrawing.Utility.AngleFromXAxis(sp, ep)
    ls = Sqr((sp(0) - ep(0)) ^ 2 + (sp(1) - ep(1)) ^ 2)
    mp = ThisDrawing.Utility.PolarPoint(sp, b, ls / 2#)
    h = Sqr(rad ^ 2 - (ls / 2#) ^ 2)
    cp = ThisDrawing.Utility.PolarPoint(mp, b + (pi / 2#), h)
    sa = ThisDrawing.Utility.AngleFromXAxis(cp, sp)
    ea = ThisDrawing.Utility.AngleFromXAxis(cp, ep)

    Set myarc = ThisDrawing.ModelSpace.AddArc(cp, rad, sa, ea)

    End Sub

    'example of how to use the DrawArcSER sub

    Sub DARC()
    Dim spoint As Variant
    Dim epoint As Variant
    Dim radius As Double

    spoint = ThisDrawing.Utility.GetPoint(, "Arc Start Point:")
    epoint = ThisDrawing.Utility.GetPoint(spoint, "Arc End Point:")
    radius = ThisDrawing.Utility.GetDistance(spoint, "Arc Radius:")

    Call DrawArcSER(spoint, epoint, radius)

    End Sub

    --
    Saludos, Ing. Jorge Jimenez, SICAD S.A., Costa Rica
    (sorry, phony e-mail, SPAM made me do it)

    using theses parameters in Autocad, but don't know how i can draw arc in VBA
    using these given parameters.
     
    Jorge Jimenez, Feb 28, 2004
    #4
  5. If Jorge's example [nice one:)] doesn't help, check out
    http://vbdesign.net.

    ___________________________
    Mike Tuersley
    CADalyst's AutoCAD Clinic
    Rand IMAGINiT Technologies
     
    Mike Tuersley, Feb 29, 2004
    #5
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.