def RunScript(self, AS, CL): # Initialize outputs S = [] TS = CL W = [] CS = [] # Set defaults if no values are provided D = 1000 # Iterate over each test segment for seg in CL: # Extend line to threshold width midpt, TT, t = ghc.EvaluateLength(seg, 0.5, True) SS, E = ghc.EndPoints(seg) V, L = ghc.Vector2Pt(midpt, SS, False) vect = ghc.Amplitude(V, D/2) G1, X = ghc.Move(midpt, vect) G2, X = ghc.Move(midpt, -vect) test_line = ghc.Line(G1, G2) # Rotate test line 90 degrees test_line, X = ghc.Rotate(test_line, math.pi/2, midpt) # Check for intersection srf_intersection = checkIntersection(test_line, AS, midpt, D) # Store results CS.append(srf_intersection) W.append(ghc.Length(srf_intersection)) # Return outputs return TS, W, CS
def copy_modules(): global meshes_a, meshes_b, meshes_c # Copying Modules meshes_a = [] meshes_b = [] meshes_c = [] totals = [0, 0, 0] for i, p in enumerate(points_input): d = voxel_data[i] if d == 0: continue cart = loc_to_cart(i) mesh_id = mesh_strategy_neighbors(cart) translation = gh.Vector2Pt(world_xy, p, False)[0] add = clamp( int((gh.Deconstruct(p)[2] / 4000 * 4) + (perlin_values[i] - 0.5)), 0, 3) if mesh_id == 0: meshes_a.append(gh.Move(mesh_input[16 + add], translation)[0]) elif mesh_id == 1: meshes_a.append(gh.Move(mesh_input[12 + add], translation)[0]) meshes_b.append(gh.Move(mesh_input[8 + add], translation)[0]) elif mesh_id == 2: meshes_b.append(gh.Move(mesh_input[4 + add], translation)[0]) meshes_c.append(gh.Move(mesh_input[0 + add], translation)[0]) totals[mesh_id] += 1 #new_plane = gh.PlaneOrigin(random.choose print totals
def leafgenerator(point): #random z move zmove = rg.Vector3d(0, 0, 1) moveamp = random.uniform(-leaflen / 3, leaflen / 5) ampzmove = ghc.Amplitude(zmove, moveamp) llendpnt = ghc.Move(point, ampzmove)[0] #setting a leaf centerline vector leafvector = ghc.Vector2Pt(leafpoint, llendpnt, True)[0] #defining leaf center point as avarage of st and end pnts midpnt = ghc.Average([leafpoint, llendpnt]) #generating perpendicular vector vecperpleaf = ghc.Rotate(leafvector, radians(90), planetocenter)[0] leafperpamp = ghc.Amplitude( vecperpleaf, random.uniform((leafwidth / 2) / 5 * 4, (leafwidth / 2) / 5 * 6)) #moving mid point to both sides midpnt1 = ghc.Move(midpnt, leafperpamp)[0] midpnt2 = ghc.Move(midpnt, -leafperpamp)[0] #leaf geo leafgeo = rg.NurbsSurface.CreateFromCorners( leafpoint, midpnt1, llendpnt, midpnt2) leaves.append(leafgeo)
def Cremona2(no, nomes, Linhas, countPF, dicPF): ptos1 = [] dicUp = {} for i in range(countPF): if i == 0: Spt = dicPF[nomes[i]].PointAt(0) Ept = dicPF[nomes[i]].PointAt(1) else: if i == 1: cond1 = rs.PointCompare(dicPF[nomes[i - 1]].PointAt(0), dicPF[nomes[i]].PointAt(1), Tol) cond2 = rs.PointCompare(dicPF[nomes[i - 1]].PointAt(0), dicPF[nomes[i]].PointAt(0), Tol) if cond1 or cond2: pAux3 = Spt Spt = Ept Ept = pAux3 if rs.PointCompare(Ept, dicPF[nomes[i]].PointAt(1), Tol): ptAux1 = dicPF[nomes[i]].PointAt(1) ptAux2 = dicPF[nomes[i]].PointAt(0) else: ptAux1 = dicPF[nomes[i]].PointAt(0) ptAux2 = dicPF[nomes[i]].PointAt(1) Ept += (ptAux2 - ptAux1) vAux1 = Line(rs.CurveStartPoint(Linhas[-2]), Ept) vAux2 = Line(rs.CurveStartPoint(Linhas[-1]), Spt) F1 = gh.Move(rs.coerceline(Linhas[-2]), vAux1)[0] F2 = gh.Move(rs.coerceline(Linhas[-1]), vAux2)[0] inter = gh.LineXLine(F1, F2)[2] F1 = rs.AddLine(Ept, inter) F2 = rs.AddLine(inter, Spt) dicUp[nomes[-2]] = rs.coerceline(F1) dicUp[nomes[-1]] = rs.coerceline(F2) #-cargas e nomenclatura #teste de tração e compressão sin1 = TraComp(no, F1, rs.coerceline(Linhas[-2]), nomes[-2]) sin2 = TraComp(no, F2, rs.coerceline(Linhas[-1]), nomes[-1]) #valores das cargas carga1 = rs.CurveLength(F1) * sin1 / Escala carga2 = rs.CurveLength(F2) * sin2 / Escala #teste de tensão admissivel cor1 = teste_elemento(nomes[-2], carga1, Linhas[-2]) cor2 = teste_elemento(nomes[-1], carga2, Linhas[-1]) #nomenclatura do FG txt1 = nomes[-2] + ' = ' + str('%.2f' % carga1) txt2 = nomes[-1] + ' = ' + str('%.2f' % carga2) pt1 = rs.coerceline(Linhas[-2]).PointAt(.5) pt2 = rs.coerceline(Linhas[-1]).PointAt(.5) ptos1 += [pt1, txt1, cor1] ptos1 += [pt2, txt2, cor2] #nimenclatura do PF pt1 = rs.coerceline(F1).PointAt(.5) pt2 = rs.coerceline(F2).PointAt(.5) txt1 = nomes[-2] txt2 = nomes[-1] ptos1 += [pt1, txt1, cor1] ptos1 += [pt2, txt2, cor2] return dicUp, ptos1
def inset_window_surface(self): """Moves the window geometry based on the InstallDepth param """ orientation = -1 # don't remember why this is... transform_vector = ghc.Amplitude(self.surface_normal, float(self.install_depth) * orientation) transformed_surface = ghc.Move(self.rh_surface, transform_vector).geometry return transformed_surface
def create_outside_points(segment): # Create a point mid-curve outside the region n_pts = max(int(segment.GetLength() / sample), 1) curve_points, tangents, _ = ghc.DivideCurve(segment, n_pts, False) if n_pts > 1: points = [] for curve_point in curve_points[1:-1]: normal = ghc.CrossProduct(tangents[0], global_Z, True) curve_point, _ = ghc.Move(curve_point, normal[0] * distance) points.append(curve_point) return points else: segment.Domain = reparam normal = ghc.CrossProduct(tangents, global_Z, True) curve_point = ghc.EvaluateCurve(segment, 0.5)[0] curve_point, _ = ghc.Move(curve_point, normal[0][0] * distance) return [curve_point]
def get_footprint(_surfaces): # Finds the 'footprint' of the building for 'Primary Energy Renewable' reference # 1) Re-build the Opaque Surfaces # 2) Join all the surface Breps into a single brep # 3) Find the 'box' for the single joined brep # 4) Find the lowest Z points on the box, offset another 10 units 'down' # 5) Make a new Plane at this new location # 6) Projects the brep edges onto the new Plane # 7) Split a surface using the edges, combine back into a single surface Footprint = namedtuple('Footprint', ['Footprint_surface', 'Footprint_area']) #----- Build brep surfaces = (from_face3d(surface.Srfc) for surface in _surfaces) bldg_mass = ghc.BrepJoin(surfaces).breps bldg_mass = ghc.BoundaryVolume(bldg_mass) if not bldg_mass: return Footprint(None, None) #------- Find Corners, Find 'bottom' (lowest Z) bldg_mass_corners = [v for v in ghc.BoxCorners(bldg_mass)] bldg_mass_corners.sort(reverse=False, key=lambda point3D: point3D.Z) rect_pts = bldg_mass_corners[0:3] #------- Projection Plane projection_plane1 = ghc.Plane3Pt(rect_pts[0], rect_pts[1], rect_pts[2]) projection_plane2 = ghc.Move(projection_plane1, ghc.UnitZ(-10)).geometry matrix = rs.XformPlanarProjection(projection_plane2) #------- Project Edges onto Projection Plane projected_edges = [] for edge in ghc.DeconstructBrep(bldg_mass).edges: projected_edges.append(ghc.Transform(edge, matrix)) #------- Split the projection surface using the curves l1 = ghc.Line(rect_pts[0], rect_pts[1]) l2 = ghc.Line(rect_pts[0], rect_pts[2]) max_length = max(ghc.Length(l1), ghc.Length(l2)) projection_surface = ghc.Polygon(projection_plane2, max_length * 100, 4, 0).polygon projected_surfaces = ghc.SurfaceSplit(projection_surface, projected_edges) #------- Remove the biggest surface from the set(the background srfc) projected_surfaces.sort(key=lambda x: x.GetArea()) projected_surfaces.pop(-1) #------- Join the new srfcs back together into a single one unioned_NURB = ghc.RegionUnion(projected_surfaces) unioned_surface = ghc.BoundarySurfaces(unioned_NURB) return Footprint(unioned_surface, unioned_surface.GetArea())
def _build_volume_brep_from_zone(self): # Floor Surface floor_surface = rs.coercebrep(self.tfa_surface.surface) floor_surface = ghc.Move(floor_surface, ghc.UnitZ(self._offset_z) )[0] # 0 is the new translated geometry # Extrusion curve surface_centroid = Rhino.Geometry.AreaMassProperties.Compute(floor_surface).Centroid end_point = ghc.ConstructPoint(surface_centroid.X, surface_centroid.Y, surface_centroid.Z + self._space_height) extrusion_curve = rs.AddLine(surface_centroid, end_point) volume_brep = rs.ExtrudeSurface(surface=floor_surface, curve=extrusion_curve, cap=True) volume_brep = rs.coercebrep(volume_brep) return [volume_brep]
def calcFootprint(_zoneObjs, _opaqueSurfaces): # Finds the 'footprint' of the building for 'Primary Energy Renewable' reference # 1) Re-build the zone Breps # 2) Join all the zone Breps into a single brep # 3) Find the 'box' for the single joined brep # 4) Find the lowest Z points on the box, offset another 10 units 'down' # 5) Make a new Plane at this new location # 6) Projects the brep onto the new Plane #----- zoneBreps = [] for zone in _zoneObjs: zoneSurfaces = [] for srfc in _opaqueSurfaces: if srfc.HostZoneName == zone.ZoneName: zoneSurfaces.append(ghc.BoundarySurfaces(srfc.Boundary)) zoneBrep = ghc.BrepJoin(zoneSurfaces).breps zoneBreps.append(zoneBrep) bldg_mass = ghc.SolidUnion(zoneBreps) if bldg_mass == None: return None #------- Find Corners, Find 'bottom' (lowest Z) bldg_mass_corners = [v for v in ghc.BoxCorners(bldg_mass)] bldg_mass_corners.sort(reverse=False, key=lambda point3D: point3D.Z) rect_pts = bldg_mass_corners[0:3] #------- Project Brep to Footprint projection_plane1 = ghc.Plane3Pt(rect_pts[0], rect_pts[1], rect_pts[2]) projection_plane2 = ghc.Move(projection_plane1, ghc.UnitZ(-10)).geometry matrix = rs.XformPlanarProjection(projection_plane2) footprint_srfc = rs.TransformObjects(bldg_mass, matrix, copy=True) footprint_area = rs.Area(footprint_srfc) #------- Output Footprint = namedtuple('Footprint', ['Footprint_surface', 'Footprint_area']) fp = Footprint(footprint_srfc, footprint_area) return fp
def TraComp(no, forcePF, forceFG, nome): pontoFG = forceFG.PointAt(.5) movevec = rs.AddLine(rs.CurveEndPoint(forcePF), no) movevec = rs.coerceline(movevec) testeLin = gh.Move(rs.coerceline(forcePF), movevec)[0] dist1 = rs.Distance(testeLin.PointAt(0), pontoFG) dist2 = gh.Length(testeLin) dist2 += (gh.Length(forceFG) / 2) #testando tração if abs(dist1 - dist2) <= Tol: #coloca a nomenclattura do elemento na lista de objetos tracionados Ltrac.append(nome) #retorna 1 para tração return 1 #se compressão else: #coloca a nomenclattura do elemento na lista de objetos comprimidos Lcomp.append(nome) #retorna -1 para compressão return -1
def fractal(depth, x1, y1, z1, x2, y2, z2, length, anglerec, angle, lvariation, aran, lran, anglerech, angleh, branches, verticality, gchance, depthstart, radtolen, radchng, mngon, polygon, branch_cluster): #test if depth>0 if depth: #defining random angle variation and length variation arn = random.uniform(-angle / 100 * aran, angle / 100 * aran) lrn = random.uniform(-length / 100 * lran, length / 100 * lran) if hrandom == True: #defining horizontal rotation angles ahor = random.sample(range(0, 360), branches) #removing numbers within tolerance ahr = rs.CullDuplicateNumbers(ahor, angleh) #in a 360 fashion if ahr[0] + 360 - angleh < ahr[-1]: del ahr[0] else: #generating evenly distributed angles ahr = range(0, 360 + 1, 360 // branches)[:-1] #previous branch vector vecst = rg.Point3d(x1, y1, z1) vecend = rg.Point3d(x2, y2, z2) movevec = ghc.Vector2Pt(vecst, vecend, True)[0] #returns vector and it's length #perpendicular vector rotplane3 = ghc.PlaneNormal( vecend, movevec) #creates plane perpendicular to vector plns = ghc.DeconstructPlane(rotplane3) #origin, x, y, z rotplane = ghc.ConstructPlane( plns[2], plns[1], plns[3] ) #constructing new plane switching x and y planes to make perpendicular #generating perpendicular vector vecperp = ghc.Rotate(movevec, radians(90), rotplane)[0] #generating vector amplitudes leny = (length + lrn) * sin( radians((anglerec + arn) * (1 - (verticality**depth)))) lenz = (length + lrn) * cos(radians(anglerec + arn)) ampy = ghc.Amplitude(vecperp, leny) ampz = ghc.Amplitude(movevec, lenz) #changing branch length dependant on branch depth length = length * lvariation #building points endpoint1 = ghc.Move( vecend, ampz)[0] #returns moved object and transformation data endpoint = ghc.Move( endpoint1, ampy)[0] #returns moved object and transformation data #rotating point in a cone fashion rotpoint = ghc.Rotate3D( endpoint, radians(anglerech), vecend, movevec)[0] #returns rotated geometry and transformation data #building line between points linegeo = rg.Line(vecend, rotpoint) #defining recursion depth key = depthstart + 1 - depth #building geometry pln = ghc.PlaneNormal(rotpoint, linegeo) #returns a plane perp to a vector radius = length * (radchng**(key)) / radtolen #reduce details with each branch, but not less than 3 if mngon - key + 1 <= 3: splits = 3 else: splits = mngon - key + 1 polygonend = ghc.Polygon(pln, radius, splits, 0)[0] #returns a polygon and its perimeter #aligning curves for loft creation crvst = ghc.EndPoints(polygon)[0] pntcld = ghc.Discontinuity(polygonend, 1) #returns points and point parameters #finind seam point closest_point = ghc.ClosestPoint( crvst, pntcld[0] ) #returns closest point, closest point index, distance between closest points seampnt = pntcld[1][closest_point[1]] polygonend = ghc.Seam(polygonend, seampnt) lcurves = [polygon, polygonend] #building geometry if depth == 1 and splits == 3: geo = ghc.ExtrudePoint( polygon, rotpoint) #if last branch than make a pyramid else: geo = rg.Brep.CreateFromLoft(lcurves, rg.Point3d.Unset, rg.Point3d.Unset, rg.LoftType.Normal, False)[0] #make solid geocapped = ghc.CapHoles(geo) #building a dict of geo with depth as key, and geo as values, for more efficient joins if branch_cluster not in pgons.keys(): pgons[branch_cluster] = [geocapped] else: pgons[branch_cluster].append(geocapped) #setting coords for next branch x1 = x2 y1 = y2 z1 = z2 #getting xyz from rotated point x2 = rg.Point3d(rotpoint)[0] y2 = rg.Point3d(rotpoint)[1] z2 = rg.Point3d(rotpoint)[2] #setting base polygon for next branch polygon = polygonend #calling function with different angle parameter for branch splitting #calling as many branches as spread within tolerance #filling dict with branch clusters cluster.append(cluster[-1] + 1) branch_cluster = cluster[-1] for aa in ahr: if ( (random.randint(40, 99) / 100)**depth ) < gchance or depth == depthstart + 1: #or added to prevent blank trees fractal(depth - 1, x1, y1, z1, x2, y2, z2, length, angle, angle, lvariation, aran, lran, aa, angleh, branches, verticality, gchance, depthstart, radtolen, radchng, mngon, polygon, branch_cluster)
DiagEixo = Diagonais for i in DiagEixo: vol = Volumetria(i, Diag_e / 2, Diag_l / 2, ptX) Tr_3D.append(vol) # 3D dos banzos e bordas do conector BzEixo = Banzo_Sup + Banzo_Inf + Conector for i in BzEixo: vol = Volumetria(i, Bz_e / 2, Bz_l / 2, ptX) Tr_3D.append(vol) # 3D da cobertura for i in Cobertura: vol = Volumetria(i, .01, Dist_entre_eixos / 2, ptX) Tr_3D.append(vol) # copiando treliças de acordo com a distancia entre os eixos for i in range(1, N_Tr, 1): Tr_copias += gh.Move(Tr_3D, i * Dist_entre_eixos * eZ)[0] ### - cargas - ### #area das diagonais AreaD = Diag_e * Diag_l ### menor momento de inercia das diagonais ID = MomInerMinQuad(Diag_l, Diag_e) #area do banzo AreaB = Bz_e * Bz_l ### menor momento de inercia dos Banzos IB = MomInerMinQuad(Bz_l, Bz_e) #peso linear das diagonais plDiag = AreaD * Peso_esp_Tr #peso linear do banzo plBz = AreaB * Peso_esp_Tr #peso linear da cobertura
def fractal(depth, x1, y1, z1, x2, y2, z2, length, anglerec, angle, lvariation, aran, lran, anglerech, angleh, branches, gravity): #test if depth>0 if depth: #defining random angle variation and length variation arn = random.uniform(-angle / 100 * aran, angle / 100 * aran) lrn = random.uniform(-length / 100 * lran, length / 100 * lran) #defining horizontal rotation angles ahor = random.sample(range(0, 360), branches) """ #removing numbers within tolerance ahr = rs.CullDuplicateNumbers(ahor, angleh) #in a 360 fashion if ahr[0]+360-angleh<ahr[-1]: del ahr[0] random.shuffle(ahr) """ ahr = [0, 90, 270, 180] #previous branch vector vecst = rg.Point3d(x1, y1, z1) vecend = rg.Point3d(x2, y2, z2) movevec = ghc.Vector2Pt(vecst, vecend, True)[0] #returns vector and it's length #perpendicular vector rotation plane rotplane3 = ghc.PlaneNormal( vecend, movevec) #creates plane perpendicular to vector plns = ghc.DeconstructPlane(rotplane3) #origin, x, y, z rotplane = ghc.ConstructPlane( plns[0], plns[3], plns[2] ) #constructing new plane switching x and y planes to make perpendicular #generating perpendicular vector vecperp = ghc.Rotate(movevec, radians(90), rotplane)[0] #generating vector amplitudes leny = (length + lrn) * sin(radians(anglerec + arn)) lenz = (length + lrn) * cos(radians(anglerec + arn)) ampy = ghc.Amplitude(vecperp, leny) ampz = ghc.Amplitude(movevec, lenz) #changing branch length dependant on branch depth length = length * lvariation #building points endpoint1 = ghc.Move( vecend, ampz)[0] #returns moved object and transformation data endpoint = ghc.Move( endpoint1, ampy)[0] #returns moved object and transformation data #rotating point in a cone fashion rotpoint = ghc.Rotate3D( endpoint, anglerech, vecend, movevec)[0] #returns rotated geometry and transformation data #vertical branch angle angl1 = ghc.Angle(rg.Line(vecend, rotpoint), horizont, verticalpln)[0] #outputs angle and reflex angl = ghc.Degrees(angl1) anglls.append(angl) #rotate depending on how horizontal branch is if angl > 0 and angl < 180: if angl < 89: grrot = ((30 / 100) * (100 - (angl * 0.9)) / 100) * gravity elif angl > 91: grrot = ((30 / 100) * (100 - ((180 - angl) * 0.9)) / 100) * gravity try: grrot == 0 rotpoint = ghc.Rotate3D(rotpoint, grrot, vecend, verticalpln)[0] except: pass #building line between points linegeo = rg.Line(vecend, rotpoint) #setting coords for next branch x1 = x2 y1 = y2 z1 = z2 #getting xyz from rotated point x2 = rg.Point3d(rotpoint)[0] y2 = rg.Point3d(rotpoint)[1] z2 = rg.Point3d(rotpoint)[2] #building a dict of lines with depth as key, and corresponding lines as values if depth not in treelin.keys(): treelin[depth] = [linegeo] else: treelin[depth].append(linegeo) #calling function with different angle parameter for branch splitting #calling as many branches as spread within tolerance for aa in ahr: fractal(depth - 1, x1, y1, z1, x2, y2, z2, length, angle, angle, lvariation, aran, lran, aa, angleh, branches, gravity)
pOr, eX, eY, eZ = Plano #-Copiando Curva inicial Curva = rs.CopyObjects(Curva, 10 * eY) BzSup1 = rs.coercecurve(Curva) #----Primeiro ponto do Eixo de Simetria---- #A variável Eixo_de_Simetria por entrada um float entre o e 1 ou #uma reta que intercepta a Curva no ponto do eixo #caso seja um float: if type(Eixo_de_Simetria) == float: #ptX1 = coordenadas da curva no ponto de interceção com o eixo de simetria #vct1 = tangente da curva no ponto #prm1 = parametro da curva no ponto ptX1, vtc1, prm1 = gh.EvaluateLength(BzSup1, Eixo_de_Simetria, True) ptAux = gh.Move(ptX1, -eY)[0] #-desenhando linha do Exio de simetria Eixo_de_Simetria = rs.AddLine(ptX1, ptAux) #caso seja uma linha elif str(type(Eixo_de_Simetria)) == "<type 'Guid'>": #ptX1 = coordenadas do ponto de interceção da Curva com o eixo de simetria #prm1 = parametro da curva no ponto #count = conta o número de interceções ptX1, prm1, count = gh.CurveXLine(BzSup1, rs.coerceline(Eixo_de_Simetria)) ptAux = gh.Move(ptX1, -eY)[0] #caso o vão da viga seja definido pela variavel VigaDist if VigaDist: ptobase = rs.CurveStartPoint(Curva) ptoAux = rs.LineClosestPoint(Eixo_de_Simetria, ptobase) dist1 = rs.Distance(ptobase, ptoAux) escala = (VigaDist / 2) / dist1
def EixosVigas(BZ, DiagN, d1, od1, d2, od2): #----Diagnoais---- #dividir o banzo superior 1 em 2 x (numero de diagonais de v) ptB1 = rs.DivideCurve(BZ, (2 * DiagN)) #a variável EPcurv armazena o start point do eixo do banzo superior SPCurv = ptB1[0] #exclui o primeiro valor da lista (start point da curva do banzo superior) ptB1 = ptB1[1:] #pAux é o ponto de partida do eixo do banzo inferior pAux = gh.Move(Point3d(SPCurv), -d2 * eY)[0] #Offsets da curva do banzo sup nas distancias d1 e d2 cAux1 = rs.OffsetCurve(BZ, od1, d1, eZ) cAux2 = rs.OffsetCurve(BZ, od2, d2, eZ) #-aplicando mascara binária #ptB1 = lista dos nós do banzo sup ptB1 = gh.Dispatch(ptB1, [False, True, False, False])[0] # iniciando lista dos nós do bazo infeirior apoio = pAux ptB2 = [pAux] #-calculando nós do banzo inferior #contador FOR do primeiro ao penultimo item de ptb1 for i in range(len(ptB1) - 1): #desenha linhas etrne o ponto atual e próximo ponto de ptB1 linAux = Line(ptB1[i], ptB1[i + 1]) #pAux = ponto médio de linAux pAux3 = linAux.PointAt(.5) #calcula ponto em cAux1 mais proximo de pAux #pAux1 =[(coordenadas do pto),(parametro do pto),(distância pto-crv)] pAux1 = gh.CurveClosestPoint(pAux3, rs.coercecurve(cAux1)) #idem - cAux2 #pAux2 = idem pAux2 = gh.CurveClosestPoint(pAux3, rs.coercecurve(cAux2)) #linha entre os pontos equivalentes das curvas cAux1 e cAux2 linAux2 = Line(pAux2[0], pAux1[0]) #cAux3 = cAux1 cortada (trim) no ponto pAux1 cAux3 = rs.TrimCurve(cAux1, (0, pAux1[1]), False) #razão entre o comprimento da curva cAux1 até o ponto pAux1 #e o compriento total de cAux1 prmt = rs.CurveLength(cAux3) / rs.CurveLength(cAux1) #ponto que interpola as alturas VH1 e VH2 pAux = linAux2.PointAt(prmt) #coloca o pto pAux na lista dos nós ptB2.append(pAux) #o ponto final do banzo inferior é colocado no final da lista ptB2 ptB2.append(rs.CurveEndPoint(cAux1)) #-ajuste do ultimo ponto da treliça nosD = gh.Weave([0, 1], ptB2, ptB1) if DiagN % 2 == 0: ptB1.append(rs.CurveEndPoint(BZ)) else: del nosD[-1] #desenha diagonais lDiag = rs.AddPolyline(nosD) #desenha banzo inferior bzInf = rs.AddPolyline(ptB2) #desenha banzo superior bzSup = rs.AddPolyline(ptB1) return lDiag, bzSup, bzInf, nosD, ptB1, ptB2, apoio
def fractal(depth, x1, y1, z1, x2, y2, z2, length, anglerec, angle, lvariation, aran, lran, anglerech, angleh, branches, verticality, gchance): #test if depth>0 if depth: #defining random angle variation and length variation arn = random.uniform(-angle / 100 * aran, angle / 100 * aran) lrn = random.uniform(-length / 100 * lran, length / 100 * lran) if hrandom == True: #defining horizontal rotation angles ahor = random.sample(range(0, 360), branches) #removing numbers within tolerance ahr = rs.CullDuplicateNumbers(ahor, angleh) #in a 360 fashion if ahr[0] + 360 - angleh < ahr[-1]: del ahr[0] else: #generating evenly distributed angles ahr = range(0, 360 + 1, 360 // branches)[:-1] #previous branch vector vecst = rg.Point3d(x1, y1, z1) vecend = rg.Point3d(x2, y2, z2) movevec = ghc.Vector2Pt(vecst, vecend, True)[0] #returns vector and it's length #perpendicular vector rotplane3 = ghc.PlaneNormal( vecend, movevec) #creates plane perpendicular to vector plns = ghc.DeconstructPlane(rotplane3) #origin, x, y, z rotplane = ghc.ConstructPlane( plns[2], plns[1], plns[3] ) #constructing new plane switching x and y planes to make perpendicular #generating perpendicular vector vecperp = ghc.Rotate(movevec, radians(90), rotplane)[0] #generating vector amplitudes leny = (length + lrn) * sin( radians((anglerec + arn) * (1 - (verticality**depth)))) lenz = (length + lrn) * cos(radians(anglerec + arn)) ampy = ghc.Amplitude(vecperp, leny) ampz = ghc.Amplitude(movevec, lenz) #changing branch length dependant on branch depth length = length * lvariation #building points endpoint1 = ghc.Move( vecend, ampz)[0] #returns moved object and transformation data endpoint = ghc.Move( endpoint1, ampy)[0] #returns moved object and transformation data #rotating point in a cone fashion rotpoint = ghc.Rotate3D( endpoint, radians(anglerech), vecend, movevec)[0] #returns rotated geometry and transformation data #building line between points linegeo = rg.Line(vecend, rotpoint) #setting coords for next branch x1 = x2 y1 = y2 z1 = z2 #getting xyz from rotated point x2 = rg.Point3d(rotpoint)[0] y2 = rg.Point3d(rotpoint)[1] z2 = rg.Point3d(rotpoint)[2] #building a dict of lines with depth as key, and corresponding lines as values if depth not in treelin.keys(): treelin[depth] = [linegeo] else: treelin[depth].append(linegeo) #calling function with different angle parameter for branch splitting #calling as many branches as spread within tolerance for aa in ahr: if ( (random.randint(40, 99) / 100)**depth ) < gchance or depth == depthstart + 1: #or added to prevent blank trees fractal(depth - 1, x1, y1, z1, x2, y2, z2, length, angle, angle, lvariation, aran, lran, aa, angleh, branches, verticality, gchance)
def fractal(depth, x1, y1, z1, x2, y2, z2, length, anglerec, angle, lvariation, aran, lran, anglerech, angleh, branches, verticality, gchance, depthstart, radtolen, radchng, mngon, polygon): #test if depth>0 if depth: #defining random angle variation and length variation arn = random.uniform(-angle / 100 * aran, angle / 100 * aran) lrn = random.uniform(-length / 100 * lran, length / 100 * lran) if hrandom == True: #defining horizontal rotation angles ahor = random.sample(range(0, 360), branches) #removing numbers within tolerance ahr = rs.CullDuplicateNumbers(ahor, angleh) #in a 360 fashion if ahr[0] + 360 - angleh < ahr[-1]: del ahr[0] else: #generating evenly distributed angles ahr = range(0, 360 + 1, 360 // branches)[:-1] #previous branch vector vecst = rg.Point3d(x1, y1, z1) vecend = rg.Point3d(x2, y2, z2) movevec = ghc.Vector2Pt(vecst, vecend, True)[0] #returns vector and it's length #perpendicular vector rotplane3 = ghc.PlaneNormal( vecend, movevec) #creates plane perpendicular to vector plns = ghc.DeconstructPlane(rotplane3) #origin, x, y, z rotplane = ghc.ConstructPlane( plns[2], plns[1], plns[3] ) #constructing new plane switching x and y planes to make perpendicular #generating perpendicular vector vecperp = ghc.Rotate(movevec, radians(90), rotplane)[0] #generating vector amplitudes leny = (length + lrn) * sin( radians((anglerec + arn) * (1 - (verticality**depth)))) lenz = (length + lrn) * cos(radians(anglerec + arn)) ampy = ghc.Amplitude(vecperp, leny) ampz = ghc.Amplitude(movevec, lenz) #changing branch length dependant on branch depth length = length * lvariation #building points endpoint1 = ghc.Move( vecend, ampz)[0] #returns moved object and transformation data endpoint = ghc.Move( endpoint1, ampy)[0] #returns moved object and transformation data #rotating point in a cone fashion rotpoint = ghc.Rotate3D( endpoint, radians(anglerech), vecend, movevec)[0] #returns rotated geometry and transformation data #building line between points linegeo = rg.Line(vecend, rotpoint) #defining recursion depth key = depthstart + 1 - depth #building geometry #stpnt = VECEND ghc.EndPoints(nn)[0] #returns list of two points, start and end #endpnt = ROTPOINT ghc.EndPoints(nn)[1] pln = ghc.PlaneNormal(rotpoint, linegeo) #returns a plane perp to a vector radius = length * (radchng**(key)) / radtolen #polygon = polygonbase #reduce details with each branch, but not less than 3 if mngon - key + 1 <= 3: splits = 3 else: splits = mngon - key + 1 polygonend = ghc.Polygon(pln, radius, splits, 0)[0] #returns a polygon and its perimeter #creating loft between polygons #Normal = rg.LoftType.Normal #loptions = ghc.LoftOptions(False, True, 0, 0, rg.LoftType.Normal) #loft option lcurves = [polygon, polygonend] #loftedgeo = ghc.Loft(lcurves, loptions) if depth == 1 and splits == 3: geo = ghc.ExtrudePoint( polygon, rotpoint) #if last branch than make a pyramid else: geo = ghc.RuledSurface(polygon, polygonend) #setting coords for next branch x1 = x2 y1 = y2 z1 = z2 #getting xyz from rotated point x2 = rg.Point3d(rotpoint)[0] y2 = rg.Point3d(rotpoint)[1] z2 = rg.Point3d(rotpoint)[2] #setting base polygon for next branch polygon = polygonend #pgons.append(polygon) #pgons.append(linegeo) pgons.append(geo) #calling function with different angle parameter for branch splitting #calling as many branches as spread within tolerance for aa in ahr: if ( (random.randint(40, 99) / 100)**depth ) < gchance or depth == depthstart + 1: #or added to prevent blank trees fractal(depth - 1, x1, y1, z1, x2, y2, z2, length, angle, angle, lvariation, aran, lran, aa, angleh, branches, verticality, gchance, depthstart, radtolen, radchng, mngon, polygon)
def fractal(depth, x1, y1, z1, x2, y2, z2, length, anglerec, angle, lvariation, aran, lran, anglerech, angleh, branches, verticality, gchance, depthstart, radtolen, radchng, mngon, polygon, branch_cluster): #test if depth>0 if depth: #defining random angle variation and length variation arn = random.uniform(-angle / 100 * aran, angle / 100 * aran) lrn = random.uniform(-length / 100 * lran, length / 100 * lran) if hrandom == True: #defining horizontal rotation angles ahor = random.sample(range(0, 360), branches) #removing numbers within tolerance ahr = rs.CullDuplicateNumbers(ahor, angleh) #in a 360 fashion if ahr[0] + 360 - angleh < ahr[-1]: del ahr[0] else: #generating evenly distributed angles ahr = range(0, 360 + 1, 360 // branches)[:-1] #previous branch vector vecst = rg.Point3d(x1, y1, z1) vecend = rg.Point3d(x2, y2, z2) movevec = ghc.Vector2Pt(vecst, vecend, True)[0] #returns vector and it's length #perpendicular vector rotplane3 = ghc.PlaneNormal( vecend, movevec) #creates plane perpendicular to vector plns = ghc.DeconstructPlane(rotplane3) #origin, x, y, z rotplane = ghc.ConstructPlane( plns[2], plns[1], plns[3] ) #constructing new plane switching x and y planes to make perpendicular #generating perpendicular vector vecperp = ghc.Rotate(movevec, radians(90), rotplane)[0] #generating vector amplitudes leny = (length + lrn) * sin( radians((anglerec + arn) * (1 - (verticality**depth)))) lenz = (length + lrn) * cos(radians(anglerec + arn)) ampy = ghc.Amplitude(vecperp, leny) ampz = ghc.Amplitude(movevec, lenz) #changing branch length dependant on branch depth length = length * lvariation #building points endpoint1 = ghc.Move( vecend, ampz)[0] #returns moved object and transformation data endpoint = ghc.Move( endpoint1, ampy)[0] #returns moved object and transformation data #rotating point in a cone fashion rotpoint = ghc.Rotate3D( endpoint, radians(anglerech), vecend, movevec)[0] #returns rotated geometry and transformation data #building line between points linegeo = rg.Line(vecend, rotpoint) #defining recursion depth key = depthstart + 1 - depth #building geometry pln = ghc.PlaneNormal(rotpoint, linegeo) #returns a plane perp to a vector radius = length * (radchng**(key)) / radtolen #reduce details with each branch, but not less than 3 splits = 3 if mngon - key + 1 <= 3 else mngon - key + 1 polygonend = ghc.Polygon(pln, radius, splits, 0)[0] #returns a polygon and its perimeter #aligning curves for loft creation crvst = ghc.EndPoints(polygon)[0] pntcld = ghc.Discontinuity(polygonend, 1) #returns points and point parameters #finind seam point closest_point = ghc.ClosestPoint( crvst, pntcld[0] ) #returns closest point, closest point index, distance between closest points seampnt = pntcld[1][closest_point[1]] polygonend = ghc.Seam(polygonend, seampnt) lcurves = [polygon, polygonend] #building geometry geo = ghc.ExtrudePoint( polygon, rotpoint ) if depth == 1 and splits == 3 else rg.Brep.CreateFromLoft( lcurves, rg.Point3d.Unset, rg.Point3d.Unset, rg.LoftType.Normal, False)[0] #if last branch than make a pyramid #make solid geocapped = ghc.CapHoles(geo) #building a dict of geo with depth as key, and geo as values pgons.update( {branch_cluster: [geocapped]}) if branch_cluster not in pgons.keys( ) else pgons[branch_cluster].append(geocapped) branchesout.append(geocapped) #setting coords for next branch x1 = x2 y1 = y2 z1 = z2 #getting xyz from rotated point x2 = rg.Point3d(rotpoint)[0] y2 = rg.Point3d(rotpoint)[1] z2 = rg.Point3d(rotpoint)[2] #setting base polygon for next branch polygon = polygonend #filling dict with branch clusters cluster.append(cluster[-1] + 1) branch_cluster = cluster[-1] #calling function with different angle parameter for branch splitting, calling as many branches as spread within tolerance if depth != 1: for aa in ahr: if ( (random.randint(40, 99) / 100)**depth ) < gchance or depth == depthstart + 1: #or added to prevent blank trees fractal(depth - 1, x1, y1, z1, x2, y2, z2, length, angle, angle, lvariation, aran, lran, aa, angleh, branches, verticality, gchance, depthstart, radtolen, radchng, mngon, polygon, branch_cluster) #leaf logic if depth <= leavesdepth and leavesperbranch > 0 and maxleaves > 0: #vector for leaf growth spread leafpntvec = ghc.Vector2Pt(vecend, rotpoint, True)[0] #setting leaf growth position on last barnch, leafpnt list lastbranchlength = ghc.Length(linegeo) leaves_list = [lastbranchlength] [ leaves_list.append(lengthparam) for lengthparam in random.sample( range(0, int(lastbranchlength)), leavesperbranch - 1) ] if leavesperbranch > 1 else None for leafpnt in leaves_list: leafamp = ghc.Amplitude(leafpntvec, leafpnt) leafpoint = ghc.Move(vecend, leafamp)[0] #plane for leaf generation linetocenter = ghc.Line(stpntbase, leafpoint) planetocenter = ghc.PlaneNormal(leafpoint, linetocenter) #create an imaginary circle with leaflen radius and populate it with points for random leaf generation leafgenerationcircle = ghc.CircleCNR(leafpoint, linetocenter, leaflen) circlesurf = ghc.BoundarySurfaces(leafgenerationcircle) leafcnt = random.randint(0, maxleaves) if leafcnt > 0: leafendpnts = ghc.PopulateGeometry(circlesurf, leafcnt, random.randint(1, 500)) def leafgenerator(point): #random z move zmove = rg.Vector3d(0, 0, 1) moveamp = random.uniform(-leaflen / 3, leaflen / 5) ampzmove = ghc.Amplitude(zmove, moveamp) llendpnt = ghc.Move(point, ampzmove)[0] #setting a leaf centerline vector leafvector = ghc.Vector2Pt(leafpoint, llendpnt, True)[0] #defining leaf center point as avarage of st and end pnts midpnt = ghc.Average([leafpoint, llendpnt]) #generating perpendicular vector vecperpleaf = ghc.Rotate(leafvector, radians(90), planetocenter)[0] leafperpamp = ghc.Amplitude( vecperpleaf, random.uniform((leafwidth / 2) / 5 * 4, (leafwidth / 2) / 5 * 6)) #moving mid point to both sides midpnt1 = ghc.Move(midpnt, leafperpamp)[0] midpnt2 = ghc.Move(midpnt, -leafperpamp)[0] #leaf geo leafgeo = rg.NurbsSurface.CreateFromCorners( leafpoint, midpnt1, llendpnt, midpnt2) leaves.append(leafgeo) #iterate over random number of generated points if list, else generate for one point [leafgenerator(pp) for pp in leafendpnts] if isinstance( leafendpnts, list) else leafgenerator(leafendpnts)
def find_reveal_shading(_phpp_window_obj, _shadingGeom, _extents=99): WinCenter = ghc.Area(_phpp_window_obj.glazing_surface).centroid edges = _phpp_window_obj._get_edges_in_order( _phpp_window_obj.glazing_surface ) surface_normal = _phpp_window_obj.surface_normal #Create the Intersection Surface for each side Side1_OriginPt = ghc.CurveMiddle( from_linesegment3d(edges.Left) ) Side1_NormalLine = ghc.LineSDL(Side1_OriginPt, surface_normal, _extents) Side1_Direction = ghc.Vector2Pt(WinCenter, Side1_OriginPt, False).vector Side1_HorizLine = ghc.LineSDL(Side1_OriginPt, Side1_Direction, _extents) Side1_IntersectionSurface = ghc.SumSurface(Side1_NormalLine, Side1_HorizLine) #Side2_OriginPt = SideMidPoints[1] #ghc.CurveMiddle(self.Edge_Left) Side2_OriginPt = ghc.CurveMiddle( from_linesegment3d(edges.Right) ) Side2_NormalLine = ghc.LineSDL(Side2_OriginPt, surface_normal, _extents) Side2_Direction = ghc.Vector2Pt(WinCenter, Side2_OriginPt, False).vector Side2_HorizLine = ghc.LineSDL(Side2_OriginPt, Side2_Direction, _extents) Side2_IntersectionSurface = ghc.SumSurface(Side2_NormalLine, Side2_HorizLine) #Find any Shader Objects and put them all into a list Side1_RevealShaderObjs = [] testStartPt = ghc.Move(WinCenter, ghc.Amplitude(surface_normal, 0.1)).geometry #Offsets the test line just a bit Side1_TesterLine = ghc.LineSDL(testStartPt, Side1_Direction, _extents) #extend a line off to side 1 for i in range(len(_shadingGeom)): if ghc.BrepXCurve(_shadingGeom[i],Side1_TesterLine).points != None: Side1_RevealShaderObjs.append(_shadingGeom[i]) Side2_RevealShaderObjs = [] Side2_TesterLine = ghc.LineSDL(testStartPt, Side2_Direction, _extents) #extend a line off to side 2 for i in range(len(_shadingGeom)): if ghc.BrepXCurve(_shadingGeom[i],Side2_TesterLine).points != None: Side2_RevealShaderObjs.append(_shadingGeom[i]) #--------------------------------------------------------------------------- # Calc Shading reveal dims NumShadedSides = 0 if len(Side1_RevealShaderObjs) != 0: Side1_o_reveal = CalcRevealDims(_phpp_window_obj, Side1_RevealShaderObjs, Side1_IntersectionSurface, Side1_OriginPt, Side1_Direction)[0] Side1_d_reveal = CalcRevealDims(_phpp_window_obj, Side1_RevealShaderObjs, Side1_IntersectionSurface, Side1_OriginPt, Side1_Direction)[1] Side1_CheckLine = CalcRevealDims(_phpp_window_obj, Side1_RevealShaderObjs, Side1_IntersectionSurface, Side1_OriginPt, Side1_Direction)[2] NumShadedSides = NumShadedSides + 1 else: Side1_o_reveal = None Side1_d_reveal = None Side1_CheckLine = Side1_HorizLine if len(Side2_RevealShaderObjs) != 0: Side2_o_reveal = CalcRevealDims(_phpp_window_obj, Side2_RevealShaderObjs, Side2_IntersectionSurface, Side2_OriginPt, Side2_Direction)[0] Side2_d_reveal = CalcRevealDims(_phpp_window_obj, Side2_RevealShaderObjs, Side2_IntersectionSurface, Side2_OriginPt, Side2_Direction)[1] Side2_CheckLine = CalcRevealDims(_phpp_window_obj, Side2_RevealShaderObjs, Side2_IntersectionSurface, Side2_OriginPt, Side2_Direction)[2] NumShadedSides = NumShadedSides + 1 else: Side2_o_reveal = None Side2_d_reveal = None Side2_CheckLine = Side2_HorizLine # # # # TODO: how to handel asymetrical reveals???? o_reveal = Side1_o_reveal#(Side1_o_reveal + Side2_o_reveal )/ max(1,NumShadedSides) d_reveal = Side1_d_reveal#(Side1_d_reveal + Side2_d_reveal )/ max(1,NumShadedSides) # # # # # return o_reveal, d_reveal, Side1_CheckLine, Side2_CheckLine
return gh.Length(Line(pt1,pt2)) # Desenhando o poligono de forças pAux = rs.coerce3dpoint(pto_inicial) polo = rs.coerce3dpoint(polo) #primeiro raio polar raios.append(Line(polo,pAux)) for v in vetores: vAux1 = rs.coerceline(v) vAux2 = pAux - v.PointAt(0) vAux3 = gh.Move(vAux1,vAux2)[0] pAux = vAux3.PointAt(1) PF.append(vAux3) r=Line(polo,pAux) raios.append(r) #desenhando a resultante result=Line(rs.coerce3dpoint(pto_inicial),pAux) #Desenhando o funicular j = len(raios) for i in range(j):
def bakeText(_txt, _txtLocation, _layer, _txtSize=1, _neighbors=[], _avoidCollisions=False): """Bakes some Text to the Rhino scene _txt: <String> The actual text / note to bake _txtLocation: <Point3D> The reference point / location for the object _layer: <String> The layer to bake the object to _txtSize: <Float> The size of the text (height). Refers to the Annotation scale of the Page being printed _neighbors: <List> The other text tags being printed """ # https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_TextEntity.htm sc.doc = Rhino.RhinoDoc.ActiveDoc # The baseplane for the Text origin = _txtLocation basePlane_origin = Rhino.Geometry.Point3d(origin) basePlan_normal = Rhino.Geometry.Vector3d(0, 0, 1) # Assumes Top View basePlane = Rhino.Geometry.Plane(origin=basePlane_origin, normal=basePlan_normal) # Create the txt object txt = Rhino.Geometry.TextEntity() txt.Text = _txt txt.Plane = basePlane txt.TextHeight = _txtSize txt.Justification = Rhino.Geometry.TextJustification.MiddleCenter if _avoidCollisions: # Test against the other text items on the sheet # First, find / create the bouding box rectangle of the text note thisBB = txt.GetBoundingBox(txt.Plane) boxXdim = abs(thisBB.Min.X - thisBB.Max.X) boxYdim = abs(thisBB.Min.Y - thisBB.Max.Y) domainX = ghc.ConstructDomain((boxXdim / 2) * -1, boxXdim / 2) domainY = ghc.ConstructDomain((boxYdim / 2) * -1, boxYdim / 2) boundingRect = ghc.Rectangle(txt.Plane, domainX, domainY, 0).rectangle # Compare the current text note to the others already in the scene # Move the current tag if neccessary for eachNeighbor in _neighbors: intersection = ghc.CurveXCurve(eachNeighbor, boundingRect) if intersection.points != None: neighbor = ghc.DeconstuctRectangle( eachNeighbor) # The overlapping textbox neighborY = neighbor.Y # Returns a domain #neighborY = abs(neighborY[0] - neighborY[1]) # Total Y distance neighborCP = neighbor.base_plane.Origin thisCP = ghc.DeconstuctRectangle( boundingRect).base_plane.Origin if thisCP.Y > neighborCP.Y: # Move the tag 'up' neighborMaxY = neighborCP.Y + neighborY[1] thisMinY = thisCP.Y - (boxYdim / 2) moveVector = Rhino.Geometry.Vector3d( 0, neighborMaxY - thisMinY, 0) boundingRect = ghc.Move(boundingRect, moveVector).geometry else: # Move the tag 'down' neighborMinY = neighborCP.Y - neighborY[1] thisMaxY = thisCP.Y + (boxYdim / 2) moveVector = Rhino.Geometry.Vector3d( 0, neighborMinY - thisMaxY, 0) boundingRect = ghc.Move(boundingRect, moveVector).geometry #Re-Set the text tag's origin to the new location txt.Plane = ghc.DeconstuctRectangle(boundingRect).base_plane else: boundingRect = None # Add the new text object to the Scene txtObj = Rhino.RhinoDoc.ActiveDoc.Objects.AddText(txt) # Set the new Text's Layer if not rs.IsLayer(_layer): rs.AddLayer(_layer) rs.ObjectLayer(txtObj, _layer) sc.doc = ghdoc return boundingRect # Return the text bounding box
#Cargas na viga v3 C_v3, ptC_v3 = Linhas_de_Cargas(v3, P_v3, 'V3') Linhas_de_Carga += C_v3 txt_pontos += ptC_v3 #determinando sendido de seleção dos elementos cirDir = rs.AddCircle3Pt(Apoios[0], ptX[0], Apoios[1]) #### --- Cálculo do Shed --- #### print '####-------------------Shed----------------------####' bi3 = v3[2] pto = rs.CurveStartPoint(bi3) if not pto_base_FG1: pto_base_FG1 = pto pto_base_FG1 = rs.coerce3dpoint(pto_base_FG1) vAux1 = Line(pto, pto_base_FG1) for i in range(len(v3)): v3[i] = gh.Move(rs.coercegeometry(v3[i]), vAux1)[0] for i in range(len(C_v3)): C_aux = gh.Move(rs.coerceline(C_v3[i]), vAux1)[0] carreg_1.append(C_aux) FG1 = v3 + carreg_1 carreg_1.pop(0) nomes_cargas = [] for i in range(len(carreg_1)): nome = "P" + str(i + 1) + '_v3' nomes_cargas.append(nome) dic_1, raios_1, funicular_1, resultante_1, ptos = PF_funic( pto_inicial_1, polo_1, carreg_1, nomes_cargas) for i in dic_1.keys(): PF1.append(dic_1[i]) txt_pontos += ptos # - desenhando a resultante no FG
def PF_funic(pto_inicial, polo, carreg, nomes_cargas): raios = [] ptos = [] dicUp = {} PF = [] resultante = [] funicular = [] ## -- Desenhando o poligono de forças -- ## pAux = rs.coerce3dpoint(pto_inicial) # polo do PF do Shed polo = rs.coerce3dpoint(polo) #primeiro raio polar raios.append(Line(polo, pAux)) ptos += [polo, 'polo', cornode] #desenhando carregamentos no PF e os raios polares for i in range(len(carreg)): v = carreg[i] #carregamento no FG vAux1 = rs.coerceline(v) #vetor auxiliar para mover o carregamento para a posição de soma vAux2 = pAux - v.PointAt(0) # carregamento no PF vAux3 = gh.Move(vAux1, vAux2)[0] #Nomenclatura - texto da reação Pi nome = nomes_cargas[i] #Nomenclatua - posição do texto txtPt = vAux3.PointAt(.5) # Nomenclatura do PF ptos += [txtPt, nome, corcargas] # colocando carregamento na lista do PF PF.append(vAux3) # olocando carregamento no dicionario do PF dicUp[nome] = vAux3 # ponto da posição de soma para o proximo carregamento pAux = vAux3.PointAt(1) #desenhando raio polar r = Line(polo, pAux) #colocando raio polar na lista de raios raios.append(r) #desenhando a resultante no PF #ponto final da resultante R1 pto_R1 = pAux #resultante r1 no PF R1PF = Line(rs.coerce3dpoint(pto_inicial), pto_R1) #colocando R1 na lista de resultantes resultante.append(R1PF) #R1 no dicionario do PF dicUp['R1'] = R1PF #Desenhando o funicular for i in range(len(raios)): r = rs.coerceline(raios[i]) #caso da primeira corda if i == 0: pAux = (rs.coerceline(carreg[0]).PointAt(0)) vAux1 = Line(r.PointAt(0), pAux) corda = gh.Move(r, vAux1)[0] corda = rs.coerceline(corda) #cordas intermediarias elif i < len(raios) - 1: vAux1 = Line(r.PointAt(1), pAux) crdAux = gh.Move(r, vAux1)[0] crdAux = rs.coerceline(crdAux) pAux2 = pAux pAux = gh.LineXLine(crdAux, carreg[i])[-1] corda = Line(pAux2, pAux) #caso da ultima corda else: vAux1 = Line(r.PointAt(1), pAux) corda = gh.Move(r, vAux1)[0] corda = rs.coerceline(corda) #adicionando corda na lista do funicular funicular.append(corda) #resesenhando as cordas extremas return dicUp, raios, funicular, resultante, ptos
def Linha_force_extena(no, peso, conv): lincarg = rs.AddLine(no, gh.Move(no, peso * conv * eY)[0]) rs.ReverseCurve(lincarg) return lincarg