def open_file(settings): if not settings["file.dir"]: filepath = compas_rhino.select_file(folder=HERE, filter="fofin") else: filepath = compas_rhino.select_file(folder=settings["file.dir"], filter="fofin") if not filepath: return file_dir = os.path.dirname(filepath) file_name = os.path.basename(filepath) settings["file.dir"] = file_dir settings["file.name"] = file_name if not file_name.endswith(".fofin"): print("The filename is invalid: {}".format(file_name)) return filepath = os.path.join(file_dir, file_name) with open(filepath, "r") as f: data = json.load(f) if "settings" in data and data["settings"]: settings.update(data["settings"]) if "cablenet" in data and data["cablenet"]: cablenet = Cablenet.from_data(data["cablenet"]) cablenet.draw(layer=settings["layer"], clear_layer=True, settings=settings) else: cablenet = None return cablenet
def cablenet_fd_rpc(data, **kwargs): """Convenience wrapper for ``cablenet_fd_numpy`` that can be used with ``RPC``. Parameters ---------- data : dict The data dictionary representing a cablenet data structure. Returns ------- dict A data dict with the same structure as the input dict. Notes ----- For additional named parameters that can be passed to this function, see ``cablenet_fd_numpy``. Examples -------- .. code-block:: python proxy = Proxy('compas_fofin.equilibrium') result = proxy.cablenet_fd_rpc(cablenet.to_data()) cablenet.data = result """ from compas_fofin.datastructures import Cablenet cablenet = Cablenet.from_data(data) cablenet_fd_numpy(cablenet) return cablenet.to_data()
def update_xyz_proxy(data, *args, **kwargs): from compas_fofin.datastructures import Cablenet net = Cablenet.from_data(data) update_xyz_numpy(net, *args, **kwargs) return net.to_data()
def apply_loads_proxy(data, *args, **kwargs): from compas_fofin.datastructures import Cablenet cablenet = Cablenet.from_data(data) apply_loads_numpy(cablenet, *args, **kwargs) return cablenet.to_data()