divide a line

divide a line

Anonymous
Not applicable
379 Views
3 Replies
Message 1 of 4

divide a line

Anonymous
Not applicable
hi! i want to know how to divide a line into multiple little lines, with a for cicle or something, so it can be divided many times. thanks!
0 Likes
380 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
"cmedinag" wrote in message news:29268.1109222550162.JavaMail.jive@jiveforum2.autodesk.com... > hi! i want to know how to divide a line into multiple little lines, with a for cicle or something, so it can be divided many times. thanks! 'just some quick pseudo code to give the general idea 'syntax likely not correct check help for details 'dimension variables 'oLineOrig as AcadLine etc 'dLen as Double, lDiv as Long, etc etc 'Get the line set oLineOrig = 'select or iterate or however you identify the original line 'get the length dLen = oLineOrig.Length 'get the number of divisions lDiv = 'prompt for input or get from form or ??? 'calc length of new lines dNewLen = dLen / lDiv 'get startpoint vStPt = oLineOrig.Startpoint 'get the angle dAng = oLineOrig.Angle 'was orig line in modelspace,paperspace or a block? Set oOwner = oLineOrig.Owner 'create new lines for lIdx = 1 to lDiv oOwner.AddLine vStPt, ThisDrawing.Utility.PolarPoint( vStPt, dAng, dNewLen) 'adjust startpoint for next line vStPt = ThisDrawing.Utility.PolarPoint( vStPt, dAng, dNewLen) next lIdx 'erase orig line if req'd oLineOrig.Delete hth Mark
0 Likes
Message 3 of 4

Anonymous
Not applicable
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!
0 Likes
Message 4 of 4

Anonymous
Not applicable
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!
0 Likes