-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1a0e8c
commit 6611731
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
################################################################################ | ||
# SampleEditPoints.py | ||
# Copyright (c) 2018 Robert McNeel & Associates. | ||
# See License.md in the root of this repository for details. | ||
################################################################################ | ||
import Rhino | ||
import rhinoscriptsyntax as rs | ||
|
||
# Demonstrates how to get a curve's edit points | ||
def SampleEditPoints(): | ||
|
||
obj_id = rs.GetObject('Select curve', rs.filter.curve) | ||
if not obj_id: return | ||
|
||
crv = rs.coercecurve(obj_id) | ||
if not crv: return | ||
|
||
nc = crv.ToNurbsCurve() | ||
|
||
# NurbsCurve.GrevilleParameters always returns all parameters, even for | ||
# perodic curves. Otherwise, it would not be possible to determine | ||
# which subset of the full list of Greville abcissae was returned. | ||
t_list = nc.GrevilleParameters() | ||
|
||
# Filter out what we don't want so it looks like what we'd see if | ||
# we ran the EditPtOn command | ||
if t_list: | ||
t = 0 | ||
t_count = t_list.Count | ||
if nc.IsPeriodic: | ||
t_count -= nc.Order - 1 | ||
rc = 0 | ||
while True: | ||
if rc < nc.Order - 1 and t_list[t] < nc.Knots[nc.Order-2]: | ||
rc += 1 | ||
t += 1 | ||
continue | ||
break | ||
elif nc.IsClosed: | ||
t_count -= 1 | ||
|
||
for n in range(t, t + t_count): | ||
rs.AddPoint(nc.PointAt(t_list[n])) | ||
|
||
# Check to see if this file is being executed as the "main" python | ||
# script instead of being used as a module by some other python script | ||
# This allows us to use the module which ever way we want. | ||
if __name__ == "__main__": | ||
SampleEditPoints() |