def horizontal_nodal_proxy(formdata, forcedata, *args, **kwargs): """RPC proxy for node-per-node calculation of horizontal equilibrium. Parameters ---------- formdata : dict The data dictionary of a :class:`FormDiagram`. forcedata : dict The data dictionary of a :class:`ForceDiagram`. Additional Parameters --------------------- alpha : int, optional Weighting factor for computing target vectors for parallelisation of corresponding edges of Form and ForceDiagram. Default is `100` which means that the target vectors are equal to the FormDiagram edges. kmax : int, optional Maximum number of iterartions. Default is `100`. display : bool, optional Display all messages generated by the solver. Default is `True`. Returns ------- tuple 0. The updated data dict of the FormDiagram. 1. The updated data dict of the ForceDiagram. """ form = FormDiagram.from_data(formdata) force = ForceDiagram.from_data(forcedata) horizontal_nodal(form, force, *args, **kwargs) return form.to_data(), force.to_data()
def from_lines(root): guids = compas_rhino.select_lines() if not guids: return lines = compas_rhino.get_line_coordinates(guids) form = FormDiagram.from_lines(lines) return form
def load_session(session): print("loading session") scene = get_scene() scene.clear() if 'settings' in session: scene.settings = session['settings'] if 'data' in session: data = session['data'] if 'pattern' in data and data['pattern']: pattern = Pattern.from_data(data['pattern']) scene.add(pattern, name="pattern") else: if 'form' in data and data['form']: form = FormDiagram.from_data(data['form']) thrust = form.copy( cls=ThrustDiagram) # this is not a good idea scene.add(form, name="form") scene.add(thrust, name="thrust") if 'force' in data and data['force']: force = ForceDiagram.from_data(data['force']) force.primal = form form.dual = force force.update_angle_deviations() scene.add(force, name="force") scene.update()
def from_surface(root): # add option for uv versus heighfield? # add option for patches? guid = compas_rhino.select_surface() if not guid: return form = FormDiagram.from_rhinosurface(guid) return form
def RunCommand(is_interactive): scene = get_scene() if not scene: return pattern = scene.get("pattern")[0] if not pattern: print("There is no Pattern in the scene.") return if not list(pattern.datastructure.vertices_where({'is_anchor': True})): print( "Pattern has no anchor vertices! Please define anchor (support) vertices." ) return form = FormDiagram.from_pattern(pattern.datastructure) form.vertices_attribute('is_fixed', False) normals = [ form.face_normal(face) for face in form.faces_where({'_is_loaded': True}) ] scale = 1 / len(normals) normal = scale_vector(sum_vectors(normals), scale) if normal[2] < 0: form.flip_cycles() fixed = list(pattern.datastructure.vertices_where({'is_fixed': True})) if fixed: for key in fixed: if form.has_vertex(key): form.vertex_attribute(key, 'is_anchor', True) thrust = form.copy(cls=ThrustDiagram) bbox_form = form.bounding_box_xy() diagonal = length_vector(subtract_vectors(bbox_form[2], bbox_form[0])) zmax = 0.25 * diagonal scene.settings['Solvers']['tna.vertical.zmax'] = round(zmax, 1) scene.clear() scene.add(form, name='form') scene.add(thrust, name='thrust') scene.update() print('FormDiagram object successfully created.')
def RunCommand(is_interactive): RV2 = get_rv2() if not RV2: return scene = get_scene() if not scene: return session = RV2["session"] root = session["cwd"] or HERE filepath = select_filepath_open(root, 'obj') if not filepath: return form = FormDiagram.from_obj(filepath) thrust = form.copy(cls=ThrustDiagram) scene.clear() scene.add(form, name='form') scene.add(thrust, name='thrust', visible=False) scene.update()
def from_json(root): filepath = select_filepath_open(root, 'json') if not filepath: return form = FormDiagram.from_json(filepath) return form
def from_obj(root): filepath = select_filepath_open(root, 'obj') if not filepath: return form = FormDiagram.from_obj(filepath) return form
def from_mesh(root): guid = compas_rhino.select_mesh() if not guid: return form = FormDiagram.from_rhinomesh(guid) return form