import os
import sys
import inspect
import numpy
filename = inspect.getfile(lambda: None)
basename = os.path.basename(filename)
parent = os.path.dirname(filename)
grandparent = os.path.dirname(parent)
sys.path.insert(0, grandparent)
from turbo_turtle_abaqus import parsers
from turbo_turtle_abaqus import vertices
from turbo_turtle_abaqus import geometry
from turbo_turtle_abaqus import _abaqus_utilities
from turbo_turtle_abaqus import _mixed_settings
[docs]
def main(
inner_radius,
outer_radius,
height,
output_file,
model_name=parsers.geometry_defaults["model_name"],
part_name=parsers.cylinder_defaults["part_name"],
revolution_angle=parsers.geometry_defaults["revolution_angle"],
y_offset=parsers.cylinder_defaults["y_offset"],
):
"""Accept dimensions of a right circular cylinder and generate an axisymmetric revolved geometry
Centroid of cylinder is located on the global coordinate origin by default.
:param float inner_radius: Radius of the hollow center
:param float outer_radius: Outer radius of the cylinder
:param float height: Height of the cylinder
:param str output_file: Abaqus CAE database to save the part(s)
:param str model_name: name of the Abaqus model in which to create the part
:param list part_name: name(s) of the part(s) being created
:param float revolution_angle: angle of solid revolution for ``3D`` geometries
:param float y_offset: vertical offset along the global Y-axis
"""
import abaqus
import abaqusConstants
output_file = os.path.splitext(output_file)[0] + ".cae"
try:
cylinder(inner_radius, outer_radius, height, y_offset, model_name, part_name, revolution_angle)
except RuntimeError as err:
_mixed_utilities.sys_exit(err.message)
abaqus.mdb.saveAs(pathName=output_file)
[docs]
def cylinder(inner_radius, outer_radius, height, y_offset, model_name, part_name, revolution_angle):
"""Accept dimensions of a right circular cylinder and generate an axisymmetric revolved geometry
This function drives the geometry creation of a cylinder whose axis of symmetry is located on the global coordinate
origin by default, and always on the global Y-axis.
:param float inner_radius: Radius of the hollow center
:param float outer_radius: Outer radius of the cylinder
:param float height: Height of the cylinder
:param float y_offset: vertical offset along the global Y-axis
:param str model_name: name of the Abaqus model in which to create the part
:param list part_name: name(s) of the part(s) being created
:param float revolution_angle: angle of solid revolution for ``3D`` geometries
"""
_abaqus_utilities._conditionally_create_model(model_name)
lines = vertices.cylinder_lines(inner_radius, outer_radius, height, y_offset)
geometry.draw_part_from_splines(
lines, [], planar=False, model_name=model_name, part_name=part_name, revolution_angle=revolution_angle
)
[docs]
def _gui():
"""Function with no inputs required for driving the plugin"""
_abaqus_utilities.gui_wrapper(
inputs_function=_gui_get_inputs, subcommand_function=cylinder, post_action_function=_abaqus_utilities._view_part
)
if __name__ == "__main__":
if "caeModules" in sys.modules: # All Abaqus CAE sessions immediately load caeModules
_gui()
else:
parser = parsers.cylinder_parser(basename=basename)
try:
args, unknown = parser.parse_known_args()
except SystemExit as err:
sys.exit(err.code)
sys.exit(
main(
inner_radius=args.inner_radius,
outer_radius=args.outer_radius,
height=args.height,
output_file=args.output_file,
model_name=args.model_name,
part_name=args.part_name,
revolution_angle=args.revolution_angle,
y_offset=args.y_offset,
)
)