Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System.Guid
def AveragePoint3d(aPts):
X = Y = Z = 0
L = len(aPts)
for i in range(len(aPts)):
X += aPts[i].X
Y += aPts[i].Y
Z += aPts[i].Z
return Rhino.Geometry.Point3d(X/L, Y/L, Z/L)
def MatchSeamMarker():
crvId = rs.GetObject("Select a marker curve.", 4, preselect=True)
if not crvId: return
text = rs.GetUserText(crvId, "SeamMarkerId")
if not text: return
ids = rs.ObjectsByType(4)
grp = rs.AddGroup()
lines = []
if ids:
for id in ids:
temp = rs.GetUserText(id, "SeamMarkerId")
if temp:
if temp == text and id != crvId:
p1 = AveragePoint3d([rs.CurveEndPoint(crvId), rs.CurveStartPoint(crvId)])
p2 = AveragePoint3d([rs.CurveEndPoint(id), rs.CurveStartPoint(id)])
lines.append(rs.AddLine(p1, p2))
if len (lines) > 0:
rs.AddObjectsToGroup(lines, grp)
else:
rs.DeleteGroup(grp)
if __name__ == "__main__": MatchSeamMarker()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment