symcad.parts.generic
1#!/usr/bin/env python3 2# Copyright (C) 2022, Will Hedgecock 3# 4# This program is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation, either version 3 of the License, or 7# (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17from __future__ import annotations 18from ...core.SymPart import SymPart 19from typing import Callable, Union 20from ...core.ML import NeuralNet 21import abc, os 22 23class GenericShape(SymPart, metaclass=abc.ABCMeta): 24 """Base class from which all generic parametric shapes should derive.""" 25 26 def __init__(self, identifier: str, 27 cad_representation: Union[str, Callable], 28 properties_model: Union[str, NeuralNet, None], 29 material_density_kg_m3: float) -> None: 30 """Initializes a generic parametric `SymPart`. 31 32 Parameters 33 ---------- 34 identifier : `str` 35 Unique, identifying name for the `GenericShape`. 36 cad_representation : `Union[str, Callable]` 37 Either the path to a representative CAD model for the given `GenericShape` or a 38 callable method that can create such a model. 39 properties_model : `Union[str, NeuralNet, None]` 40 Path to or instance of a neural network that may be evaluated to obtain the underlying 41 geometric properties for the given `GenericShape`. 42 material_density_kg_m3 : `float` 43 Uniform material density in `kg/m^3` to be used in mass property calculations. 44 """ 45 super().__init__(identifier, 46 os.path.join('generic', cad_representation) 47 if isinstance(cad_representation, str) else 48 cad_representation, 49 os.path.join('generic', properties_model) 50 if properties_model and isinstance(properties_model, str) else 51 properties_model, 52 material_density_kg_m3) 53 54from .Box import Box 55from .Capsule import Capsule 56from .Cone import Cone 57from .Cuboid import Cuboid 58from .Custom import Custom 59from .Cylinder import Cylinder 60from .EllipsoidalCap import EllipsoidalCap 61from .EllipticCylinder import EllipticCylinder 62from .EllipticPipe import EllipticPipe 63from .Fin import Fin 64from .Parallelepiped import Parallelepiped 65from .Pipe import Pipe 66from .Prism import Prism 67from .Pyramid import Pyramid 68from .Sphere import Sphere 69from .SymmetricAirfoil import SymmetricAirfoil 70from .Torus import Torus
24class GenericShape(SymPart, metaclass=abc.ABCMeta): 25 """Base class from which all generic parametric shapes should derive.""" 26 27 def __init__(self, identifier: str, 28 cad_representation: Union[str, Callable], 29 properties_model: Union[str, NeuralNet, None], 30 material_density_kg_m3: float) -> None: 31 """Initializes a generic parametric `SymPart`. 32 33 Parameters 34 ---------- 35 identifier : `str` 36 Unique, identifying name for the `GenericShape`. 37 cad_representation : `Union[str, Callable]` 38 Either the path to a representative CAD model for the given `GenericShape` or a 39 callable method that can create such a model. 40 properties_model : `Union[str, NeuralNet, None]` 41 Path to or instance of a neural network that may be evaluated to obtain the underlying 42 geometric properties for the given `GenericShape`. 43 material_density_kg_m3 : `float` 44 Uniform material density in `kg/m^3` to be used in mass property calculations. 45 """ 46 super().__init__(identifier, 47 os.path.join('generic', cad_representation) 48 if isinstance(cad_representation, str) else 49 cad_representation, 50 os.path.join('generic', properties_model) 51 if properties_model and isinstance(properties_model, str) else 52 properties_model, 53 material_density_kg_m3)
Base class from which all generic parametric shapes should derive.
GenericShape( identifier: str, cad_representation: Union[str, Callable], properties_model: Union[str, symcad.core.ML.NeuralNet.NeuralNet, NoneType], material_density_kg_m3: float)
27 def __init__(self, identifier: str, 28 cad_representation: Union[str, Callable], 29 properties_model: Union[str, NeuralNet, None], 30 material_density_kg_m3: float) -> None: 31 """Initializes a generic parametric `SymPart`. 32 33 Parameters 34 ---------- 35 identifier : `str` 36 Unique, identifying name for the `GenericShape`. 37 cad_representation : `Union[str, Callable]` 38 Either the path to a representative CAD model for the given `GenericShape` or a 39 callable method that can create such a model. 40 properties_model : `Union[str, NeuralNet, None]` 41 Path to or instance of a neural network that may be evaluated to obtain the underlying 42 geometric properties for the given `GenericShape`. 43 material_density_kg_m3 : `float` 44 Uniform material density in `kg/m^3` to be used in mass property calculations. 45 """ 46 super().__init__(identifier, 47 os.path.join('generic', cad_representation) 48 if isinstance(cad_representation, str) else 49 cad_representation, 50 os.path.join('generic', properties_model) 51 if properties_model and isinstance(properties_model, str) else 52 properties_model, 53 material_density_kg_m3)
Initializes a generic parametric SymPart.
Parameters
- identifier (
str): Unique, identifying name for theGenericShape. - cad_representation (
Union[str, Callable]): Either the path to a representative CAD model for the givenGenericShapeor a callable method that can create such a model. - properties_model (
Union[str, NeuralNet, None]): Path to or instance of a neural network that may be evaluated to obtain the underlying geometric properties for the givenGenericShape. - material_density_kg_m3 (
float): Uniform material density inkg/m^3to be used in mass property calculations.
Inherited Members
- symcad.core.SymPart.SymPart
- name
- geometry
- attachment_points
- attachments
- connection_ports
- connections
- static_origin
- static_placement
- orientation
- material_density
- current_states
- is_exposed
- clone
- set_placement
- set_orientation
- set_state
- set_unexposed
- set_material_density
- add_attachment_point
- add_connection_port
- attach
- connect
- get_cad_physical_properties
- export
- set_geometry
- get_geometric_parameter_bounds
- get_valid_states
- mass
- material_volume
- displaced_volume
- surface_area
- unoriented_center_of_gravity
- oriented_center_of_gravity
- unoriented_center_of_buoyancy
- oriented_center_of_buoyancy
- unoriented_length
- unoriented_width
- unoriented_height
- oriented_length
- oriented_width
- oriented_height