Finds the closed segment of the polyline a passed point
Syntax
Example
Example where on mouse down event when we click somewhere close to a polyline we can find
the segment with the start and the end point of the polyline which is more close to the point that we have clicked
C# | Copy Code |
---|
function _vdmousedown(e) { if (e.target.ActiveAction().IsStarted()) return; //no user waiting action is active var entity = e.target.GetEntityFromPoint(e.xPix, e.yPix); //scan for an entity under the pick point if (!entity || entity._t !== vdConst.vdPolyline_code) return; //check if entity exist and is a polyline type var index = vdgeo.GetPlineSegmentIndexFromPoint([e.x, e.y, e.z], entity.VertexList.Items, entity.Flag == 1, entity.ExtrusionVector); //get the picked index near the pick point if (index == -1) return; //an index was found.Print the result var sp, ep; sp = entity.VertexList.Items[index]; if (index == entity.VertexList.Items.length - 1) ep = entity.VertexList.Items[0]; else ep = entity.VertexList.Items[index + 1]; alert("Segment" + index + "\nbetween first point X=" + sp[0].toFixed(3).toString() + " Y=" + sp[1].toFixed(3).toString() + " Z=" + sp[2].toFixed(3).toString() + " Bulge=" + sp[3].toFixed(3).toString() + "\nand second point X=" + ep[0].toFixed(3).toString() + " Y=" + ep[1].toFixed(3).toString() + " Z=" + ep[2].toFixed(3).toString() + " Bulge=" + ep[3].toFixed(3).toString()); } |
See Also