コード例 #1
0
    def setNormalVec(self):
        #set normal vector from selected base surface
        #if selected base surface isn't planar, return False

        self.baseSurface = rs.GetSurfaceObject(
            "Select surface to be addded object")
        if self.baseSurface == None:
            return False

        rs.SelectObject(self.baseSurface[0])

        if not rs.IsSurfacePlanar(self.baseSurface[0]):
            print(
                "Selected Surface is not planar\nPlease select planar surface")
            return False

        print("Confirm direction to add object")
        rs.Command("Dir")

        self.normalVec = rs.SurfaceNormal(self.baseSurface[0], [0, 0])

        rs.UnselectAllObjects()

        self.setAngleOfBaseSurface()

        return True
コード例 #2
0
def RunCommand():
    surface_id = rs.GetSurfaceObject()[0]
    if surface_id == None:
        return
    surface = rs.coercesurface(surface_id)

    corners = rs.GetRectangle()
    if corners == None:
        return

    plane = Plane(corners[0], corners[1], corners[2])

    is_or_isnt = "" if IsSurfaceInPlane(
        surface, plane, doc.ModelAbsoluteTolerance) else " not "
    print "Surface is{0} in plane.".format(is_or_isnt)
コード例 #3
0
def PrincipalCurvatureMapper():
    select = rs.GetSurfaceObject("Point on surface to start from", False, True)
    if not select: return
    if select[2]!=1:
        print "You must pick on a surface for this to work"
        return
    srf_id = select[0]
    uvPt = select[4]


	
	Dim idSrf : idSrf = dSelect(0)
	Dim uvPt : uvPt = dSelect(4)
	
	Dim uvPts() : ReDim uvPts(0) : uvPts(0) = uvPt
	Dim i, nUVPt
コード例 #4
0
def start():
    from compas.geometry.algorithms.smoothing import mesh_smooth_centroid
    from compas.geometry.algorithms.smoothing import mesh_smooth_area

    from compas_pattern.algorithms.smoothing import define_constraints
    from compas_pattern.algorithms.smoothing import apply_constraints

    guid = rs.GetObject('get mesh')
    dense_mesh = RhinoGeometry.from_guid(guid)
    vertices, faces = dense_mesh.get_vertices_and_faces()
    dense_mesh = Mesh.from_vertices_and_faces(vertices, faces)

    #lines = rs.GetObjects('lines', filter = 4)
    #edges = [[rs.CurveStartPoint(line), rs.CurveEndPoint(line)] for line in lines]
    #dense_mesh = Mesh.from_lines(edges)

    #faces = list(dense_mesh.faces())
    #for fkey in faces:
    #    if len(dense_mesh.face_vertices(fkey)) > 10:
    #        delete_face(dense_mesh, fkey)
    #        print '-1 face'

    #dense_mesh = conway_ambo(dense_mesh)
    #dense_mesh = conway_dual(dense_mesh)
    #dense_mesh = conway_gyro(dense_mesh)
    #dense_mesh = conway_dual(dense_mesh)
    #dense_mesh = conway_gyro(dense_mesh)
    #dense_mesh = conway_kis(dense_mesh)

    #rs.EnableRedraw(False)
    #draw_mesh(dense_mesh)
    #rs.EnableRedraw(True)
    #return

    surface_guid = rs.GetSurfaceObject('surface constraint')[0]

    smooth_mesh = dense_mesh.copy()

    smoothing_iterations = rs.GetInteger('number of iterations for smoothing',
                                         number=20)
    damping_value = rs.GetReal('damping value for smoothing', number=.5)

    rs.EnableRedraw(False)

    #constraints, surface_boundaries = custom_constraints(smooth_mesh, surface_guid)
    constraints, surface_boundaries = define_constraints(
        smooth_mesh, surface_guid)

    rs.EnableRedraw(False)
    fixed_vertices = [
        vkey for vkey, constraint in constraints.items()
        if constraint[0] == 'fixed'
    ]
    mesh_smooth_area(smooth_mesh,
                     fixed=fixed_vertices,
                     kmax=smoothing_iterations,
                     damping=damping_value,
                     callback=apply_constraints,
                     callback_args=[smooth_mesh, constraints])

    smooth_mesh_guid = draw_mesh(smooth_mesh)

    #layer = 'smooth_mesh'
    #rs.AddLayer(layer)
    #rs.ObjectLayer(smooth_mesh_guid, layer = layer)

    rs.EnableRedraw(True)
コード例 #5
0
import rhinoscriptsyntax as rs

surface_id, _, _, _, _, _ = rs.GetSurfaceObject(
    "Select surface for curvature measurement")
point = rs.GetPointOnSurface(
    surface_id, "Select point on surface for curvature measurement")
u, v = rs.SurfaceClosestPoint(surface_id, point)

#point, normal, kappa_u, direction_u, kappa_v, direction_v, gaussian, mean =
surface_curvature = rs.SurfaceCurvature(surface_id, (u, v))

point, normal, kappa_u, direction_u, kappa_v, direction_v, gaussian, mean = surface_curvature

print "Surface curvature evaluation at parameter: ({0}, {1})".format(u, v)

print "  3-D Point: ({0}, {1}, {2})".format(point.X, point.Y, point.Z)

print "  3-D Normal: ({0}, {1}, {2})".format(normal.X, normal.Y, normal.Z)

print "  Maximum principal curvature: {0} ({1}, {2}, {3})".format(
    kappa_u, direction_u.X, direction_u.Y, direction_u.Z)

print "  Minimum principal curvature: {0} ({1}, {2}, {3})".format(
    kappa_v, direction_v.X, direction_v.Y, direction_v.Z)

print "  Gaussian curvature: {0}".format(gaussian)
print "  Mean curvature: {0}".format(mean)
コード例 #6
0
import rhinoscriptsyntax as rs
import Rhino
doc = Rhino.RhinoDoc.ActiveDoc

srf = rs.GetSurfaceObject("select surface")
tol = rs.UnitAbsoluteTolerance()
guid = srf[0]
obj = doc.Objects.Find(guid)
geo = obj.Geometry.Surfaces[0]

is_planar = geo.IsPlanar(tol)

if is_planar:
    print "This surface is planar"
else:
    print "This surface is not planar"
コード例 #7
0
import Rhino

count = 0
selected = rs.SelectedObjects()
# for obj in selected:
#     count += 1

if (selected):
    print("number of objects selected: " + str(len(selected)))

if len(selected) == 1 and rs.IsSurface(selected):
    print("got one")
    obj = selected
else:
    print("don't got one")
    obj = rs.GetSurfaceObject("surface to porcupine-ify", select=True)

print(obj)

scale = rs.GetReal("distance away from surface", 1)

# ucount = rs.GetInteger("# of u points")
# vcount = rs.GetInteger("# of v points")

srfcurves = []
srfpoints = []
extensionpoints = []
extensionlines = []
srfcircles = []
extcircles = []
コード例 #8
0
import rhinoscriptsyntax as rs
from grid import Grid
from hexFactory import HexFactory
import util

rs.EnableRedraw(False)

util.curvatureScale = -15

attractorPt = rs.AddPoint(0, 0, 0)
baseSrf = rs.GetSurfaceObject("Base Surface")[0]

projSrf = rs.GetSurfaceObject("Proj. Surface")[0]
gridObj = Grid(10, 10, baseSrf)
factory = HexFactory(gridObj, projSrf, attractorPt)