def create_solid(self): """Creates a 3d solid using points with straight edges. Returns: A CadQuery solid: A 3D solid volume """ # Creates a cadquery solid from points and revolves points_without_connections = [p[:2] for p in self.points] solid = (cq.Workplane(self.workplane).polyline( points_without_connections).close().extrude( distance=-self.distance / 2.0, both=True)) if self.with_inner_leg is True: inner_leg_solid = cq.Workplane(self.workplane) inner_leg_solid = inner_leg_solid.polyline( self.inner_leg_connection_points) inner_leg_solid = inner_leg_solid.close().extrude( distance=-self.distance / 2.0, both=True) solid = cq.Compound.makeCompound( [a.val() for a in [inner_leg_solid, solid]]) solid = self.rotate_solid(solid) cutting_wedge = calculate_wedge_cut(self) solid = self.perform_boolean_operations(solid, wedge_cut=cutting_wedge) self.solid = solid # not necessarily required as set in boolean_operations return solid
def create_solid(self): """Creates an extruded 3d solid using points connected with straight and spline edges. Returns: A CadQuery solid: A 3D solid volume """ solid = super().create_solid() if not self.extrude_both: extrusion_distance = -self.distance else: extrusion_distance = -self.distance / 2.0 wire = solid.close() self.wire = wire solid = wire.extrude(distance=extrusion_distance, both=self.extrude_both) solid = self.rotate_solid(solid) cutting_wedge = calculate_wedge_cut(self) solid = self.perform_boolean_operations(solid, wedge_cut=cutting_wedge) self.solid = solid return solid
def create_solid(self): """Creates a extruded 3d solid using points with circular edges. Returns: A CadQuery solid: A 3D solid volume """ # so a positive offset moves extrusion further from axis of azimuthal # placement rotation extrusion_offset = -self.extrusion_start_offset if not self.extrude_both: extrusion_distance = -self.distance else: extrusion_distance = -self.distance / 2.0 wire = (cq.Workplane( self.workplane).workplane(offset=extrusion_offset).moveTo( self.points[0][0], self.points[0][1]).circle(self.radius)) self.wire = wire solid = wire.extrude(distance=extrusion_distance, both=self.extrude_both) solid = self.rotate_solid(solid) cutting_wedge = calculate_wedge_cut(self) solid = self.perform_boolean_operations(solid, wedge_cut=cutting_wedge) self.solid = solid return solid
def create_solid(self): """Creates a 3d solid using points with straight edges. Returns: A CadQuery solid: A 3D solid volume """ # Creates a cadquery solid from points and revolves solid = (cq.Workplane(self.workplane).polyline( self.points).close().extrude(distance=-self.distance / 2.0, both=True)) if self.with_inner_leg is True: inner_leg_solid = cq.Workplane(self.workplane) inner_leg_solid = inner_leg_solid.polyline( self.inner_leg_connection_points) inner_leg_solid = inner_leg_solid.close().extrude( distance=-self.distance / 2.0, both=True) solid = cq.Compound.makeCompound( [a.val() for a in [inner_leg_solid, solid]]) # Checks if the azimuth_placement_angle is a list of angles if isinstance(self.azimuth_placement_angle, Iterable): rotated_solids = [] # Perform seperate rotations for each angle for angle in self.azimuth_placement_angle: rotated_solids.append( solid.rotate((0, 0, -1), (0, 0, 1), angle)) solid = cq.Workplane(self.workplane) # Joins the seperate solids together for i in rotated_solids: solid = solid.union(i) else: # Peform rotations for a single azimuth_placement_angle angle solid = solid.rotate((0, 0, 1), (0, 0, -1), self.azimuth_placement_angle) calculate_wedge_cut(self) self.perform_boolean_operations(solid) return solid
def create_solid(self): """Creates an extruded 3d solid using points connected with spline edges. :return: a 3d solid volume :rtype: a cadquery solid """ # Creates a cadquery solid from points and extrudes solid = ( cq.Workplane(self.workplane) .spline(self.points) .close() .extrude(distance=-1 * self.distance / 2.0, both=True) ) # Checks if the azimuth_placement_angle is a list of angles if isinstance(self.azimuth_placement_angle, Iterable): rotated_solids = [] # Perform seperate rotations for each angle for angle in self.azimuth_placement_angle: rotated_solids.append( solid.rotate( (0, 0, -1), (0, 0, 1), angle)) solid = cq.Workplane(self.workplane) # Joins the seperate solids together for i in rotated_solids: solid = solid.union(i) else: # Peform rotations for a single azimuth_placement_angle angle solid = solid.rotate( (0, 0, -1), (0, 0, 1), self.azimuth_placement_angle) calculate_wedge_cut(self) self.perform_boolean_operations(solid) return solid