Below is attached a Python script that behaves strangely. The script puts the odds (long long X or Y) of the sides of a polylinea as in the attached image or any other.
If I click the side close to the edge (red circle) puts me exactly share if I click on side in center position (green circle) puts the proportion between one end and the point where I clicked like in the attached image.
Further strange thing is that: I close and then open the item again, drawing a Rhino polylinea, launch the script and I click on a side away from the edge puts the first precise altitude and then returns the first casino.
I wish someone would try to see what happens on other computers.
Ciao Vittorio
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext
def GetCurvesAndEdges():
"""
Return segmento di polylinea , linea, edge
"""
filter= Rhino.DocObjects.ObjectType.Curve
rc, objrefs = Rhino.Input.RhinoGet.GetOneObject("Seleziona segmento o edge da quotare", False, filter)
if rc != Rhino.Commands.Result.Success: return rc
pp=Rhino.DocObjects.ObjRef.CurveParameter(objrefs)
print "c",objrefs.Curve()
pt=objrefs.SelectionPoint()
#rs.AddPoint(pt)
a=Rhino.Geometry.Curve.DuplicateSegments(objrefs.Curve())
if len(a)==0:
segmento=scriptcontext.doc.Objects.AddCurve(objrefs.Curve())
return segmento
cc=[]
for i in a:
seg=scriptcontext.doc.Objects.AddCurve(i)
param=rs.CurveClosestPoint(seg,pt)
cp=rs.EvaluateCurve(seg,param)
if rs.PointCompare(pt,cp,0.0001):
segmento=seg
else:
cc.append(seg)
rs.DeleteObjects(cc)
return segmento
cc=GetCurvesAndEdges()
if rs.IsLine(cc):
ps=rs.CurveStartPoint(cc)
pe=rs.CurveEndPoint(cc)
#rs.AddPoints((ps,pe))
p1=rs.coerce3dpoint(ps)
p2=rs.coerce3dpoint(pe)
rs.AddPoints((p1,p2))
rs.DeleteObject(cc)
rs.Command("Dim W"+str(p1)+" W"+str(p2))
```
<a class="attachment" href="https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/8/6/865e55131a9f8168d939d6572e133975d08bfefe.py">QuotaToccandoSegmentoPolylinea.py</a> (1.4 KB)