joining points in a line

Discussion in 'AutoCAD' started by cmedinag, Feb 22, 2005.

  1. cmedinag

    cmedinag Guest

    hi, im new to ACAD and to VBA also, and im making a routine that does exactly the same as point/divide command, but i wanted the new points created to join the line, so they can also modify it.. is there a way to do this? this is my code for this:

    Public Sub Separado()

    Dim varPt1 As Variant
    Dim varPt2 As Variant
    Dim intDiv As Integer
    Dim dblDivx As Double
    Dim dblDivy As Double
    Dim intFor As Integer
    Dim linea As AcadLine
    Dim varPtNew As Variant

    On Error Resume Next

    With ThisDrawing.Utility

    varPt1 = .GetPoint(, vbCr & "initial point ")
    varPt2 = .GetPoint(, vbCr & "ending point ")
    intDiv = .GetInteger(vbCr & "points to divide in")
    varPtNew = varPt1

    dblDivx = (Abs(varPt1(0) - varPt2(0))) / intDiv
    dblDivy = (Abs(varPt1(1) - varPt2(1))) / intDiv

    For intFor = 0 To intDiv - 1

    If varPt1(0) > varPt2(0) Then
    varPtNew(0) = varPtNew(0) - dblDivx
    Else
    varPtNew(0) = dblDivx + varPtNew(0)
    End If

    If varPt1(1) > varPt2(1) Then
    varPtNew(1) = varPtNew(1) - dblDivy
    Else
    varPtNew(1) = dblDivy + varPtNew(1)
    End If

    ThisDrawing.ModelSpace.AddPoint (varPtNew)
    Next

    MsgBox ("line divided")
    End With

    End Sub
     
    cmedinag, Feb 22, 2005
    #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.