Пример #1
0
def delete(entities):
    """ Delete a list or single entity

    :param entities: the entity or list of entities to be deleted
    :return: None
    """
    _system.cubitCmd('delete {0[0]} {0[1]}'.format(_functions.listIdString(entities)))
Пример #2
0
def open(fileName):
    """ Open a Cubit format file

    :param fileName: File path to open
    :return: None
    """
    _system.cubitCmd('open "{0}"'.format(fileName))
Пример #3
0
def open(fileName):
    """ Open a Cubit format file

    :param fileName: File path to open
    :return: None
    """
    _system.cubitCmd('open "{0}"'.format(fileName))
Пример #4
0
def setElementType(blockId, elementType):
    """ Set block element type

    :param blockId: Id number of block
    :param elementType: Element type from enum ElementType
    :return: None
    """
    _system.cubitCmd('block {0} element type {1}'.format(blockId, elementType))
Пример #5
0
def createNodeset(entities, nodesetId):
    """ Adds entities to or creates node set

    :param entities: list of entities
    :param bodyType: type of entities
    :return: None
    """
    _system.cubitCmd('nodeset {0} {1[0]} {1[1]}'.format(nodesetId, _functions.listIdString(entities)))
Пример #6
0
def nameBlock(blockId, name):
    """ Assign a name to a block

    :param blockId: number of block
    :param name: block name
    :return: None
    """
    _system.cubitCmd('block {0} name "{1}"'.format(blockId, name))
Пример #7
0
def createBlock(entities, blockId):
    """ Assign a entity to a block

    :param entities: the entity or list of entities to be assigned
    :param blockId: the block id
    :return: None
    """
    _system.cubitCmd('block {0} {1[0]} {1[1]}'.format(blockId, _functions.listIdString(entities)))
Пример #8
0
def nameNodeset(nodesetId, name):
    """ Assign a name to a node set

    :param nodesetId: the number of the node set
    :param name: the name to be assigned
    :return: None
    """
    _system.cubitCmd('nodeset {0} name "{1}"'.format(nodesetId, name))
Пример #9
0
def setElementType(blockId, elementType):
    """ Set block element type

    :param blockId: Id number of block
    :param elementType: Element type from enum ElementType
    :return: None
    """
    _system.cubitCmd('block {0} element type {1}'.format(blockId, elementType))
Пример #10
0
def createSideset(entities, sidesetId):
    """ Create a side set

    :param entities: list of entities to assign to side set
    :param sidesetId: the id number of the sideset
    :return: None
    """
    _system.cubitCmd('sideset {0} {1[0]} {1[1]}'.format(sidesetId, _functions.listIdString(entities)))
Пример #11
0
def nameBlock(blockId, name):
    """ Assign a name to a block

    :param blockId: number of block
    :param name: block name
    :return: None
    """
    _system.cubitCmd('block {0} name "{1}"'.format(blockId, name))
Пример #12
0
def setName(entities, name):
    """ Set a name for a single entity or a list of entities

    :param entities: single or list of entities
    :param name: name to be set
    :return: None
    """
    _system.cubitCmd('{0[0]} {0[1]} rename "{1}"'.format(
        _functions.listIdString(entities), name))
Пример #13
0
def createBlock(entities, blockId):
    """ Assign a entity to a block

    :param entities: the entity or list of entities to be assigned
    :param blockId: the block id
    :return: None
    """
    _system.cubitCmd('block {0} add {1[0]} {1[1]}'.format(
        blockId, _functions.listIdString(entities)))
Пример #14
0
def mergeAll(*args, **kwargs):
    """ Unconditional merge command

    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('merge all {0} {1}'.format(_functions.listStr(args),
                                                _functions.listKeywordString(kwargs)))
Пример #15
0
def imprintTolerantAll(*args, **kwargs):
    """ Unconditional tolerant imprint operation

    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('imprint tolerant all {0} {1}'.format(_functions.listStr(args),
                                                           _functions.listKeywordString(kwargs)))
Пример #16
0
def scaleMesh(factor, *args, **kwargs):
    """ Scale created mesh
    :param factor: factor to scale with
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('transform mesh output scale {0} {1} {2}'.format(factor,
                                                                      _functions.listStr(args),
                                                                      _functions.listKeywordString(kwargs)))
Пример #17
0
def enableJournal(enabled=True):
    """ Turn the journal on or off,

    :param enabled: Flag if on or off
    :return:
    """
    if enabled:
        enabled = 'on'
    else:
        enabled = 'off'
    _system.cubitCmd('journal {0}'.format(enabled))
Пример #18
0
def enableDeveloperCommands(enabled=True):
    """ Enable the developer commands granting access to advanced beta functionality

    :param enabled: Flag if on or off
    :return: None
    """
    if enabled:
        enabled = 'on'
    else:
        enabled = 'off'
    _system.cubitCmd('set developer commands {0}'.format(enabled))
Пример #19
0
def export(filename, overwrite=True):
    """ Export to external format

    :param filename: path to export to
    :param overwrite: flag if to everwrite existing file
    :return: None
    """
    if overwrite:
        _system.cubitCmd('export mesh "{0}" overwrite'.format(filename))
    else:
        _system.cubitCmd('export mesh "{0}"'.format(filename))
Пример #20
0
def createArc(centerVertex, startVertex, endVertex):
    """ Creates an arc from 3 already created vertices

    :param centerVertex: Vertex at the center of the arc
    :param startVertex: Vertex at the start of the arc
    :param endVertex: Vertex at the end of the arc
    :return: None
    """
    _system.cubitCmd('Create Curve Arc Center Vertex {0} {1} {2}'.format(
        centerVertex.id(), startVertex.id(), endVertex.id()))
    return lastCurve()
Пример #21
0
def createArc(centerVertex, startVertex, endVertex):
    """ Creates an arc from 3 already created vertices

    :param centerVertex: Vertex at the center of the arc
    :param startVertex: Vertex at the start of the arc
    :param endVertex: Vertex at the end of the arc
    :return: None
    """
    _system.cubitCmd('Create Curve Arc Center Vertex {0} {1} {2}'.format(centerVertex.id(),
                                                                         startVertex.id(), endVertex.id()))
    return lastCurve()
Пример #22
0
def enableDeveloperCommands(enabled=True):
    """ Enable the developer commands granting access to advanced beta functionality

    :param enabled: Flag if on or off
    :return: None
    """
    if enabled:
        enabled = 'on'
    else:
        enabled = 'off'
    _system.cubitCmd('set developer commands {0}'.format(enabled))
Пример #23
0
def export(filename, overwrite=True):
    """ Export to external format

    :param filename: path to export to
    :param overwrite: flag if to everwrite existing file
    :return: None
    """
    if overwrite:
        _system.cubitCmd('export mesh "{0}" overwrite'.format(filename))
    else:
        _system.cubitCmd('export mesh "{0}"'.format(filename))
Пример #24
0
def sectionCut(entities, plane='x', *args, **kwargs):
    """ Section cut a entity or list of entities
    :param entities: the entity or a list of entities
    :param plane: plane to cut at: x, y, z
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('section {0[0]} {0[1]} {1}plane {2} {3}'.format(_functions.listIdString(entities), plane,
                                                                     _functions.listStr(args),
                                                                     _functions.listKeywordString(kwargs)))
Пример #25
0
def enableJournal(enabled=True):
    """ Turn the journal on or off,

    :param enabled: Flag if on or off
    :return:
    """
    if enabled:
        enabled = 'on'
    else:
        enabled = 'off'
    _system.cubitCmd('journal {0}'.format(enabled))
Пример #26
0
def meshQuality(entities, elementType='', *args, **kwargs):
    """ Function to check the quality of the mesh
    :param entities: list of entities or single body, None gives all
    :param elementType: mesh element type
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('quality {0[0]} {0[1]} {1} {2} {3}'.format(_functions.listIdString(entities),
                                                                elementType,
                                                                _functions.listStr(args),
                                                                _functions.listKeywordString(kwargs)))
Пример #27
0
def sweepCurve(surface, curve, *args, **kwargs):
    """ Creates a volume by sweeping a surface along an arbitrary curve
    :param surface: source surface
    :param curve: sweep curve
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: create volume
    """
    _system.cubitCmd('Sweep surface {0} along curve {1} {2} {3}'.format(surface.id(), curve.id(),
                                                                        _functions.listStr(args),
                                                                        _functions.listKeywordString(kwargs)))
    return _transform.getLastBody()
Пример #28
0
def setInterval(entities, interval, *args, **kwargs):
    """ Set the number of intervals for a curve

    :param entities: the base curve
    :param interval: number of intervals
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('{0[0]} {0[1]} interval {1} {2} {3}'.format(_functions.listIdString(entities), interval,
                                                                 _functions.listStr(args),
                                                                 _functions.listKeywordString(kwargs)))
Пример #29
0
def sweepCurve(surface, curve, *args, **kwargs):
    """ Creates a volume by sweeping a surface along an arbitrary curve
    :param surface: source surface
    :param curve: sweep curve
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: create volume
    """
    _system.cubitCmd('Sweep surface {0} along curve {1} {2} {3}'.format(
        surface.id(), curve.id(), _functions.listStr(args),
        _functions.listKeywordString(kwargs)))
    return _transform.getLastBody()
Пример #30
0
def save(fileName, overwrite=True):
    """ Saves the current file to Cubit format

    :param fileName: File name to save to
    :param overwrite: Flag if existing files is to overwrite
    :return: None
    """

    if overwrite:
        _system.cubitCmd('save as "{0}" overwrite'.format(fileName))
    else:
        _system.cubitCmd('save as "{0}"'.format(fileName))
Пример #31
0
def intersect(bodies, *args, **kwargs):
    """ Create the logical AND of bodies

    :param bodies: list of bodies
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: intersected body
    """
    _system.cubitCmd('intersect {0[0]} {0[1]} {1} {2}'.format(_functions.listIdString(bodies),
                                                              _functions.listStr(args),
                                                              _functions.listKeywordString(kwargs)))
    return _transform.getLastBody()
Пример #32
0
def save(fileName, overwrite=True):
    """ Saves the current file to Cubit format

    :param fileName: File name to save to
    :param overwrite: Flag if existing files is to overwrite
    :return: None
    """

    if overwrite:
        _system.cubitCmd('save as "{0}" overwrite'.format(fileName))
    else:
        _system.cubitCmd('save as "{0}"'.format(fileName))
Пример #33
0
def intersect(bodies, *args, **kwargs):
    """ Create the logical AND of bodies

    :param bodies: list of bodies
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: intersected body
    """
    _system.cubitCmd('intersect {0[0]} {0[1]} {1} {2}'.format(
        _functions.listIdString(bodies), _functions.listStr(args),
        _functions.listKeywordString(kwargs)))
    return _transform.getLastBody()
Пример #34
0
def rotate(entities, angle, axis='z', *args, **kwargs):
    """ Rotate a entity
    :param entities: the entity or list of entities
    :param angle: angle in degrees
    :param axis: coordinate system axis x, y, z
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('rotate {0[0]} {0[1]} angle {1} about {2} {3} {4}'.format(
        _functions.listIdString(entities), angle, axis,
        _functions.listStr(args), _functions.listKeywordString(kwargs)))
Пример #35
0
def sweepVector(surface, vector, *args, **kwargs):
    """ Creates a volume by sweeping a surface along an arbitrary curve
    :param surface: source surface
    :param vector: vector in tuple form
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: create volume
    """
    _system.cubitCmd('Sweep surface {0} vector {1[0]} {1[1]} {1[2]} {2} {3}'.format(surface.id(), vector,
                                                                                    _functions.listStr(args),
                                                                                    _functions.listKeywordString(
                                                                                        kwargs)))
    return _transform.getLastBody()
Пример #36
0
def rotate(entities, angle, axis='z', *args, **kwargs):
    """ Rotate a entity
    :param entities: the entity or list of entities
    :param angle: angle in degrees
    :param axis: coordinate system axis x, y, z
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('rotate {0[0]} {0[1]} angle {1} about {2} {3} {4}'.format(_functions.listIdString(entities),
                                                                               angle, axis,
                                                                               _functions.listStr(args),
                                                                               _functions.listKeywordString(kwargs)))
Пример #37
0
def webcut(entities, plane='x', offset=0, *args, **kwargs):
    """
    :param entities: entities or single one to cut
    :param plane: plane: x, y, z
    :param offset: offset from origin
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd(
        'webcut {0[0]} {0[1]} with plane {1}plane offset {2} {3} {4}'.format(
            _functions.listIdString(entities), plane, offset,
            _functions.listStr(args), _functions.listKeywordString(kwargs)))
Пример #38
0
def sweepVector(surface, vector, *args, **kwargs):
    """ Creates a volume by sweeping a surface along an arbitrary curve
    :param surface: source surface
    :param vector: vector in tuple form
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: create volume
    """
    _system.cubitCmd(
        'Sweep surface {0} vector {1[0]} {1[1]} {1[2]} {2} {3}'.format(
            surface.id(), vector, _functions.listStr(args),
            _functions.listKeywordString(kwargs)))
    return _transform.getLastBody()
Пример #39
0
def setAutoSize(entities, factor, *args, **kwargs):
    """ Set auto size on a surface or curve

    :param entities: list or single entity
    :param factor: the auto size factor
    :param propagate: flag for propagation
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('{0[0]} {0[1]} size auto factor {1} {2} {3}'.format(_functions.listIdString(entities), factor,
                                                                         _functions.listStr(args),
                                                                         _functions.listKeywordString(kwargs)))
Пример #40
0
def copyReflect(entities, plane='x', *args, **kwargs):
    """ Reflect and copy a list of entities

    :param entities: list or single base entity
    :param plane: reflection plane x, y, z
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: created entity
    """
    # TODO get list of entities back
    _system.cubitCmd('{0[0]} {0[1]} copy reflect {1} {2} {3}'.format(_functions.listIdString(entities), plane,
                                                                     _functions.listStr(args),
                                                                     _functions.listKeywordString(kwargs)))
    return getLastBody()
Пример #41
0
def sweepDirection(surface, distance, direction='z', *args, **kwargs):
    """
    :param surface: source surface
    :param distance: distance to sweep
    :param direction: direction: x, y, z, negative: nx, ny, nz
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: created volume
    """
    _system.cubitCmd(
        'sweep surface {0} direction {1} distance {2} {3} {4}'.format(
            surface.id(), direction, distance, _functions.listStr(args),
            _functions.listKeywordString(kwargs)))
    return _transform.getLastBody()
Пример #42
0
def mesh(entities, *args, **kwargs):
    """ Meshes a body using Cubits internal meshing function, that behaves differently

    :param entities: list or single entity to mesh
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    idList = _functions.listIdString(entities)
    if idList[0] == _common.BodyTypes.body:
        idList = _functions.listIdString(_functions.getEntitiesFromObject(entities, _common.BodyTypes.volume))
    _system.cubitCmd('mesh {0[0]} {0[1]} {1} {2}'.format(idList,
                                                         _functions.listStr(args),
                                                         _functions.listKeywordString(kwargs)))
Пример #43
0
def sweepDirection(surface, distance, direction='z', *args, **kwargs):
    """
    :param surface: source surface
    :param distance: distance to sweep
    :param direction: direction: x, y, z, negative: nx, ny, nz
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: created volume
    """
    _system.cubitCmd('sweep surface {0} direction {1} distance {2} {3} {4}'.format(surface.id(), direction, distance,
                                                                                   _functions.listStr(args),
                                                                                   _functions.listKeywordString(
                                                                                       kwargs)))
    return _transform.getLastBody()
Пример #44
0
def webcut(entities, plane='x', offset=0, *args, **kwargs):
    """
    :param entities: entities or single one to cut
    :param plane: plane: x, y, z
    :param offset: offset from origin
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd(
        'webcut {0[0]} {0[1]} with plane {1}plane offset {2} {3} {4}'.format(_functions.listIdString(entities),
                                                                             plane, offset,
                                                                             _functions.listStr(args),
                                                                             _functions.listKeywordString(kwargs)))
Пример #45
0
def merge(entities=None, *args, **kwargs):
    """ Merge a list of bodies

    :param entities: list of bodies or None
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    if entities is None:
        mergeAll(*args, **kwargs)
    else:
        _system.cubitCmd('merge {0[0]} {0[1]} {1} {2}'.format(_functions.listIdString(entities),
                                                              _functions.listStr(args),
                                                              _functions.listKeywordString(kwargs)))
Пример #46
0
def imprintCurve(surface, curve, *args, **kwargs):
    """ Imprint a curve onto a surface

    :param surface: Surface to imprint on
    :param curve: Curve to imprint
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    _system.cubitCmd('imprint surface {0} curve {1[1]} {2} {3}'
                     .format(_functions.listIdString(surface, _common.BodyTypes.surface),
                             _functions.listIdString(curve, _common.BodyTypes.curve),
                             _functions.listStr(args),
                             _functions.listKeywordString(kwargs)))
Пример #47
0
def setMeshScheme(entities, meshScheme, *args, **kwargs):
    """ Assign a meshing scheme to a body

    :param entities: list or single entity
    :param meshScheme: the scheme
    :param args: additional parameters for the command: 'option'
    :param kwargs: additional parameter value pairs: option=value
    :return: None
    """
    idList = _functions.listIdString(entities)
    if idList[0] == _common.BodyTypes.body:
        idList = _functions.listIdString(_functions.getEntitiesFromObject(entities, _common.BodyTypes.volume))
    _system.cubitCmd('{0[0]} {0[1]} scheme {1} {2} {3}'.format(idList, meshScheme,
                                                               _functions.listStr(args),
                                                               _functions.listKeywordString(kwargs)))
Пример #48
0
def executeJournalFile(fileName, echo=False):
    """ Read and execute a journal file

    :param fileName: path and name of journal file
    :param echo: print commands before executing them, default False
    :return: None
    """
    import __builtin__

    with __builtin__.open(fileName, 'r') as journal:
        for line in journal:
            # line = line.split('#')[0].strip()
            line = line.strip()
            if line:
                print(line)
                _system.cubitCmd(line)