当前位置: 首页>>代码示例>>Python>>正文


Python ezdxf.new方法代码示例

本文整理汇总了Python中ezdxf.new方法的典型用法代码示例。如果您正苦于以下问题:Python ezdxf.new方法的具体用法?Python ezdxf.new怎么用?Python ezdxf.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ezdxf的用法示例。


在下文中一共展示了ezdxf.new方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dxf_frame

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def dxf_frame(
    vpoints: Sequence[VPoint],
    v_to_slvs: Callable[[], Iterable[Tuple[int, int]]],
    version: str,
    file_name: str
):
    """Create frame sketch only."""
    dwg = ezdxf.new(version)
    msp = dwg.modelspace()

    for p1, p2 in v_to_slvs():
        vp1 = vpoints[p1]
        vp2 = vpoints[p2]
        msp.add_line((vp1.cx, vp1.cy), (vp2.cx, vp2.cy))

    dwg.saveas(file_name) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:18,代码来源:dxf.py

示例2: main

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def main():
    def make(dxfversion, filename):
        doc = ezdxf.new(dxfversion)
        if 'VIEWPORTS' not in doc.layers:
            vp_layer = doc.layers.new('VIEWPORTS')
        else:
            vp_layer = doc.layers.get('VIEWPORTS')
        # switch viewport layer off to hide the viewport border lines
        vp_layer.off()

        create_2d_modelspace_content(doc.modelspace())
        create_3d_modelspace_content(doc.modelspace())
        # IMPORTANT: DXF R12 supports only one paper space aka layout, every layout name returns the same layout
        layout = doc.layout('Layout1')  # default layout
        layout.page_setup(size=(22, 17), margins=(1, 1, 1, 1), units='inch')
        create_viewports(layout, dxfversion)

        try:
            doc.saveas(filename)
        except IOError:
            print("Can't write: '%s'" % filename)

    make('AC1009', 'viewports_in_paperspace_R12.dxf')
    make('AC1015', 'viewports_in_paperspace_R2000.dxf')
    make('AC1021', 'viewports_in_paperspace_R2007.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:27,代码来源:viewports_in_paperspace.py

示例3: run

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def run():
    doc = ezdxf.new('R2004')  # does not work with AC1015/R2000, but it should
    doc.header['$SORTENTS'] = SortEntities.REGEN
    msp = doc.modelspace()

    add_solids(msp, count=1000, min_size=3, max_size=7)
    doc.saveas('sort_solids_unordered.dxf')
    order_solids_by_color(msp)  # 1 -> 7
    doc.saveas('sort_solids_ordered.dxf')
    reverse_order_solids_by_color(msp)  # 7 -> 1
    doc.saveas('sort_solids_reversed_ordered.dxf')
    move_solids_on_top(msp, 6)  # 7, 5, 4, 3, 2, 1, 6
    doc.saveas('sort_solids_6_on_top.dxf')  # 6 is magenta
    # AutoCAD has no problem with removed entities in the redraw order table (SORTENTSTABLE)
    remove_solids(msp, 6)
    doc.saveas('sort_solids_removed_color_6.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:18,代码来源:redraw_order.py

示例4: main_ellipse

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def main_ellipse(layout):
    entity, vertices, axis_vertices = ellipse(start=math.pi / 2, end=-math.pi / 2)
    axis = Vector.random()
    angle = random_angle()
    entity, vertices, axis_vertices = synced_rotation(entity, vertices, axis_vertices, axis=axis, angle=angle)
    entity, vertices, axis_vertices = synced_translation(
        entity, vertices, axis_vertices,
        dx=random.uniform(-2, 2),
        dy=random.uniform(-2, 2),
        dz=random.uniform(-2, 2)
    )

    for sx, sy, sz in UNIFORM_SCALING + NON_UNIFORM_SCALING:
        entity0, vertices0, axis0 = synced_scaling(entity, vertices, axis_vertices, sx, sy, sz)
        add(layout, entity0, vertices0, layer=f'new ellipse')
        layout.add_line(axis0[0], axis0[2], dxfattribs={'color': 6, 'linetype': 'DASHED', 'layer': 'old axis'})
        layout.add_line(axis0[1], axis0[3], dxfattribs={'color': 6, 'linetype': 'DASHED', 'layer': 'old axis'})
        p = list(entity0.vertices([0, math.pi / 2, math.pi, math.pi * 1.5]))
        layout.add_line(p[0], p[2], dxfattribs={'color': 1, 'layer': 'new axis'})
        layout.add_line(p[1], p[3], dxfattribs={'color': 3, 'layer': 'new axis'}) 
开发者ID:mozman,项目名称:ezdxf,代码行数:22,代码来源:transformation_workbench.py

示例5: main_insert2

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def main_insert2(layout):
    entity, vertices = insert()
    m = Matrix44.chain(
        Matrix44.scale(-1.1, 1.1, 1),
        Matrix44.z_rotate(math.radians(10)),
        Matrix44.translate(1, 1, 1),
    )
    doc.layers.new('exploded axis', dxfattribs={'color': -7})

    for i in range(5):
        entity, vertices = synced_transformation(entity, vertices, m)
        layout.entitydb.add(entity)
        layout.add_entity(entity)

        origin, x, y, z = list(vertices)
        layout.add_line(origin, x, dxfattribs={'color': 2, 'layer': 'new axis'})
        layout.add_line(origin, y, dxfattribs={'color': 4, 'layer': 'new axis'})
        layout.add_line(origin, z, dxfattribs={'color': 6, 'layer': 'new axis'})

        for line in entity.virtual_entities():
            line.dxf.layer = 'exploded axis'
            line.dxf.color = 7
            layout.entitydb.add(line)
            layout.add_entity(line) 
开发者ID:mozman,项目名称:ezdxf,代码行数:26,代码来源:transformation_workbench.py

示例6: radius_default_inside_horizontal

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def radius_default_inside_horizontal(dxfversion='R2000', delta=10, dimtmove=0):
    doc = ezdxf.new(dxfversion, setup=True)
    style = doc.dimstyles.get('EZ_RADIUS_INSIDE')
    style.dxf.dimtmove = dimtmove

    msp = doc.modelspace()
    for x, y in multiple_locations(delta=delta):
        angle = Vector(x, y).angle_deg
        msp.add_circle((x, y), radius=3)

        dim = msp.add_radius_dim(center=(x, y), radius=3, angle=angle, dimstyle='EZ_RADIUS_INSIDE',
                                 override={
                                     'dimtih': 1,  # force text inside horizontal
                                 })
        dim.render(discard=BRICSCAD)
    doc.set_modelspace_vport(height=3 * delta)
    doc.saveas(OUTDIR / f'dim_radius_{dxfversion}_default_inside_horizontal_dimtmove_{dimtmove}.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:19,代码来源:dimension_radius.py

示例7: radius_user_defined_outside

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def radius_user_defined_outside(dxfversion='R2000', delta=15):
    def add_dim(x, y, radius, dimtad):
        center = Vector(x, y)
        msp.add_circle((x, y), radius=3)
        dim_location = center + Vector.from_deg_angle(angle, radius)
        dim = msp.add_radius_dim(center=(x, y), radius=3, location=dim_location, dimstyle='EZ_RADIUS',
                                 override={
                                     'dimtad': dimtad,
                                 })
        dim.render(discard=BRICSCAD)

    doc = ezdxf.new(dxfversion, setup=True)
    msp = doc.modelspace()
    for x, y in multiple_locations(delta=delta):
        angle = Vector(x, y).angle_deg
        add_dim(x, y, 5, dimtad=1)  # above
        add_dim(x + 3 * delta, y, 5, dimtad=0)  # center
        add_dim(x + 6 * delta, y, 5, dimtad=4)  # below

    doc.set_modelspace_vport(height=3 * delta, center=(4.5 * delta, 0))
    doc.saveas(OUTDIR / f'dim_radius_{dxfversion}_user_defined_outside.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:23,代码来源:dimension_radius.py

示例8: radius_user_defined_outside_horizontal

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def radius_user_defined_outside_horizontal(dxfversion='R2000', delta=15):
    def add_dim(x, y, radius, dimtad):
        center = Vector(x, y)
        msp.add_circle((x, y), radius=3)
        dim_location = center + Vector.from_deg_angle(angle, radius)
        dim = msp.add_radius_dim(center=(x, y), radius=3, location=dim_location, dimstyle='EZ_RADIUS',
                                 override={
                                     'dimtad': dimtad,
                                     'dimtoh': 1,  # force text outside horizontal
                                 })
        dim.render(discard=BRICSCAD)

    doc = ezdxf.new(dxfversion, setup=True)
    msp = doc.modelspace()
    for x, y in multiple_locations(delta=delta):
        angle = Vector(x, y).angle_deg
        add_dim(x, y, 5, dimtad=1)  # above
        add_dim(x + 3 * delta, y, 5, dimtad=0)  # center
        add_dim(x + 6 * delta, y, 5, dimtad=4)  # below

    doc.set_modelspace_vport(height=3 * delta, center=(4.5 * delta, 0))
    doc.saveas(OUTDIR / f'dim_radius_{dxfversion}_user_defined_outside_horizontal.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:24,代码来源:dimension_radius.py

示例9: radius_user_defined_inside

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def radius_user_defined_inside(dxfversion='R2000', delta=10, dimtmove=0):
    def add_dim(x, y, radius, dimtad):
        center = Vector(x, y)
        msp.add_circle((x, y), radius=3)
        dim_location = center + Vector.from_deg_angle(angle, radius)
        dim = msp.add_radius_dim(center=(x, y), radius=3, location=dim_location, dimstyle='EZ_RADIUS',
                                 override={
                                     'dimtad': dimtad,
                                 })
        dim.render(discard=BRICSCAD)

    doc = ezdxf.new(dxfversion, setup=True)
    style = doc.dimstyles.get('EZ_RADIUS')
    style.dxf.dimtmove = dimtmove

    msp = doc.modelspace()
    for x, y in multiple_locations(delta=delta):
        angle = Vector(x, y).angle_deg
        add_dim(x, y, 1, dimtad=1)  # above
        add_dim(x + 3 * delta, y, 1, dimtad=0)  # center
        add_dim(x + 6 * delta, y, 1, dimtad=4)  # below

    doc.set_modelspace_vport(height=3 * delta, center=(4.5 * delta, 0))
    doc.saveas(OUTDIR / f'dim_radius_{dxfversion}_user_defined_inside_dimtmove_{dimtmove}.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:26,代码来源:dimension_radius.py

示例10: radius_user_defined_inside_horizontal

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def radius_user_defined_inside_horizontal(dxfversion='R2000', delta=10):
    def add_dim(x, y, radius, dimtad):
        center = Vector(x, y)
        msp.add_circle((x, y), radius=3)
        dim_location = center + Vector.from_deg_angle(angle, radius)
        dim = msp.add_radius_dim(center=(x, y), radius=3, location=dim_location, dimstyle='EZ_RADIUS',
                                 override={
                                     'dimtad': dimtad,
                                     'dimtih': 1,  # force text inside horizontal
                                 })
        dim.render(discard=BRICSCAD)

    doc = ezdxf.new(dxfversion, setup=True)
    msp = doc.modelspace()
    for x, y in multiple_locations(delta=delta):
        angle = Vector(x, y).angle_deg
        add_dim(x, y, 1, dimtad=1)  # above
        add_dim(x + 3 * delta, y, 1, dimtad=0)  # center
        add_dim(x + 6 * delta, y, 1, dimtad=4)  # below

    doc.set_modelspace_vport(height=3 * delta, center=(4.5 * delta, 0))
    doc.saveas(OUTDIR / f'dim_radius_{dxfversion}_user_defined_inside_horizontal.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:24,代码来源:dimension_radius.py

示例11: create_gear

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def create_gear(filename, teeth=20, outside_radius=10, top_width=2, bottom_width=3, height=2):
    doc = ezdxf.new('R2000')
    msp = doc.modelspace()
    vertices = zip(
        forms.gear(
            count=teeth,
            top_width=top_width,
            bottom_width=bottom_width,
            height=height,
            outside_radius=outside_radius,
        ),
        cycle([0, .1, 0, .1])  # bulge values: top, down flank,  bottom, up flank
    )
    msp.add_lwpolyline(
        vertices,
        format='vb',
        dxfattribs={'closed': True}
    )
    doc.saveas(filename) 
开发者ID:mozman,项目名称:ezdxf,代码行数:21,代码来源:render_forms.py

示例12: diameter_default_inside_horizontal

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def diameter_default_inside_horizontal(dxfversion='R2000', delta=10, dimtmove=0):
    doc = ezdxf.new(dxfversion, setup=True)
    style = doc.dimstyles.get('EZ_RADIUS_INSIDE')
    style.dxf.dimtmove = dimtmove

    msp = doc.modelspace()
    for x, y in multiple_locations(delta=delta):
        angle = Vector(x, y).angle_deg
        msp.add_circle((x, y), radius=3)

        dim = msp.add_diameter_dim(center=(x, y), radius=3, angle=angle, dimstyle='EZ_RADIUS_INSIDE',
                                   override={
                                       'dimtih': 1,  # force text inside horizontal
                                   })
        dim.render(discard=BRICSCAD)
    doc.set_modelspace_vport(height=3 * delta)
    doc.saveas(OUTDIR / f'dim_diameter_{dxfversion}_default_inside_horizontal_dimtmove_{dimtmove}.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:19,代码来源:dimension_diameter.py

示例13: diameter_user_defined_outside

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def diameter_user_defined_outside(dxfversion='R2000', delta=15):
    def add_dim(x, y, radius, dimtad):
        center = Vector(x, y)
        msp.add_circle((x, y), radius=3)
        dim_location = center + Vector.from_deg_angle(angle, radius)
        dim = msp.add_diameter_dim(center=(x, y), radius=3, location=dim_location, dimstyle='EZ_RADIUS',
                                   override={
                                       'dimtad': dimtad,
                                   })
        dim.render(discard=BRICSCAD)

    doc = ezdxf.new(dxfversion, setup=True)
    msp = doc.modelspace()
    for x, y in multiple_locations(delta=delta):
        angle = Vector(x, y).angle_deg
        add_dim(x, y, 5, dimtad=1)  # above
        add_dim(x + 3 * delta, y, 5, dimtad=0)  # center
        add_dim(x + 6 * delta, y, 5, dimtad=4)  # below

    doc.set_modelspace_vport(height=3 * delta, center=(4.5 * delta, 0))
    doc.saveas(OUTDIR / f'dim_diameter_{dxfversion}_user_defined_outside.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:23,代码来源:dimension_diameter.py

示例14: diameter_user_defined_outside_horizontal

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def diameter_user_defined_outside_horizontal(dxfversion='R2000', delta=15):
    def add_dim(x, y, radius, dimtad):
        center = Vector(x, y)
        msp.add_circle((x, y), radius=3)
        dim_location = center + Vector.from_deg_angle(angle, radius)
        dim = msp.add_diameter_dim(center=(x, y), radius=3, location=dim_location, dimstyle='EZ_RADIUS',
                                   override={
                                       'dimtad': dimtad,
                                       'dimtoh': 1,  # force text outside horizontal
                                   })
        dim.render(discard=BRICSCAD)

    doc = ezdxf.new(dxfversion, setup=True)
    msp = doc.modelspace()
    for x, y in multiple_locations(delta=delta):
        angle = Vector(x, y).angle_deg
        add_dim(x, y, 5, dimtad=1)  # above
        add_dim(x + 3 * delta, y, 5, dimtad=0)  # center
        add_dim(x + 6 * delta, y, 5, dimtad=4)  # below

    doc.set_modelspace_vport(height=3 * delta, center=(4.5 * delta, 0))
    doc.saveas(OUTDIR / f'dim_diameter_{dxfversion}_user_defined_outside_horizontal.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:24,代码来源:dimension_diameter.py

示例15: diameter_user_defined_inside

# 需要导入模块: import ezdxf [as 别名]
# 或者: from ezdxf import new [as 别名]
def diameter_user_defined_inside(dxfversion='R2000', delta=10, dimtmove=0):
    def add_dim(x, y, radius, dimtad):
        center = Vector(x, y)
        msp.add_circle((x, y), radius=3)
        dim_location = center + Vector.from_deg_angle(angle, radius)
        dim = msp.add_diameter_dim(center=(x, y), radius=3, location=dim_location, dimstyle='EZ_RADIUS',
                                   override={
                                       'dimtad': dimtad,
                                   })
        dim.render(discard=BRICSCAD)

    doc = ezdxf.new(dxfversion, setup=True)
    style = doc.dimstyles.get('EZ_RADIUS')
    style.dxf.dimtmove = dimtmove

    msp = doc.modelspace()
    for x, y in multiple_locations(delta=delta):
        angle = Vector(x, y).angle_deg
        add_dim(x, y, 1, dimtad=1)  # above
        add_dim(x + 3 * delta, y, 1, dimtad=0)  # center
        add_dim(x + 6 * delta, y, 1, dimtad=4)  # below

    doc.set_modelspace_vport(height=3 * delta, center=(4.5 * delta, 0))
    doc.saveas(OUTDIR / f'dim_diameter_{dxfversion}_user_defined_inside_dimtmove_{dimtmove}.dxf') 
开发者ID:mozman,项目名称:ezdxf,代码行数:26,代码来源:dimension_diameter.py


注:本文中的ezdxf.new方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。