Skip to content

Instantly share code, notes, and snippets.

@yasushisakai
Last active December 14, 2015 04:19
Show Gist options
  • Save yasushisakai/5027368 to your computer and use it in GitHub Desktop.
Save yasushisakai/5027368 to your computer and use it in GitHub Desktop.
creates a point in a curve with the given distance samething discorverd in... http://wiki.mcneel.com/developer/scriptsamples/curvearclengthpoint 入力:曲線、点、オフセット距離 出力:曲線上でオフセットされた点 似たような事をVBで発見、 http://wiki.mcneel.com/developer/scriptsamples/curvearclengthpoint
import rhinoscript.userinterface
import rhinoscript.geometry
import rhinoscriptsyntax as rs
__commandname__ = "OffsetPointOnCurve"
def RunCommand( is_interactive ):
'''
creates a point in a curve with the given distance
samething discorverd in...
http://wiki.mcneel.com/developer/scriptsamples/curvearclengthpoint
'''
curve = rs.GetObject('Select curve',4)
point = rs.GetPointOnCurve(curve,'Select point on curve')
if point is None: return 1
distance = rs.GetReal('Distance to offset point')
if distance is None : return 1
t = rs.CurveClosestPoint(curve,point)
domain = rs.CurveDomain(curve)
curveLength = rs.CurveLength(curve)
lengths = rs.CurveLength(curve,-1,(domain[0],t))
try:
rs.AddPoint(rs.CurveArcLengthPoint(curve,lengths+distance,True))
except:
# if the user selected a point on the end, point will not be added.
pass
try:
rs.AddPoint(rs.CurveArcLengthPoint(curve,curveLength-lengths+distance,False))
except:
# if the user selected a point on the end, point will not be added.
pass
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment