import FreeCAD as App import Draft import math doc = App.newDocument() print ("INICIA") # razon dorada fi = (1+math.sqrt(5))/2.0 # los vertices en una lista vertices = [ [0,-fi,1], [0,fi,1], [0,fi,-1] ,[0,-fi,-1], [1,0,fi], [-1,0,fi], [-1,0,-fi] ,[1,0,-fi], [fi,1,0],[-fi,1,0],[-fi,-1,0],[fi,-1,0] ] # aristas # los vertices acomodados por rectangulos dorados puntosRect1 = [ [0,-fi,1], [0,fi,1], [0,fi,-1] ,[0,-fi,-1]] puntosRect2 = [ [1,0,fi], [-1,0,fi], [-1,0,-fi] ,[1,0,-fi]] puntosRect3 = [ [fi,1,0],[-fi,1,0],[-fi,-1,0],[fi,-1,0] ] # poner esferitas en los vertices for n in range(0,4): sphere1 = doc.addObject("Part::Sphere", "vertice") sphere1.Radius = 0.1 sphere1.Placement = App.Placement(App.Vector(puntosRect1[n]), App.Rotation(0,0,0)) sphere1 = doc.addObject("Part::Sphere", "vertice") sphere1.Radius = 0.1 sphere1.Placement = App.Placement(App.Vector(puntosRect2[n]), App.Rotation(0,0,0)) sphere1 = doc.addObject("Part::Sphere", "vertice") sphere1.Radius = 0.1 sphere1.Placement = App.Placement(App.Vector(puntosRect3[n]), App.Rotation(0,0,0)) # los rectangulos dorados r = True if r==True: vecs = [FreeCAD.Vector(t) for t in puntosRect1] # convert tuples to vectors vecs.append(vecs[0]) # to close the wire print (vecs) wire = Part.makePolygon(vecs) face = Part.Face(wire) Part.show(face ) FreeCADGui.getDocument('Unnamed').getObject('Shape').ShapeColor = (1.00,0.00,0.00) vecs = [FreeCAD.Vector(t) for t in puntosRect2] # convert tuples to vectors vecs.append(vecs[0]) # to close the wire wire = Part.makePolygon(vecs) face = Part.Face(wire) Part.show(face ) FreeCADGui.getDocument('Unnamed').getObject('Shape001').ShapeColor = (0.00,1.00,0.00) vecs = [FreeCAD.Vector(t) for t in puntosRect3] # convert tuples to vectors vecs.append(vecs[0]) # to close the wire wire = Part.makePolygon(vecs) face = Part.Face(wire) Part.show(face ) FreeCADGui.getDocument('Unnamed').getObject('Shape002').ShapeColor = (0.00,0.00,1.00) v = 4 # las aristas arista = [[11,3],[7,3],[6,3],[10,3],[0,3]] for n in range(0,5): line1 = Draft.make_line(App.Vector(vertices[arista[n][0]]), App.Vector(vertices[arista[n][1]])) for r in range(1,v): p1 = App.Vector(vertices[arista[n][0]]) p2 = App.Vector(vertices[arista[n][1]]) r = r/v p3 = p2.multiply(r) + p1.multiply(1-r) sphere2 = doc.addObject("Part::Sphere", "partevertice") sphere2.Radius = 0.05 sphere2.Placement = App.Placement((p3), App.Rotation(0,0,0)) arista = [[0,11],[11,7],[7,6],[6,10],[10,0]] for n in range(0,5): line1 = Draft.make_line(App.Vector(vertices[arista[n][0]]), App.Vector(vertices[arista[n][1]])) for r in range(1,v): p1 = App.Vector(vertices[arista[n][0]]) p2 = App.Vector(vertices[arista[n][1]]) r = r/v p3 = p2.multiply(r) + p1.multiply(1-r) sphere2 = doc.addObject("Part::Sphere", "partevertice") sphere2.Radius = 0.05 sphere2.Placement = App.Placement((p3), App.Rotation(0,0,0)) # -- arista = [[2,1],[9,1],[5,1],[4,1],[8,1]] for n in range(0,5): line1 = Draft.make_line(App.Vector(vertices[arista[n][0]]), App.Vector(vertices[arista[n][1]])) arista = [[2,9],[9,5],[5,4],[4,8],[8,2]] for n in range(0,5): line1 = Draft.make_line(App.Vector(vertices[arista[n][0]]), App.Vector(vertices[arista[n][1]])) # -- arista = [[11,8],[7,2],[6,9],[10,5],[0,4] , [11,4],[7,8],[6,2],[10,9],[0,5]] for n in range(0,10): line1 = Draft.make_line(App.Vector(vertices[arista[n][0]]), App.Vector(vertices[arista[n][1]])) # la esfera que pasa por todos los vertices sphere3 = doc.addObject("Part::Sphere", "EsferaGeodesica") sphere3.Radius = math.sqrt(fi*fi + 1) sphere3.Placement = App.Placement(App.Vector(0,0,0), App.Rotation(0,0,0)) FreeCADGui.getDocument('Unnamed').getObject('EsferaGeodesica').Transparency = 80 doc.recompute()