def Main(): jointno = 4 list = [] dir0 = rs.GetPoint("from") dir1 = rs.GetPoint("hub") dir2 = rs.GetPoints(False, False, "outline_left_to_right") #THIS VECTOR WILL ALLOW US TO TAKE INTO ACCOUNT POSSIBLE LAYOUT OF DRAWN JOINTS ON THE PAGE fix = rs.VectorSubtract([0, 0, 0], dir1) dir0 = rs.VectorAdd(dir0, fix) dir1 = rs.VectorAdd(dir1, fix) indir = rs.VectorSubtract(dir1, dir0) for j in range(len(dir2)): pt = rs.VectorAdd(dir2[j], fix) dir2[j] = pt list.append([dir1, indir, dir2]) for i in (range(jointno)[1:]): dir0 = rs.GetPoint("from") dir1 = rs.GetPoint("hub") dir2 = rs.GetPoint("to") #THIS VECTOR WILL ALLOW US TO TAKR INTO ACCOUNT POSSIBLE LAYOUT OF DRAWN JOINTS ON THE PAGE fix = rs.VectorSubtract([0, 0, 0], dir1) #What is this line doing??? dir0 = rs.VectorAdd(dir0, fix) dir1 = rs.VectorAdd(dir1, fix) dir2 = rs.VectorAdd(dir2, fix) #Setting up direction vectors! indir = rs.VectorSubtract(dir1, dir0) outdir = rs.VectorSubtract(dir2, dir1) lside = rs.GetPoints(False, False, "left") rside = rs.GetPoints(False, False, "right") for j in range(len(lside)): pt = rs.VectorAdd(lside[j], fix) lside[j] = pt for j in range(len(rside)): pt = rs.VectorAdd(rside[j], fix) rside[j] = pt list.append([dir1, indir, lside, rside, outdir]) WritePolies(addresss, list)
def get_points(): """Prompts for a point triple. Returns a list of the points: [<iter>, ...] """ points = rs.GetPoints(draw_lines=False, in_plane=False, message1='Select first tail', message2='Select heads', max_points=None, base_point=None) return points
def SampleBlockLeader(): go = Rhino.Input.Custom.GetObject() go.SetCommandPrompt("Select block instance to annotate") go.GeometryFilter = Rhino.DocObjects.ObjectType.InstanceReference go.EnablePreSelect(False, True) go.InactiveDetailPickEnabled = True rc = go.Get() if rc == Rhino.Input.GetResult.Object: prompt0 = "First point of leader" prompt1 = "Next point of leader. Press Enter when done" points = rs.GetPoints(True, True, prompt0, prompt1) if points is not None: objref = go.Object(0) obj = objref.Object() name = rs.BlockInstanceName(obj.Id) rs.AddLeader(points, None, name)
def addArcLeader(): """ Automatically calculates and annotates the length of a curve object, used primarily for arc length Input parameters: None Returns: Guid if successful None if failure """ try: #assign empty variables points = [] leader = None #get curve crv = rs.GetCurveObject("Select curve object") crvLen = rs.CurveLength(crv[0]) #get curve's length #get points pts = rs.GetPoints("AddPoints, press enter when done") points = rs.AddPoints(pts) #make leader leader = rs.AddLeader(points, text="ArcLength: " + str(round(crvLen, 3))) return leader except Exception: pass finally: if points: rs.DeleteObjects( points) #points will be deleted even upon exception return leader
def dividePointsInX(): points = rs.GetPoints() x = 0 for point in points: arCoord = rs.GetPointCoordinates();
#Python Workshop Lesson:04 #http://designalyze.com/int2pythonscripting04_listscurvetypes #Lists of Points + Curve Types #Bonus simple for loop import rhinoscriptsyntax as rs listPoints = [] listPoints = rs.GetPoints(True, True, "Pick a starting point", "Keep picking points until you get tired") #Curve Types myPolyline = rs.AddPolyline(listPoints) myCurve = rs.AddCurve(listPoints) myIntpCurve = rs.AddInterpCurve(listPoints) #Curve Colors #Colors are Arrays of [r,g,b] color01 = [0, 255, 255] #cyan color02 = [255, 0, 255] #magenta color03 = [255, 255, 0] #yellow #Change Color of Curves rs.ObjectColor(myPolyline, color01) rs.ObjectColor(myCurve, color02) rs.ObjectColor(myIntpCurve, color03) #Bonus For Loop for point in listPoints: rs.AddPoint(point)
# -- coding: utf-8 -- #这段代码的功能是画一个引线标注,自动给出起点的XY坐标,第一个点是需要标注的坐标点位置 #注意: rhino的单位默认为MM, 测绘图的坐标体系X为建筑专业平面图竖坐标,Y为横坐标 #引线的默认尺寸画完后在属性里可以改 import rhinoscriptsyntax as rs leaderB = rs.GetPoints(True, False, "Select leader points") PC_B = leaderB[0] PS_B = repr(PC_B) #Attention that the Mapping Drawing X is the vertical co-ordinates in CAD plan XB0 = float(PS_B.split('[')[-1].split(',')[1]) YB0 = float(PS_B.split('[')[-1].split(',')[0]) #When the rhino Unit is mm,IF not comment out the next line 注意rhino的单位默认为MM,测绘图为米,如果都是米则下面一行前加#号 XB0 = XB0 / 1000 XB = round(XB0, 3) #When the rhino Unit is mm,IF not comment out the next line 注意rhino的单位默认为MM,测绘图为米,如果都是米则下面一行前加#号 YB0 = YB0 / 1000 YB = round(YB0, 3) if PS_B: rs.AddLeader(leaderB, None, "X=%s\nY=%s" % (XB, YB))
def get_polyline(): points = rs.GetPoints(draw_lines = True, in_plane = True, max_points = 3) if points and len(points)>1: return Rhino.Geometry.Polyline(points) return False
# Lists of Points and Curve Types #import the Rhinoscript Library and set the reference to 'rs' import rhinoscriptsyntax as rs #create and empty list to store points ptList = [] #prompt user to select points ptList = rs.GetPoints(True, True, "Please select start point", "Select next point, Enter When finished") #print contents of list print(ptList) #Create some Curves of different types from our Point List myPolyLine = rs.AddPolyline(ptList) myCurve = rs.AddCurve(ptList) myIntpCurve = rs.AddInterpCurve(ptList) #output type and GUID print type(myPolyLine) print myCurve print myIntpCurve #Color Curves #Colors are tuples color01 = (255, 0, 0) #red color02 = (0, 255, 0) #green color03 = (0, 0, 255) #blue #Change Color of Curves
#define imputs for brick wall height = rs.GetReal('Please enter brick height',2.25) length = rs.GetReal('Please enter brick length',7.625) width = rs.GetReal('Please enter brick width',3.325) gap = rs.GetReal('Please enter desired gap between bricks',.9) spaceBetweenBricks = length+gap rowCount = rs.GetInteger('Please enter desired number of rows of bricks',10) rotation = rs.GetReal('Please enter brick rotation in degrees',0) #create the world axis as vectors worldZAxis = rs.VectorCreate([0,0,1],[0,0,0]) #create curves to define wall and loft to get wall surface #upperCurve = rs.AddCurve([[7,7,0],[15,-8,0],[0,-16,0]]) #lowerCurve = rs.AddCurve([[12,12,0],[1,11,0],[-3,8,0],[6,-2,0],[-7,-11,0]]) lowerCurve = rs.AddCurve(rs.GetPoints(True,True,'Please select points to create lower curve of wall')) upperCurve = rs.AddCurve(rs.GetPoints(True,True,'Please select points to create upper curve of wall, be sure to start on the same end of the wall as the lower curve')) upperCurve2 = rs.CopyObject(upperCurve,rs.VectorScale(worldZAxis,(height*rowCount))) loftedSurface = rs.AddLoftSrf([lowerCurve,upperCurve2]) rs.HideObjects([loftedSurface,lowerCurve,upperCurve,upperCurve2]) #intersect planes with surface to get the profile of the wall at each row intersected = rs.AddSrfContourCrvs(loftedSurface,([0,0,0], [0,0,(height*rowCount)]),height) rs.HideObjects(intersected) #make list of even and list of odd row profiles intersectedEven = [] intersectedOdd = [] for i in range(len(intersected)): if i%2 == 0 : intersectedEven.append(intersected[i])
def getPolyline(): points = rs.GetPoints(draw_lines=True, in_plane=True, max_points=3) if points: return Rhino.Geometry.Polyline(points) else: return False