Пример #1
0
def plane_normal_from_3_points(point1, point2, point3):
    for point in (point1, point2, point3):
        if None in point:
            return None  # some coords are missing
    import transform
    x1, y1, z1 = point1
    x2, y2, z2 = point2
    x3, y3, z3 = point3
    m0 = transform.matrix([[x1, y1, z1], [x2, y2, z2], [x3, y3, z3]])
    m1 = transform.matrix([[1, y1, z1], [1, y2, z2], [1, y3, z3]])
    m2 = transform.matrix([[x1, 1, z1], [x2, 1, z2], [x3, 1, z3]])
    m3 = transform.matrix([[x1, y1, 1], [x2, y2, 1], [x3, y3, 1]])
    #d0 = 1.0*m0.get_determinant()
    d1 = 1.0 * m1.get_determinant()
    d2 = 1.0 * m2.get_determinant()
    d3 = 1.0 * m3.get_determinant()
    a = d1  #/d0
    b = d2  #/d0
    c = d3  #/d0
    return a, b, c
Пример #2
0
def plane_normal_from_3_points( point1, point2, point3):
  for point in (point1,point2,point3):
    if None in point:
      return None  # some coords are missing
  import transform
  x1,y1,z1 = point1
  x2,y2,z2 = point2
  x3,y3,z3 = point3
  m0 = transform.matrix( [[x1,y1,z1],[x2,y2,z2],[x3,y3,z3]])
  m1 = transform.matrix( [[1,y1,z1],[1,y2,z2],[1,y3,z3]])
  m2 = transform.matrix( [[x1,1,z1],[x2,1,z2],[x3,1,z3]])
  m3 = transform.matrix( [[x1,y1,1],[x2,y2,1],[x3,y3,1]])
  #d0 = 1.0*m0.get_determinant()
  d1 = 1.0*m1.get_determinant()
  d2 = 1.0*m2.get_determinant()
  d3 = 1.0*m3.get_determinant()
  a = d1 #/d0
  b = d2 #/d0
  c = d3 #/d0
  return a,b,c
Пример #3
0
def convert(svg_in, dxf_out, layer_to_style=None, debug_out=None):
    if debug_out is not None:
        debug = lambda *objects: print(*objects, file=debug_out)
    else:
        debug = _noop

    with stdout_ignore():
        svg = pysvg.parser.parse(svg_in)
    dwg = ezdxf.new('AC1015')
    create_layers(dwg, layer_to_style)

    msp = dwg.modelspace()
    transform_ = transform.matrix(1, 0, 0, -1, 0, 0)
    context = ElementContext(transform_=transform_).element(svg)
    _append_subelements(svg, msp, debug, context)

    dwg.write(dxf_out)
Пример #4
0
def convert(svg_in, dxf_out, layer_to_style=None, debug_out=None):
    if debug_out is not None:
        debug = lambda *objects: print(*objects, file=debug_out)
    else:
        debug = _noop

    with stdout_ignore():
        svg = pysvg.parser.parse(svg_in)
    dwg = ezdxf.new('AC1015')
    create_layers(dwg, layer_to_style)

    msp = dwg.modelspace()
    transform_ = transform.matrix(1, 0, 0, -1, 0, 0)
    context = ElementContext(transform_=transform_).element(svg)
    _append_subelements(svg, msp, debug, context)

    dwg.write(dxf_out)