本文整理汇总了Python中rhinoscriptsyntax.coercecurve函数的典型用法代码示例。如果您正苦于以下问题:Python coercecurve函数的具体用法?Python coercecurve怎么用?Python coercecurve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了coercecurve函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: GenerateCrossSection
def GenerateCrossSection(sectionPoints, radius, rotation, smooth, curve, samples, p, q):
points = []
avoidRoundoff = 0.01
for angle in rs.frange(0.0, 360.0+avoidRoundoff, 360.0/sectionPoints):
points.append(rs.Polar((0.0, 0.0, 0.0), angle, radius))
rotXform = rs.XformRotation2(rotation, (0, 0, 1), (0, 0, 0))
points = rs.PointArrayTransform(points, rotXform)
t = curve.Domain[0]
crossSections = []
curveCurvature = curve.CurvatureAt(t)
crossSectionPlane = None
if not curveCurvature:
crvPoint = curve.PointAt(t)
crvTangent = curve.TangentAt(t)
crvPerp = (0,0,1)
crvNormal = Rhino.Geometry.Vector3d.CrossProduct(crvTangent, crvPerp)
crossSectionPlane = Rhino.Geometry.Plane(crvPoint, crvPerp, crvNormal)
else:
crvPoint = curve.PointAt(t)
crvTangent = curve.TangentAt(t)
crvPerp = curve.CurvatureAt(t)
crvPerp.Unitize
crvNormal = Rhino.Geometry.Vector3d.CrossProduct(crvTangent, crvPerp)
crossSectionPlane = Rhino.Geometry.Plane(crvPoint, crvPerp, crvNormal)
if crossSectionPlane:
xform = rs.XformChangeBasis(crossSectionPlane, rs.WorldXYPlane())
sectionVerts = rs.PointArrayTransform(points, xform)
if (smooth): # Degree 3 curve to smooth it
sectionCurve = Rhino.Geometry.Curve.CreateControlPointCurve(sectionVerts, 3)
else: # Degree 1 curve (polyline)
sectionCurve = Rhino.Geometry.Curve.CreateControlPointCurve(sectionVerts, 1)
crossSection = rs.coercecurve(sectionCurve)
return crossSection
开发者ID:harshitrnnh,项目名称:culturecad,代码行数:35,代码来源:Torus+Knot+UI+Example.py
示例2: getSolarGeom
def getSolarGeom(boundary,ht,lat,shourlst,ehourlst,day,north,long,timeZ,s_mth,e_mth):
CH = ConvexHull2d()
boundary_pts = rs.CurvePoints(boundary) # you'll need this later
boundary_pts.pop(-1)
bchullpts = CH.convex_hull(boundary_pts)
centerPt = rs.CurveAreaCentroid(rs.AddCurve(bchullpts + [bchullpts[0]],1))[0]
#centerPt = rs.CurveAreaCentroid(boundary)[0]
boundary_plane = rs.PlaneFitFromPoints(boundary_pts)
top_plane = get_plane(boundary,ht)
# project curve to user_defined height
sun_pts = get_sunpt(lat,centerPt,s_mth,day,shourlst,north_=north,lon=long,tZ=timeZ,scale_=100)
sun_pts.extend(get_sunpt(lat,centerPt,e_mth,day,ehourlst,north_=north,lon=long,tZ=timeZ,scale_=100))
top_lst = project_curve(sun_pts,centerPt,top_plane,boundary)
top_curves = map(lambda x: rs.coercecurve(x),top_lst) # temp for viz
top_lst = map(lambda x: rs.CurvePoints(x),top_lst)
top_pts = map(lambda x: rs.coerce3dpoint(x),\
reduce(lambda i,j:i+j,top_lst))
# convex hull methods
chull_pts = CH.convex_hull(top_pts)
chull_crv = rs.AddCurve(chull_pts + [chull_pts[0]],1)
#chull_centerPt = rs.CurveAreaCentroid(chull_crv)[0]
# adjust curve directions
#if not rs.CurveDirectionsMatch(boundary,chull_crv):
# rs.ReverseCurve(boundary)
#b = rs.CurvePoints(boundary) + rs.CurvePoints(chull_crv)
#c = rs.CurvePoints(chull_crv)
return (boundary,chull_crv),top_curves
开发者ID:jtyow,项目名称:ladybug,代码行数:31,代码来源:Ladybug_SolarFan_alt.py
示例3: Sweep1
def Sweep1():
rail = rs.GetObject("Select rail curve", rs.filter.curve)
rail_crv = rs.coercecurve(rail)
if not rail_crv: return
cross_sections = rs.GetObjects("Select cross section curves", rs.filter.curve)
if not cross_sections: return
cross_sections = [rs.coercecurve(crv) for crv in cross_sections]
sweep = Rhino.Geometry.SweepOneRail()
sweep.AngleToleranceRadians = scriptcontext.doc.ModelAngleToleranceRadians
sweep.ClosedSweep = False
sweep.SweepTolerance = scriptcontext.doc.ModelAbsoluteTolerance
sweep.SetToRoadlikeTop()
breps = sweep.PerformSweep(rail_crv, cross_sections)
for brep in breps: scriptcontext.doc.Objects.AddBrep(brep)
scriptcontext.doc.Views.Redraw()
开发者ID:ColinWade,项目名称:rhinocommon-1,代码行数:17,代码来源:ex_sweep1.py
示例4: circleWithRadiusOf10GeometryFilter
def circleWithRadiusOf10GeometryFilter (rhObject, geometry, componentIndex):
isCircleWithRadiusOf10 = False
c = rs.coercecurve(geometry)
if c:
b, circle = c.TryGetCircle()
if b:
isCircleWithRadiusOf10 = circle.Radius <= 10.0 + Rhino.RhinoMath.ZeroTolerance and circle.Radius >= 10.0 - Rhino.RhinoMath.ZeroTolerance
return isCircleWithRadiusOf10
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:8,代码来源:ex_customgeometryfilter.py
示例5: isSubCrvLine
def isSubCrvLine(rhObject,geometry, componentIndex):
isSubCrvLine = False
print componentIndex.Index
#if componentIndex.Index < 1: return False
c = rs.coercecurve(geometry)
if c:
isSubCrvLine, line = c.TryGetLine()
return isSubCrvLine
开发者ID:pgolay,项目名称:PG_Scripts,代码行数:9,代码来源:DogBone_dev.py
示例6: sweep1
def sweep1(rail, cross_sections):
rail_crv = rs.coercecurve(rail)
if not rail_crv: return
if not cross_sections: return
cross_sections = [rs.coercecurve(crv) for crv in cross_sections]
sweep = Rhino.Geometry.SweepOneRail()
sweep.AngleToleranceRadians = scriptcontext.doc.ModelAngleToleranceRadians
sweep.ClosedSweep = False
sweep.MiterType = 2
sweep.SweepTolerance = scriptcontext.doc.ModelAbsoluteTolerance
sweep.SetToRoadlikeTop()
breps = sweep.PerformSweep(rail_crv, cross_sections)
guids=[]
for brep in breps:
rc = scriptcontext.doc.Objects.AddBrep(brep)
guids.append(rc)
scriptcontext.doc.Views.Redraw()
return guids
开发者ID:tamirez3dco,项目名称:Rendering_Data,代码行数:19,代码来源:name_pendant_cmd.py
示例7: get_camera_by_curve
def get_camera_by_curve(guid):
"""
Given a curve guid, return an origin and target.
"""
curve = rs.coercecurve(guid, -1, True)
origin = curve.PointAt(0)
target = curve.PointAt(1)
return origin, target
开发者ID:chirs,项目名称:studio5,代码行数:11,代码来源:camera.py
示例8: ReverseCurves
def ReverseCurves():
crvs = rs.GetObjects("Select curves to reverse", rs.filter.curve)
if not crvs: return
for crvid in crvs:
crv = rs.coercecurve(crvid)
if not crv: continue
dup = crv.DuplicateCurve()
if dup:
dup.Reverse()
doc.Objects.Replace(crvid, dup)
开发者ID:ColinWade,项目名称:rhinocommon-1,代码行数:11,代码来源:ex_curvereverse.py
示例9: OffsetCurveOnSurface
def OffsetCurveOnSurface(self, border, face, offsetDist):
success = False
glzArea = 0
direction = 1
# Try RhinoCommon
glzCurve = border.OffsetOnSurface(face.Faces[0], offsetDist, tolerance)
if glzCurve==None:
glzCurve = border.OffsetOnSurface(face.Faces[0], -offsetDist, tolerance)
direction = -1
if glzCurve == None:
# Magically Steve Baer's script works in many cases that RhinoCommon Fails
# I checked the source code in gitHub and it looks exactly the same as the lines above!
# I have no idea what am I doing wrong! [Jan 19 2013]
print "RhinoCommon failed to offsetCurveOnSurface... Testing Steve Baer's magic!"
rsborder = sc.doc.Objects.AddCurve(border)
rsface = sc.doc.Objects.AddSurface(face.Faces[0])
glzCurve = rs.OffsetCurveOnSurface(rsborder, rsface, offsetDist)
if glzCurve==None:
glzCurve = rs.OffsetCurveOnSurface(rsborder, rsface, -offsetDist)
direction = -1
rs.DeleteObjects([rsface, rsborder])
if glzCurve!=None:
try:
glzCurve = [rs.coercecurve(glzCurve)]
except:
glzCurve = [rs.coercecurve(glzCurve[0])]
print "Magic worked!"
if glzCurve!=None:
glzCurve = glzCurve[0]
splitter = rc.Geometry.Surface.CreateExtrusion(glzCurve, self.getSrfAreaAndCenPt(face, calArea = False)[2]).ToBrep()
splittedSrfs = face.Split(splitter, sc.doc.ModelAbsoluteTolerance)
try:
glzSrf = splittedSrfs[-1]
glzArea = glzSrf.GetArea()
success = True
joinedSrf = rc.Geometry.Brep.JoinBreps(splittedSrfs, tolerance)[0]
except Exception, e:
print "Split surface failed!\n" + `e`
return True, glzArea, glzCurve, None
开发者ID:chiensiTB,项目名称:Honeybee,代码行数:41,代码来源:Honeybee_Masses2Zones.py
示例10: RunCommand
def RunCommand():
crvA = rs.GetCurveObject("first curve")[0]
crvA = rs.coercecurve(crvA)
crvB = rs.GetCurveObject("second curve")[0]
crvB = rs.coercecurve(crvB)
if crvA == None or crvB == None:
return Rhino.Commands.Result.Failure
maxa, maxb, maxd, mina, minb, mind = rs.CurveDeviation(crvA, crvB)
if mind <= Rhino.RhinoMath.ZeroTolerance:
mind = 0.0;
maxDistPtA = crvA.PointAt(maxa)
maxDistPtB = crvB.PointAt(maxb)
minDistPtA = crvA.PointAt(mina)
minDistPtB = crvB.PointAt(minb)
print "Minimum deviation = {0} pointA({1}, {2}, {3}), pointB({4}, {5}, {6})".format(
mind, minDistPtA.X, minDistPtA.Y, minDistPtA.Z, minDistPtB.X, minDistPtB.Y, minDistPtB.Z)
print "Maximum deviation = {0} pointA({1}, {2}, {3}), pointB({4}, {5}, {6})".format(
maxd, maxDistPtA.X, maxDistPtA.Y, maxDistPtA.Z, maxDistPtB.X, maxDistPtB.Y, maxDistPtB.Z)
开发者ID:acormier,项目名称:RhinoCommonExamples,代码行数:21,代码来源:ex_crvdeviation.py
示例11: main
def main(north,_boundary,timeperiod,monthRange,location,height):
if sc.sticky.has_key('ladybug_release'):
try:
if not sc.sticky['ladybug_release'].isCompatible(ghenv.Component): return -1
if sc.sticky['ladybug_release'].isInputMissing(ghenv.Component): return -1
except:
warning = "You need a newer version of Ladybug to use this compoent." + \
"Use updateLadybug component to update userObjects.\n" + \
"If you have already updated userObjects drag Ladybug_Ladybug component " + \
"into canvas and try again."
w = gh.GH_RuntimeMessageLevel.Warning
ghenv.Component.AddRuntimeMessage(w, warning)
return -1
latitude,longitude,timeZone,elevation = readLocation(location)
year = datetime.datetime.now().year
day = 21
s_mth,e_mth = MONTH_DICT[monthRange][0], MONTH_DICT[monthRange][1]
s_snoon = get_solarnoon(s_mth,year,timeZone,day,latitude,longitude)
e_snoon = get_solarnoon(e_mth,year,timeZone,day,latitude,longitude)
"""solar variables"""
shourlst,ehourlst,day = getSolarData(timeperiod,s_snoon,e_snoon)
"""work with curves"""
curve_ = rs.coercecurve(_boundary, -1, True)
boundary_lst = checkConcaveConvex(curve_)
chull_lst = []
top_lst = [] # for testing purposes
if type(boundary_lst) != type([]):
boundary_lst = [_boundary]
for boundary_ in boundary_lst:
boundary = clean_curve(boundary_)
bcurve,tc = getSolarGeom(boundary,height,latitude,\
shourlst,ehourlst,day,north,longitude,timeZone,s_mth,e_mth)
chull_lst.append(bcurve)
top_lst.extend(tc)
b2ch = Curve2ConvexHull3d()
breplst,ptlst = b2ch.get_convexhull(chull_lst)
L = map(lambda m: rs.coercebrep(m),breplst)
CB = CleanBrep(TOL,L)
map(lambda id: sc.doc.Objects.Delete(id,True), breplst) #delete breplst
return CB.cleanBrep()
##bcurve = boundary_lst ## for testing purposes
##top_curves = top_lst ## for testing purposes
else:
print "You should first let the Ladybug fly..."
ghenv.Component.AddRuntimeMessage(ERROR_W, "You should first let the Ladybug fly...")
开发者ID:mostaphaRoudsari,项目名称:ladybug,代码行数:52,代码来源:Ladybug_SolarFanBasic.py
示例12: projectPtOnSrf
def projectPtOnSrf(attractorPt, targetSrf, pt):
r = rs.AddLine(attractorPt, pt)
r = rs.ScaleObject(r, attractorPt, (10, 10,10))
dom = rs.CurveDomain(r)
crv = rs.coercecurve(r)
srf = rs.coercesurface(targetSrf).ToNurbsSurface()
inv = Interval(dom[0], dom[1])
rs.DeleteObject(r)
xobj = Intersection.CurveSurface(crv, inv, srf, 0.1, 1)
return xobj[0].PointB
开发者ID:behrooz-tahanzadeh,项目名称:HexFactory,代码行数:15,代码来源:util.py
示例13: UpdateGeometry
def UpdateGeometry(self, data):
self.surface = None
self.surfaceBBox = None
tempVerts = TorusKnotVerts(data.p, data.q, data.pathPointCount, data.zScale)
self.railCurve = Rhino.Geometry.Curve.CreateControlPointCurve(tempVerts, 3)
self.railCurveBBox = self.railCurve.GetBoundingBox(False)
rail = rs.coercecurve(self.railCurve)
# Generate a section curve at the start of the rail
self.crossSection = GenerateCrossSection(data.crossSecPointCount, data.crossSecRadius, data.crossSecRotation, data.smoothCrossSec, self.railCurve, data.pathPointCount, data.p, data.q)
if (data.outputSurface):
# Sweep it out about the rail curve
tolerance = scriptcontext.doc.ModelAbsoluteTolerance
breps = Rhino.Geometry.Brep.CreateFromSweep(rail, self.crossSection, rail.IsClosed, tolerance)
self.surface = breps[0]
self.surfaceBBox = self.surface.GetBoundingBox(False)
scriptcontext.doc.Views.Redraw()
开发者ID:harshitrnnh,项目名称:culturecad,代码行数:16,代码来源:Torus+Knot+UI+Example.py
示例14: extrude_solid
def extrude_solid(pt,cp,b):
# int_solid: (listof pt) pt curve -> (listof solid)
lo_solid = []
ptlst = rs.CurvePoints(b)
srf = rs.AddPlanarSrf(rs.AddCurve(ptlst,1))
# make curve and extrude
line = rs.AddCurve([cp,pt],1)
max = get_max_side(b)
curve = rs.ExtendCurveLength(line,0,1,max*40)
#extrude surface
brep = rs.coercebrep(srf, True)
curve = rs.coercecurve(curve, -1, True)
newbrep = brep.Faces[0].CreateExtrusion(curve, True)
if newbrep:
rc = sc.doc.Objects.AddBrep(newbrep)
sc.doc.Views.Redraw()
return rc
开发者ID:RodrigoMedina,项目名称:ladybug,代码行数:17,代码来源:Ladybug_SolarEnvelope_alt.py
示例15: RunCommand
def RunCommand():
srfid = rs.GetObject("select surface", rs.filter.surface | rs.filter.polysurface)
if not srfid: return
crvid = rs.GetObject("select curve", rs.filter.curve)
if not crvid: return
result = rs.CurveBrepIntersect(crvid, srfid)
if result == None:
print "no intersection"
return
curves, points = result
for curve in curves:
doc.Objects.AddCurve(rs.coercecurve(curve))
for point in points:
rs.AddPoint(point)
doc.Views.Redraw()
开发者ID:ColinWade,项目名称:rhinocommon-1,代码行数:19,代码来源:ex_curvesurfaceintersect.py
示例16: clean_curve
def clean_curve(b):
"""Clean curve geometry
1. Checks if guid or object
2. Simplifiebs
3. Reverse curve dirn
4. Closes curve if not already closed
"""
if type(b) == type(rs.AddPoint(0,0,0)): # already guid
pass
else:
b = sc.doc.Objects.AddCurve(b)
rs.SimplifyCurve(b)
# reverse curve direction
boundarybrep = rs.coercecurve(b)
Rhino.Geometry.Curve.Reverse(boundarybrep)
sc.doc.Objects.Replace(b,boundarybrep)
if rs.IsCurveClosed(b):
return b
else:
return rs.CloseCurve(b)
开发者ID:jtyow,项目名称:ladybug,代码行数:20,代码来源:Ladybug_SolarFan_alt.py
示例17: main
def main(north,_boundary,timeperiod,monthRange,location,height):
if sc.sticky.has_key('ladybug_release'):
latitude,longitude,timeZone,elevation = readLocation(location)
year = datetime.datetime.now().year
day = 21
s_mth,e_mth = MONTH_DICT[monthRange][0], MONTH_DICT[monthRange][1]
s_snoon = get_solarnoon(s_mth,year,timeZone,day,latitude,longitude)
e_snoon = get_solarnoon(e_mth,year,timeZone,day,latitude,longitude)
"""solar variables"""
shourlst,ehourlst,day = getSolarData(timeperiod,s_snoon,e_snoon)
"""work with curves"""
curve_ = rs.coercecurve(_boundary, -1, True)
boundary_lst = checkConcaveConvex(curve_)
chull_lst = []
top_lst = [] # for testing purposes
if type(boundary_lst) != type([]):
boundary_lst = [_boundary]
for boundary_ in boundary_lst:
boundary = clean_curve(boundary_)
bcurve,tc = getSolarGeom(boundary,height,latitude,\
shourlst,ehourlst,day,north,longitude,timeZone,s_mth,e_mth)
chull_lst.append(bcurve)
top_lst.extend(tc)
b2ch = Curve2ConvexHull3d()
breplst,ptlst = b2ch.get_convexhull(chull_lst)
L = map(lambda m: rs.coercebrep(m),breplst)
CB = CleanBrep(TOL,L)
map(lambda id: sc.doc.Objects.Delete(id,True), breplst) #delete breplst
return CB.cleanBrep()
##bcurve = boundary_lst ## for testing purposes
##top_curves = top_lst ## for testing purposes
else:
print "You should first let the Ladybug fly..."
ghenv.Component.AddRuntimeMessage(ERROR_W, "You should first let the Ladybug fly...")
开发者ID:marianox,项目名称:ladybug,代码行数:41,代码来源:Ladybug_SolarFan_alt.py
示例18: test_IncreaseByOne
def test_IncreaseByOne(self):
self.assertTrue(rs.ChangeCurveDegree(self.id, 4))
self.assertEqual(4, rs.coercecurve(self.id).ToNurbsCurve().Degree)
开发者ID:p-chambers,项目名称:rhinoscriptsyntax,代码行数:3,代码来源:ChangeCurveDegreeTests.py
示例19: test_CurveIsALine
def test_CurveIsALine(self):
id = rs.AddLine(g.Point3d.Origin, (10, 10, 10))
self.assertTrue(rs.ChangeCurveDegree(id, 3))
self.assertTrue(3, rs.coercecurve(id).ToNurbsCurve().Degree)
开发者ID:p-chambers,项目名称:rhinoscriptsyntax,代码行数:4,代码来源:ChangeCurveDegreeTests.py
示例20: Bula
import scriptcontext as sc
import clr
import rhinoscriptsyntax as rs
clr.AddReference("Grasshopper")
from Grasshopper.Kernel.Data import GH_Path
from Grasshopper import DataTree
ghenv.Component.Message = 'Bibil'
Bula = sc.sticky['Bula']
if run:
rule = DataTree[object]()
canyon_center = rs.coercecurve(canyon_center)
B = Bula()
srf_data = B.ghtree2nestlist(srf_data)
rule_ = [\
['extract_canyon', True],\
['grammar_key','extract_canyon'],\
['canyon_tol',canyon_tol],\
['canyon_center',canyon_center],\
['srf_data',srf_data],\
['end_rule']]
for i, r in enumerate(rule_):
rule.Add(r)
else:
rule = []
开发者ID:saeranv,项目名称:bibil,代码行数:31,代码来源:miru_extract_canyon.py
注:本文中的rhinoscriptsyntax.coercecurve函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论