Draw a circle in VBA with user input?

Discussion in 'AutoCAD' started by PJS5, Aug 20, 2003.

  1. PJS5

    PJS5 Guest

    Would someone like to help me with a piece of code that will let me pick the
    centre point of my circle, but drag for the diameter as opposed to my
    current code which draws only at my nominated radius.
    (ie replace "treeRad=5#", with ??????)
    Thanks in advance,
    regards Peter

    ***************** snip ******************
    Sub CommandButton8_Click()
    'Add tree to property
    If TextBox1.Text <> "" And TextBox2.Text <> "" And TextBox3.Text <> ""
    And TextBox4.Text <> "" Then
    'Draw tree
    Dim treeObj As AcadEntity
    Dim treePnt(0 To 2) As Double
    Dim treeRad As Double
    Dim PntA As Variant
    UserForm2.Hide
    PntA = ThisDrawing.Utility.GetPoint(, "Pick tree point: ")
    treePnt(0) = PntA(0): treePnt(1) = PntA(1): treePnt(2) = PntA(2)
    treeRad = 5#
    Set treeObj = ThisDrawing.ModelSpace.AddCircle(treePnt, treeRad)
    'Add record
    hand$ = treeObj.Handle
    rstObj.AddNew
    rstObj!entityhandle = hand$
    rstObj!Type = TextBox1.Text
    rstObj!age = TextBox2.Text
    rstObj!water = TextBox3.Text
    rstObj!cost = TextBox4.Text
    rstObj.Update
    rstObj.MoveLast
    'Update tree record frame
    hstr = rstObj!entityhandle.Value
    If Not hstr = "" Then Label2.Caption = hstr Else Label2.Caption = ""
    TextBox1.Text = rstObj!Type.Value
    TextBox2.Text = Format(rstObj!age.Value, "0.00####")
    TextBox3.Text = Format(rstObj!water.Value, "0.00####")
    TextBox4.Text = Format(rstObj!cost.Value, "$#,###.00")
    UserForm2.Show
    Else
    MsgBox ("You must complete all tree fields.")
    End If
    End Sub
     
    PJS5, Aug 20, 2003
    #1
  2. PJS5

    Mark Propst Guest

    Sub test()
    Dim treeObj As AcadCircle
    Dim treePnt(0 To 2) As Double
    Dim treeRad As Double
    Dim PntA As Variant
    PntA = ThisDrawing.Utility.GetPoint(, "Pick tree point: ")
    treePnt(0) = PntA(0): treePnt(1) = PntA(1): treePnt(2) = PntA(2)
    treeRad = ThisDrawing.Utility.GetDistance(PntA, "Pick radius point: ")
    Set treeObj = ThisDrawing.ModelSpace.AddCircle(treePnt, treeRad)
    End Sub

    hth
    Mark
     
    Mark Propst, Aug 20, 2003
    #2
  3. PJS5

    PJS5 Guest

    Works a treat, thanks Mark.

     
    PJS5, Aug 20, 2003
    #3
  4. PJS5

    Mark Propst Guest

    cool!
    :)
     
    Mark Propst, Aug 21, 2003
    #4
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.