Created
July 1, 2018 00:39
-
-
Save pgolay/5156ca7bb09a29c87111181a22bf53c7 to your computer and use it in GitHub Desktop.
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
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