meshlabxml/create.py
def annulus(script, radius=None, radius1=None, radius2=None, diameter=None,
            diameter1=None, diameter2=None, cir_segments=32, color=None):
    """Create a 2D (surface) circle or annulus
    radius1=1 # Outer radius of the circle
    radius2=0 # Inner radius of the circle (if non-zero it creates an annulus)
    color="" # specify a color name to apply vertex colors to the newly created mesh

    OpenSCAD: parameters: diameter overrides radius, radius1 & radius2 override radius
    """
    if radius is not None and diameter is None:
        if radius1 is None and diameter1 is None:
            radius1 = radius
        if radius2 is None and diameter2 is None:
            radius2 = 0
    if diameter is not None:
        if radius1 is None and diameter1 is None:
            radius1 = diameter / 2
        if radius2 is None and diameter2 is None:
            radius2 = 0
    if diameter1 is not None:
        radius1 = diameter1 / 2
    if diameter2 is not None:
        radius2 = diameter2 / 2
    if radius1 is None:
        radius1 = 1
    if radius2 is None:
        radius2 = 0

    # Circle is created centered on the XY plane
    filter_xml = ''.join([
        '  <filter name="Annulus">\n',
        '    <Param name="externalRadius" ',
        'value="%s" ' % radius1,
        'description="External Radius" ',
        'type="RichFloat" ',
        '/>\n',
        '    <Param name="internalRadius" ',
        'value="%s" ' % radius2,
        'description="Internal Radius" ',
        'type="RichFloat" ',
        '/>\n',
        '    <Param name="sides" ',
        'value="%d" ' % cir_segments,
        'description="Sides" ',
        'type="RichInt" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    if isinstance(script, FilterScript):
        script.add_layer('Annulus', change_layer=True)
    if color is not None:
        vert_color.function(script, color=color)
    return None
def annulus(script, radius=None, radius1=None, radius2=None, diameter=None,
            diameter1=None, diameter2=None, cir_segments=32, color=None):
    """Create a 2D (surface) circle or annulus
    radius1=1 # Outer radius of the circle
    radius2=0 # Inner radius of the circle (if non-zero it creates an annulus)
    color="" # specify a color name to apply vertex colors to the newly created mesh

    OpenSCAD: parameters: diameter overrides radius, radius1 & radius2 override radius
    """
    if radius is not None and diameter is None:
        if radius1 is None and diameter1 is None:
            radius1 = radius
        if radius2 is None and diameter2 is None:
            radius2 = 0
    if diameter is not None:
        if radius1 is None and diameter1 is None:
            radius1 = diameter / 2
        if radius2 is None and diameter2 is None:
            radius2 = 0
    if diameter1 is not None:
        radius1 = diameter1 / 2
    if diameter2 is not None:
        radius2 = diameter2 / 2
    if radius1 is None:
        radius1 = 1
    if radius2 is None:
        radius2 = 0

    # Circle is created centered on the XY plane
    filter_xml = ''.join([
        '  <filter name="Annulus">\n',
        '    <Param name="externalRadius" ',
        'value="%s" ' % radius1,
        'description="External Radius" ',
        'type="RichFloat" ',
        '/>\n',
        '    <Param name="internalRadius" ',
        'value="%s" ' % radius2,
        'description="Internal Radius" ',
        'type="RichFloat" ',
        '/>\n',
        '    <Param name="sides" ',
        'value="%d" ' % cir_segments,
        'description="Sides" ',
        'type="RichInt" ',
        '/>\n',
        '  </filter>\n'])
    util.write_filter(script, filter_xml)
    if isinstance(script, FilterScript):
        script.add_layer('Annulus', change_layer=True)
    if color is not None:
        vert_color.function(script, color=color)
    return None
Create a 2D (surface) circle or annulus
    radius1=1 # Outer radius of the circle
    radius2=0 # Inner radius of the circle (if non-zero it creates an annulus)
    color="" # specify a color name to apply vertex colors to the newly created mesh

    OpenSCAD: parameters: diameter overrides radius, radius1 & radius2 override radius