- fixed the DXF parser to work with the latest version of ezdxf module (issues for the ellipse entity and modified attribute name for the knots_values to knots)
- fixed the DXF parser to parse correctly the b-splines by not adding automatically a knot value 0f (0, 0) when the spline is not closed
This commit is contained in:
parent
ce5ad816c5
commit
249ece72e9
|
@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta
|
||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
29.06.2020
|
||||||
|
|
||||||
|
- fixed the DXF parser to work with the latest version of ezdxf module (issues for the ellipse entity and modified attribute name for the knots_values to knots)
|
||||||
|
- fixed the DXF parser to parse correctly the b-splines by not adding automatically a knot value 0f (0, 0) when the spline is not closed
|
||||||
|
|
||||||
27.06.2020
|
27.06.2020
|
||||||
|
|
||||||
- Drilling Tool - UI is working as expected; I will have to propagate the changes to other tools too, to increase likeness between different parts of the app
|
- Drilling Tool - UI is working as expected; I will have to propagate the changes to other tools too, to increase likeness between different parts of the app
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
from shapely.geometry import LineString
|
from shapely.geometry import LineString
|
||||||
from shapely.affinity import rotate
|
from shapely.affinity import rotate
|
||||||
|
from ezdxf.math.vector import Vector as ezdxf_vector
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -175,8 +176,7 @@ def dxfellipse2shapely(ellipse, ellipse_segments=100):
|
||||||
ratio = ellipse.dxf.ratio
|
ratio = ellipse.dxf.ratio
|
||||||
|
|
||||||
points_list = []
|
points_list = []
|
||||||
|
major_axis = Vector(list(major_axis))
|
||||||
major_axis = Vector(major_axis)
|
|
||||||
|
|
||||||
major_x = major_axis[0]
|
major_x = major_axis[0]
|
||||||
major_y = major_axis[1]
|
major_y = major_axis[1]
|
||||||
|
@ -248,9 +248,17 @@ def dxfsolid2shapely(solid):
|
||||||
|
|
||||||
|
|
||||||
def dxfspline2shapely(spline):
|
def dxfspline2shapely(spline):
|
||||||
with spline.edit_data() as spline_data:
|
# for old version of ezdxf
|
||||||
ctrl_points = spline_data.control_points
|
# with spline.edit_data() as spline_data:
|
||||||
knot_values = spline_data.knot_values
|
# ctrl_points = spline_data.control_points
|
||||||
|
# try:
|
||||||
|
# # required if using old version of ezdxf
|
||||||
|
# knot_values = spline_data.knot_values
|
||||||
|
# except AttributeError:
|
||||||
|
# knot_values = spline_data.knots
|
||||||
|
|
||||||
|
ctrl_points = spline.control_points
|
||||||
|
knot_values = spline.knots
|
||||||
is_closed = spline.closed
|
is_closed = spline.closed
|
||||||
degree = spline.dxf.degree
|
degree = spline.dxf.degree
|
||||||
|
|
||||||
|
@ -322,6 +330,10 @@ def get_geo_from_insert(dxf_object, insert):
|
||||||
if sx != 1 or sy != 1:
|
if sx != 1 or sy != 1:
|
||||||
geo = scale(geo, sx, sy)
|
geo = scale(geo, sx, sy)
|
||||||
if phi != 0:
|
if phi != 0:
|
||||||
|
if isinstance(tr, str) and tr.lower() == 'c':
|
||||||
|
tr = 'center'
|
||||||
|
elif isinstance(tr, ezdxf_vector):
|
||||||
|
tr = list(tr)
|
||||||
geo = rotate(geo, phi, origin=tr)
|
geo = rotate(geo, phi, origin=tr)
|
||||||
|
|
||||||
geo_block_transformed.append(geo)
|
geo_block_transformed.append(geo)
|
||||||
|
|
|
@ -22,18 +22,16 @@ def normalize_2(v):
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Convert a B-spline to polyline with a fixed number of segments
|
# Convert a B-spline to polyline with a fixed number of segments
|
||||||
#
|
|
||||||
# FIXME to become adaptive
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
def spline2Polyline(xyz, degree, closed, segments, knots):
|
def spline2Polyline(xyz, degree, closed, segments, knots):
|
||||||
"""
|
"""
|
||||||
:param xyz: DXF spline control points
|
:param xyz: DXF spline control points
|
||||||
:param degree: degree of the Spline curve
|
:param degree: degree of the Spline curve
|
||||||
:param closed: closed Spline
|
:param closed: closed Spline
|
||||||
:type closed: bool
|
:type closed: bool
|
||||||
:param segments: how many lines to use for Spline approximation
|
:param segments: how many lines to use for Spline approximation
|
||||||
:param knots: DXF spline knots
|
:param knots: DXF spline knots
|
||||||
:return: x,y,z coordinates (each is a list)
|
:return: x,y,z coordinates (each is a list)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Check if last point coincide with the first one
|
# Check if last point coincide with the first one
|
||||||
|
@ -48,7 +46,8 @@ def spline2Polyline(xyz, degree, closed, segments, knots):
|
||||||
knots = None
|
knots = None
|
||||||
else:
|
else:
|
||||||
# make base-1
|
# make base-1
|
||||||
knots.insert(0, 0)
|
# knots.insert(0, 0)
|
||||||
|
pass
|
||||||
|
|
||||||
npts = len(xyz)
|
npts = len(xyz)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue