Sub ChopLine()
Dim returnObj As AcadObject
Dim lineObj As AcadLine
Dim copyObj As AcadLine
Dim nextCopyObj As AcadLine
Dim lCurDiv As Long
Dim lNumDiv As Long
Dim basePnt As Variant
Do
On Error Resume Next
' The following example waits for a selection from the user
ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select a line"
If Err <> 0 Then
Err.Clear
Exit Sub
Else
On Error GoTo 0
If TypeOf returnObj Is AcadLine Then
Set lineObj = returnObj
Set copyObj = lineObj.Copy
lNumDiv = Int(Val(InputBox("Number of Divisions?", "Line Divide
Info", "2")))
If lNumDiv < 1 Then Exit Sub
copyObj.ScaleEntity copyObj.StartPoint, 1 / lNumDiv
For lCurDiv = 1 To lNumDiv - 1
Set nextCopyObj = copyObj.Copy
nextCopyObj.Move copyObj.StartPoint, copyObj.EndPoint
Set copyObj = nextCopyObj
Next 'lCurDiv
'lineobj.Delete 'uncomment if you want to delete original
line
End If
End If
Loop
End Sub
"cmedinag" wrote in message
news:18831694.1109264452109.JavaMail.jive@jiveforum1.autodesk.com...
> hi, thanks for the tip, i tried to implement it but it doesn't seem to be
working. this is the code... im new in VB and dont know how to make it
work...
>
> Public Sub Separado2()
>
> Dim oLineOrig As AcadLine
> Dim dLen As Double
> Dim iDiv As Integer
> Dim newLen As Double
> Dim varStPt As Variant
> Dim ang As Double
> Dim oOwner As Object
> Dim idlX As Integer
>
>
>
> On Error Resume Next
>
> With ThisDrawing.Utility
> ''OBTENER LINEA ORIGINAL
> Set oLineOrig = .GetLine(, vbCr & "Seleccione la linea a dividir:
")
> dLen = oLineOrig.Length
> intDiv = .GetInteger(vbCr & "Cuantos puntos desea agregar a ese
segmento?: ")
> newLen = dLen / iDiv
> varStPt = oLineOrig.StartPoint
> ang = oLineOrig.Angle
> Set oOwner = oLineOrig.Owner
>
> For idlX = 1 To iDiv
> oOwner.AddLine varStPt, ThisDrawing,
Utilily.PolarPoint(varStPt, ang, newLen)
> varStPt = ThisDrawing.Utility.PolarPoint(varStPt, ang, newLen)
> Next idlX
>
> oLineOrig.Delete
> MsgBox ("Se ha dividido la linea")
> End With
>
> End Sub
>
> thanks!