def drawEvaluateValue(list_evaluate): frame = 5000 original_point = 5000 step_x_axis = 100 plane = rs.WorldXYPlane() xform = rs.XformTranslation([0, 5000, 0]) plane1 = rs.PlaneTransform(plane, xform) rs.AddRectangle(plane1, frame, frame) evaluate_sum = [] for i in range(len(list_evaluate)): evaluate_sum.append(sum(list_evaluate[i])) max_value = max(evaluate_sum) min_value = min(evaluate_sum) # if 1000 > max_value > 100: # # if 10000 > max_value >= 1000: point_list = [] for i in range(len(evaluate_sum)): value = evaluate_sum[i] # print("evaluate_sum", evaluate_sum[i]) new_value = remap(value, max_value, 0, 5000, 0) # print("new_value", new_value) pt = rs.AddPoint(i * step_x_axis, original_point + new_value, 0) point_list.append(pt) rs.AddPolyline(point_list)
def checkblkplane(blkid): xform = rs.BlockInstanceXform(blkid) plane = rs.PlaneTransform(rs.WorldXYPlane(), xform) normal = plane.ZAxis.Z print normal if normal < 0: newxform = rs.XformMirror(plane.Origin, plane.Normal) return rs.TransformObject(blkid, newxform) else: return
def applyXform(target, source): targetXform = rs.BlockInstanceXform(target) sourceXform = rs.BlockInstanceXform(source) if targetXform is not None: plane = rs.PlaneTransform(rs.WorldXYPlane(), targetXform) # xformscale = rs.XformScale((1.0,20.0,1.0)) cob = rs.XformChangeBasis(rs.WorldXYPlane(), plane) cob_inverse = rs.XformChangeBasis(plane, rs.WorldXYPlane()) temp = rs.XformMultiply(sourceXform, cob) xform = rs.XformMultiply(cob_inverse, temp) rs.TransformObjects(target, xform)
def resetBlockScale(block): block_name = rs.BlockInstanceName(block) blockXform = rs.BlockInstanceXform(block) plane = rs.PlaneTransform(rs.WorldXYPlane(), blockXform) # newplane = rs.CreatePlane(plane.Origin, plane.XAxis, plane.YAxis) # cob = rs.XformChangeBasis(newplane, rs.WorldXYPlane()) cob = rs.XformChangeBasis(plane, rs.WorldXYPlane()) newBlock = rs.InsertBlock2(block_name, cob) copySourceLayer(newBlock, block) try: copySourceData(newBlock, block) except: pass rs.DeleteObjects(block) return newBlock
def blkFace(obj): cameraPos = rs.ViewCamera() cameraPos.Z = 0 xform = rs.BlockInstanceXform(obj) plane = rs.PlaneTransform(rs.WorldXYPlane(), xform) viewdir = rs.VectorUnitize(cameraPos - plane.Origin) angle = rs.VectorAngle(viewdir, plane.YAxis) newXform = rs.XformRotation3(plane.YAxis, viewdir, plane.Origin) rs.TransformObject(obj, newXform)
def redefineBlockScale(block): block_name = rs.BlockInstanceName(block) # rs.RenameBlock (block_name, "{}-old".format(block_name)) blockXform = rs.BlockInstanceXform(block) plane = rs.PlaneTransform(rs.WorldXYPlane(), blockXform) cob = rs.XformChangeBasis(plane, rs.WorldXYPlane()) cob_inverse = rs.XformChangeBasis(rs.WorldXYPlane(), plane) refBlock = rs.TransformObjects(block, cob_inverse, True) exploded = rs.ExplodeBlockInstance(refBlock) rs.AddBlock(exploded, rs.WorldXYPlane().Origin, block_name, True) newBlock = rs.InsertBlock2(block_name, cob) copySourceLayer(newBlock, block) try: copySourceData(newBlock, block) except: pass rs.DeleteObjects(block)
def bbsolid(obj): if rs.IsBlockInstance(obj): arrMatrix = rs.BlockInstanceXform(obj) if arrMatrix is not None: # pointId = rs.AddPoint([0,0,0]) plane = rs.PlaneTransform(rs.WorldXYPlane(), arrMatrix) box = rs.BoundingBox(obj, plane) bb = rs.AddBox(box) # if box: # for i, point in enumerate(box): # rs.AddTextDot( i, point ) xformscale = rs.XformScale((1.0, 20.0, 1.0)) cob = rs.XformChangeBasis(rs.WorldXYPlane(), plane) cob_inverse = rs.XformChangeBasis(plane, rs.WorldXYPlane()) temp = rs.XformMultiply(xformscale, cob) xform = rs.XformMultiply(cob_inverse, temp) rs.TransformObjects(bb, xform) return bb
def translate_plane(plane, vector): """Shifts the input plane by the given vector.""" translation = rs.XformTranslation(vector) return rs.PlaneTransform(plane, translation)
# input is guid of referenced block import rhinoscriptsyntax as rs import ghpythonlib.treehelpers as th import scriptcontext as sc import Rhino as rc sc.doc = rc.RhinoDoc.ActiveDoc cameraPos = rs.ViewCamera() cameraPos.Z = 0 xform = rs.BlockInstanceXform(x) plane = rs.PlaneTransform(rs.WorldXYPlane(), xform) viewdir = rs.VectorUnitize(cameraPos - plane.Origin) angle = rs.VectorAngle(viewdir, plane.YAxis) newplane = rs.RotatePlane(plane, angle, plane.ZAxis) a = xform b = plane c = cameraPos d = viewdir e = plane.YAxis
def blkPlane(obj): xform = rs.BlockInstanceXform(obj) plane = rs.PlaneTransform(rs.WorldXYPlane(), xform) return plane