Just wondering if there is an inverse function of CurveArcLengthPoint
i.e., a function that gives the length of a curve between the curve start point and a given other point.
Currently, I use a small function like below, but my gut feeling says this already exists somewhere
GetCurveLengthFromStartToPoint( idCurve, ptPoint )
arrTemp = rs.CurveDomain( idCurve )
idTemp = rs.AddSubCrv( idCurve, arrTemp, rs.CurveClosestPoint( idCurve, ptPoint ) )
dblDistance = rs.CurveLength( idTemp )
rs.DeleteObject( idTemp )
Also, I very often use constructs of the form
pt = rs.VectorAdd( pt0, rs.VectorScale( vecTemp, 100) )
idLine = rs.AddLine( rs.VectorAdd( pt0, rs.VectorScale( vecTemp, -100) ), rs.VectorAdd( pt0, rs.VectorScale( vecTemp, 100) )
Can this be done more efficiently using existing methods or is my way of using these as help functions the right way?
As for your curve length issue:
I do not think there is some method which will directly do that. And basically you did it right. The only thing that could be improved is using RhinoCommon methods directly instead of rhinoscriptsyntax functions. In this way you would not have to delete the sub curve:
def getCurveLengthFromStartToPoint(idCurve, ptPoint):
curveObj = rs.coercecurve(idCurve)
ptObj = rs.coerce3dpoint(ptPoint)
trimmedCrv = curveObj.Trim(curveObj.Domain, curveObj.ClosestPoint(ptObj, 0.0))
If I understood you correctly one the vector issue, you want to add two vectors, but the second one should be scaled?
You can sum and multiply the Vector3d type:
pt = rs.coerce3dvector(pt0) + rs.coerce3dvector(vecTemp)*100
You can feed a subdomain into rs.CurveLength to specify a segment of the curve:
import rhinoscriptsyntax as rs
point=rs.GetPointOnCurve(Curveid,"Select Point on curve")
Length=rs.CurveLength(Curveid,-1,(0,PointParam)) #0 is start parameter of the curve!