James,
What I had in mind is function that adds a vertex at picked point along the
polyline. Like BREAK and PLJOIN functions incombined. ACAD is generally
missing such generic function, while PEDIT is the only possible (but by far
complicated) exit. Many users I've been working with are mainly switching
from other vector-based applications (Corel, Visio...) to ACAD and they
usually miss some sort of Add-Vertex-At-Picked-Point functionality.
As I'm in development of tools that immitate Autodesk's MAP ones, I'm fully
aware of ACAD's backdraws when we talk about
precision/exactness/ease-of-use. There's also Autodesk's lean towards GIS
implementation, and it has a lot to do with it, but I guess this reply is
way way out of topic this time... :-)
Regards,
Maksim Sestic
"James Belshan" wrote in message
news:40c708b5$1_3@newsprd01...
>
> I would loop through the poly's segments, and just check which segment the
> picked point is on (assuming the osnap was used). This should only give
> ambiguous results when the user picks exactly at an intersection, or picks
> overlapping segments, which are both ambiguous situations, anyways. If
you
> don't want to use snap, change the FUZZ loop to instead track the minimum
> distance from the pick pt to each segment, and call that the picked
segment.
>
> HTH,
> James
>
>
> [pseudocode]
> 'coords() = polyline vertices
> 'pickPt = variant holding picked point
> dim x() as double, y() as double, z() as double
> numPts = ((UBound(coords) + 1) / 3) 'assumes 0-bounded array of 3-D
> points
> ReDim x(0 To numPts - 1)
> ReDim y(0 To numPts - 1)
> ReDim z(0 To numPts - 1)
> For i = 0 To numPts - 1
> x(i) = coords(3 * i)
> y(i) = coords(3 * i + 1)
> z(i) = coords(3 * i + 2)
> Next 'i
>
> '
> const FUZZ as double = 0.001
> dim dist_pt_to_seg as double
> for i = 0 to numpts-2 'different for closed pline's ?
> dist_pt_to_seg = Dist_Pt_Ln (pickpt, acPoint3D(x(i),y(i),z(i)),
> acPoint3D(x(i+1),y(i+1),z(i+1)))
> if abs(dist_pt_to_seg) < FUZZ then
> 'insert new vertex after i'th vertex and stop checking
> exit for
> endif
> next 'i
> [/pseudocode]
>
>
> [code]
> Function Dist_Pt_Ln(Pt As Variant, EndA As Variant, EndB As Variant) As
> Double
>
> 'courtesy http://softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm
> 'cross-product formulation used
>
> Dim w(0 To 2) As Double
> Dim u(0 To 2) As Double
> Dim v(0 To 2) As Double
> Dim UxW(0 To 2) As Double
> Dim len_v As Double, w_dot_u As Double
>
> v(0) = EndB(0) - EndA(0)
> v(1) = EndB(1) - EndA(1)
> v(2) = EndB(2) - EndA(2)
> w(0) = Pt(0) - EndA(0)
> w(1) = Pt(1) - EndA(1)
> w(2) = Pt(2) - EndA(2)
> len_v = Sqr(v(0) ^ 2 + v(1) ^ 2 + v(2) ^ 2)
>
> u(0) = v(0) / len_v: u(1) = v(1) / len_v
> u(2) = v(2) / len_v
>
> UxW(0) = u(1) * w(2) - u(2) * w(1)
> UxW(1) = u(2) * w(0) - u(0) * w(2)
> UxW(2) = u(0) * w(1) - u(1) * w(0)
>
> Dist_Pt_Ln = Sqr(UxW(0) ^ 2 + UxW(1) ^ 2 + UxW(2) ^ 2)
>
> End Function
>
>
>
> Public Function acPoint3D(x As Double, y As Double, Optional z As Double =
> 0) As Variant
> ' courtesy www.acadx.com
> Dim retVal(0 To 2) As Double
> retVal(0) = x: retVal(1) = y: retVal(2) = z
> acPoint3D = retVal
> End Function
>
> [/code]
>
>