def from_data(cls, data): """Construct a PrintPoint from its data representation. Parameters ---------- data: dict The data dictionary. Returns ------- layer The constructed PrintPoint. """ pp = cls(pt=Point.from_data(data['point']), layer_height=data['layer_height'], mesh_normal=Vector.from_data(data['mesh_normal'])) pp.up_vector = Vector.from_data(data['up_vector']) pp.frame = Frame.from_data(data['frame']) pp.extruder_toggle = data['extruder_toggle'] pp.velocity = data['velocity'] pp.wait_time = data['wait_time'] pp.blend_radius = data['blend_radius'] pp.closest_support_pt = Point.from_data(data['closest_support_pt']) pp.distance_to_support = data['distance_to_support'] pp.is_feasible = data['is_feasible'] pp.attributes = data['attributes'] return pp
from assembly import Element, Assembly # load settings (shared by GH) settings_file = os.path.join(DATA, "settings.json") with open(settings_file, 'r') as f: data = json.load(f) # create tool from json filepath = os.path.join(DATA, "vacuum_gripper.json") tool = Tool.from_json(filepath) # define brick dimensions width, length, height = data['brick_dimensions'] # little tolerance to not 'crash' into collision objects tolerance_vector = Vector.from_data(data['tolerance_vector']) savelevel_vector = Vector.from_data(data['savelevel_vector']) # define target frame target_frame = Frame([-0.26, -0.28, height], [1, 0, 0], [0, 1, 0]) target_frame.point += tolerance_vector # create Element and move it to target frame element = Element.from_data(data['brick']) # create Assembly with element at target_frame assembly = Assembly() T = Transformation.from_frame_to_frame(element.frame, target_frame) assembly.add_element(element.transformed(T))