Skip to content

Instantly share code, notes, and snippets.

@pgolay
Created July 1, 2018 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgolay/5156ca7bb09a29c87111181a22bf53c7 to your computer and use it in GitHub Desktop.
Save pgolay/5156ca7bb09a29c87111181a22bf53c7 to your computer and use it in GitHub Desktop.
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