本文整理汇总了Python中pycam.Utils.log.warn函数的典型用法代码示例。如果您正苦于以下问题:Python warn函数的具体用法?Python warn怎么用?Python warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: parse_lwpolyline
def parse_lwpolyline(self):
start_line = self.line_number
points = []
def add_point(p_array):
# fill all "None" values with zero
for index in range(len(p_array)):
if p_array[index] is None:
if (index == 0) or (index == 1):
log.debug("DXFImporter: weird LWPOLYLINE input " + \
"date in line %d: %s" % \
(self.line_number, p_array))
p_array[index] = 0
points.append(Point(p_array[0], p_array[1], p_array[2]))
current_point = [None, None, None]
key, value = self._read_key_value()
while (not key is None) and (key != self.KEYS["MARKER"]):
if key == self.KEYS["P1_X"]:
axis = 0
elif key == self.KEYS["P1_Y"]:
axis = 1
elif not self._color_as_height and (key == self.KEYS["P1_Z"]):
axis = 2
elif self._color_as_height and (key == self.KEYS["COLOR"]):
# interpret the color as the height
axis = 2
value = float(value) / 255
else:
axis = None
if not axis is None:
if current_point[axis] is None:
# The current point definition is not complete, yet.
current_point[axis] = value
else:
# The current point seems to be complete.
add_point(current_point)
current_point = [None, None, None]
current_point[axis] = value
key, value = self._read_key_value()
end_line = self.line_number
# The last lines were not used - they are just the marker for the next
# item.
if not key is None:
self._push_on_stack(key, value)
# check if there is a remaining item in "current_point"
if len(current_point) != current_point.count(None):
add_point(current_point)
if len(points) < 2:
# too few points for a polyline
log.warn("DXFImporter: Empty LWPOLYLINE definition between line " \
+ "%d and %d" % (start_line, end_line))
else:
for index in range(len(points) - 1):
point = points[index]
next_point = points[index + 1]
if point != next_point:
self.lines.append(Line(point, next_point))
else:
log.warn("DXFImporter: Ignoring zero-length LINE " \
+ "(between input line %d and %d): %s" \
% (start_line, end_line, point))
开发者ID:chriskyfung,项目名称:MakerDroid,代码行数:60,代码来源:DXFImporter.py
示例2: parse_arc
def parse_arc(self, circle=False):
start_line = self.line_number
# the z-level defaults to zero (for 2D models)
center = [None, None, 0]
color = None
radius = None
if circle:
angle_start = 0
angle_end = 360
else:
angle_start = None
angle_end = None
key, value = self._read_key_value()
while (not key is None) and (key != self.KEYS["MARKER"]):
if key == self.KEYS["P1_X"]:
center[0] = value
elif key == self.KEYS["P1_Y"]:
center[1] = value
elif key == self.KEYS["P1_Z"]:
center[2] = value
elif key == self.KEYS["RADIUS"]:
radius = value
elif key == self.KEYS["ANGLE_START"]:
angle_start = value
elif key == self.KEYS["ANGLE_END"]:
angle_end = value
elif key == self.KEYS["COLOR"]:
color = value
else:
pass
key, value = self._read_key_value()
end_line = self.line_number
# The last lines were not used - they are just the marker for the next
# item.
if not key is None:
self._push_on_stack(key, value)
if (None in center) or (None in (radius, angle_start, angle_end)):
log.warn("DXFImporter: Incomplete ARC definition between line " \
+ "%d and %d" % (start_line, end_line))
else:
if self._color_as_height and (not color is None):
# use the color code as the z coordinate
center[2] = float(color) / 255
center = tuple(center)
xy_point_coords = pycam.Geometry.get_points_of_arc(center, radius, angle_start, angle_end)
# Somehow the order of points seems to be the opposite of what is
# expected.
xy_point_coords.reverse()
if len(xy_point_coords) > 1:
for index in range(len(xy_point_coords) - 1):
p1 = xy_point_coords[index]
p1 = (p1[0], p1[1], center[2])
p2 = xy_point_coords[index + 1]
p2 = (p2[0], p2[1], center[2])
if p1 != p2:
self.lines.append(Line(p1, p2))
else:
log.warn("DXFImporter: Ignoring tiny ARC (between input " + \
"line %d and %d): %s / %s (%s - %s)" % (start_line,
end_line, center, radius, angle_start, angle_end))
开发者ID:stevegt,项目名称:pycam,代码行数:60,代码来源:DXFImporter.py
示例3: parse_toolpath_settings
def parse_toolpath_settings(filename):
""" parse potential PyCAM settings from a given file
This is mainly useful to retrieve task settings from a GCode file.
@value filename: the name of the file to be read
@type filename: str
@returns: a dictionary (of all setting names and values) and the content
of the 'comment' section (as a single string)
@rtype: tuple(dict, str)
"""
keywords = {}
in_meta_zone = False
meta_content = []
if filename == "-":
# read from stdin, if the input filename is "-"
infile = sys.stdin
close_file = False
else:
# open the file
try:
infile = pycam.Utils.URIHandler(filename).open()
except IOError, err_msg:
log.warn("ToolpathSettingsParser: Failed to read file (%s): %s" % \
(filename, err_msg))
return None
close_file = True
开发者ID:chriskyfung,项目名称:MakerDroid,代码行数:26,代码来源:ToolpathSettingsParser.py
示例4: close_sequence
def close_sequence(self):
start_line = self.line_number
if self._open_sequence == "POLYLINE":
self.parse_polyline(False)
else:
log.warn("DXFImporter: unexpected SEQEND found at line %d" % \
start_line)
开发者ID:I--Fox--I,项目名称:pycam,代码行数:7,代码来源:DXFImporter.py
示例5: parse_vertex
def parse_vertex(self):
start_line = self.line_number
point = [None, None, 0]
color = None
bulge = None
key, value = self._read_key_value()
while (not key is None) and (key != self.KEYS["MARKER"]):
if key == self.KEYS["P1_X"]:
point[0] = value
elif key == self.KEYS["P1_Y"]:
point[1] = value
elif key == self.KEYS["P1_Z"]:
point[2] = value
elif key == self.KEYS["COLOR"]:
color = value
elif key == self.KEYS["VERTEX_BULGE"]:
bulge = value
else:
pass
key, value = self._read_key_value()
end_line = self.line_number
if not key is None:
self._push_on_stack(key, value)
if self._color_as_height and (not color is None):
# use the color code as the z coordinate
point[2] = float(color) / 255
if None in point:
log.warn("DXFImporter: Missing attribute of VERTEX item" + \
"between line %d and %d" % (start_line, end_line))
else:
self._open_sequence_items.append(
(Point(point[0], point[1], point[2]), bulge))
开发者ID:I--Fox--I,项目名称:pycam,代码行数:32,代码来源:DXFImporter.py
示例6: parse
def parse(self, text):
text_stream = StringIO.StringIO(text)
config = ConfigParser.SafeConfigParser()
config.readfp(text_stream)
for config_dict, section in ((self.bounds, "Bounds"),
(self.tool_settings, "Tool"),
(self.process_settings, "Process")):
for key, value_type in self.SECTIONS[section].items():
value_raw = config.get(section, key, None)
if value_raw is None:
continue
elif value_type == bool:
value = value_raw.lower() in ("1", "true", "yes", "on")
elif isinstance(value_type, basestring) \
and (value_type.startswith("list_of_")):
item_type = value_type[len("list_of_"):]
if item_type == "float":
item_type = float
else:
continue
try:
value = [item_type(one_val)
for one_val in value_raw.split(",")]
except ValueError:
log.warn("Settings: Ignored invalid setting due to " \
+ "a failed list type parsing: " \
+ "(%s -> %s): %s" % (section, key, value_raw))
else:
try:
value = value_type(value_raw)
except ValueError:
log.warn("Settings: Ignored invalid setting " \
+ "(%s -> %s): %s" % (section, key, value_raw))
config_dict[key] = value
开发者ID:I--Fox--I,项目名称:pycam,代码行数:34,代码来源:Settings.py
示例7: load_preferences
def load_preferences(self):
""" load all settings that are available in the Preferences window from
a file in the user's home directory """
config_filename = pycam.Gui.Settings.get_config_filename()
if config_filename is None:
# failed to create the personal preferences directory
return
config = ConfigParser.ConfigParser()
if not config.read(config_filename):
# no config file was read
return
# report any ignored (obsolete) preference keys present in the file
for item, value in config.items("DEFAULT"):
if not item in PREFERENCES_DEFAULTS.keys():
log.warn("Skipping obsolete preference item: %s" % str(item))
for item in PREFERENCES_DEFAULTS.keys():
if not config.has_option("DEFAULT", item):
# a new preference setting is missing in the (old) file
continue
value_raw = config.get("DEFAULT", item)
old_value = self.settings.get(item)
value_type = type(PREFERENCES_DEFAULTS[item])
if isinstance(value_type(), basestring):
# keep strings as they are
value = str(value_raw)
else:
# parse tuples, integers, bools, ...
value = eval(value_raw)
self.settings.set(item, value)
开发者ID:I--Fox--I,项目名称:pycam,代码行数:29,代码来源:Project.py
示例8: combine_triangles
def combine_triangles(t1, t2):
unique_vertices = []
shared_vertices = []
for point in t1.get_points():
for point2 in t2.get_points():
if point == point2:
shared_vertices.append(point)
break
else:
unique_vertices.append(point)
if len(shared_vertices) != 2:
return None
for point in t2.get_points():
for point2 in shared_vertices:
if point == point2:
break
else:
unique_vertices.append(point)
if len(unique_vertices) != 2:
log.error("Invalid number of vertices: %s" % unique_vertices)
return None
if abs(unique_vertices[0].sub(unique_vertices[1]).norm - \
shared_vertices[0].sub(shared_vertices[1]).norm) < epsilon:
try:
return Rectangle(unique_vertices[0], unique_vertices[1],
shared_vertices[0], shared_vertices[1],
normal=t1.normal)
except ValueError:
log.warn("Triangles not combined: %s, %s" % (unique_vertices,
shared_vertices))
return None
else:
return None
开发者ID:chriskyfung,项目名称:MakerDroid,代码行数:33,代码来源:Model.py
示例9: recommends_details_gtk
def recommends_details_gtk():
result = {}
try:
import gtk.gtkgl
result["gtkgl"] = True
result["gl"] = True
except ImportError, err_msg:
log.warn("Failed to import OpenGL for GTK (ImportError): %s" % \
str(err_msg))
result["gtkgl"] = False
开发者ID:I--Fox--I,项目名称:pycam,代码行数:10,代码来源:common.py
示例10: get_lines_layer
def get_lines_layer(lines, z, last_z=None, step_width=None,
milling_style=MILLING_STYLE_CONVENTIONAL):
get_proj_point = lambda proj_point: (proj_point[0], proj_point[1], z)
projected_lines = []
for line in lines:
if (not last_z is None) and (last_z < line.minz):
# the line was processed before
continue
elif line.minz < z < line.maxz:
# Split the line at the point at z level and do the calculation
# for both point pairs.
factor = (z - line.p1[2]) / (line.p2[2] - line.p1[2])
plane_point = padd(line.p1, pmul(line.vector, factor))
if line.p1[2] < z:
p1 = get_proj_point(line.p1)
p2 = line.p2
else:
p1 = line.p1
p2 = get_proj_point(line.p2)
projected_lines.append(Line(p1, plane_point))
yield Line(plane_point, p2)
elif line.minz < last_z < line.maxz:
plane = Plane((0, 0, last_z), (0, 0, 1, 'v'))
cp = plane.intersect_point(line.dir, line.p1)[0]
# we can be sure that there is an intersection
if line.p1[2] > last_z:
p1, p2 = cp, line.p2
else:
p1, p2 = line.p1, cp
projected_lines.append(Line(p1, p2))
else:
if line.maxz <= z:
# the line is completely below z
projected_lines.append(Line(get_proj_point(line.p1),
get_proj_point(line.p2)))
elif line.minz >= z:
projected_lines.append(line)
else:
log.warn("Unexpected condition 'get_lines_layer': " + \
"%s / %s / %s / %s" % (line.p1, line.p2, z, last_z))
# process all projected lines
for line in projected_lines:
points = []
if step_width is None:
points.append(line.p1)
points.append(line.p2)
else:
if isiterable(step_width):
steps = step_width
else:
steps = floatrange(0.0, line.len, inc=step_width)
for step in steps:
next_point = padd(line.p1, pmul(line.dir, step))
points.append(next_point)
yield points
开发者ID:zultron,项目名称:pycam,代码行数:55,代码来源:MotionGrid.py
示例11: get_default_model
def get_default_model():
""" return a filename or a Model instance """
# try to load the default model file ("pycam" logo)
for inputdir in EXAMPLE_MODEL_LOCATIONS:
inputfile = os.path.join(inputdir, DEFAULT_MODEL_FILE)
if os.path.isfile(inputfile):
return inputfile
else:
# fall back to the simple test model
log.warn("Failed to find the default model (%s) in the " \
"following locations: %s" % (DEFAULT_MODEL_FILE,
", ".join(EXAMPLE_MODEL_LOCATIONS)))
return pycam.Importers.TestModel.get_test_model()
开发者ID:chriskyfung,项目名称:MakerDroid,代码行数:13,代码来源:pycampy.py
示例12: GenerateToolPathLinePush
def GenerateToolPathLinePush(self, pa, line, z, previous_z,
draw_callback=None):
if previous_z <= line.minz:
# the line is completely above the previous level
pass
elif line.minz < z < line.maxz:
# Split the line at the point at z level and do the calculation
# for both point pairs.
factor = (z - line.p1.z) / (line.p2.z - line.p1.z)
plane_point = line.p1.add(line.vector.mul(factor))
self.GenerateToolPathLinePush(pa, Line(line.p1, plane_point), z,
previous_z, draw_callback=draw_callback)
self.GenerateToolPathLinePush(pa, Line(plane_point, line.p2), z,
previous_z, draw_callback=draw_callback)
elif line.minz < previous_z < line.maxz:
plane = Plane(Point(0, 0, previous_z), Vector(0, 0, 1))
cp = plane.intersect_point(line.dir, line.p1)[0]
# we can be sure that there is an intersection
if line.p1.z > previous_z:
p1, p2 = cp, line.p2
else:
p1, p2 = line.p1, cp
self.GenerateToolPathLinePush(pa, Line(p1, p2), z, previous_z,
draw_callback=draw_callback)
else:
if line.maxz <= z:
# the line is completely below z
p1 = Point(line.p1.x, line.p1.y, z)
p2 = Point(line.p2.x, line.p2.y, z)
elif line.minz >= z:
p1 = line.p1
p2 = line.p2
else:
log.warn("Unexpected condition EC_GTPLP: %s / %s / %s / %s" % \
(line.p1, line.p2, z, previous_z))
return
# no model -> no possible obstacles
# model is completely below z (e.g. support bridges) -> no obstacles
relevant_models = [m for m in self.models if m.maxz >= z]
if not relevant_models:
points = [p1, p2]
elif self.physics:
points = get_free_paths_ode(self.physics, p1, p2)
else:
points = get_free_paths_triangles(relevant_models, self.cutter,
p1, p2)
if points:
for point in points:
pa.append(point)
if draw_callback:
draw_callback(tool_position=points[-1], toolpath=pa.paths)
开发者ID:TanayGahlot,项目名称:creatorbot-backend,代码行数:51,代码来源:EngraveCutter.py
示例13: __init__
def __init__(self, title, message):
try:
import Tkinter
except ImportError:
# tk is not installed
log.warn("Failed to show error dialog due to a missing Tkinter " \
+ "Python package.")
return
try:
root = Tkinter.Tk()
except Tkinter.TclError, err_msg:
log.info(("Failed to create error dialog window (%s). Probably " \
+ "you are running PyCAM from a terminal.") % err_msg)
return
开发者ID:I--Fox--I,项目名称:pycam,代码行数:14,代码来源:common.py
示例14: load_model_file
def load_model_file(filename, program_locations, unit=None):
uri = pycam.Utils.URIHandler(filename)
if uri.is_local():
uri = pycam.Utils.URIHandler(os.path.expanduser(str(filename)))
if not uri.exists():
log.warn("The input file ('%s') was not found!" % uri)
return None
importer = pycam.Importers.detect_file_type(uri)[1]
model = importer(uri, program_locations=program_locations, unit=unit)
if not model:
log.warn("Failed to load the model file (%s)." % uri)
return None
else:
return model
开发者ID:chriskyfung,项目名称:MakerDroid,代码行数:14,代码来源:pycampy.py
示例15: _read_key_value
def _read_key_value(self):
if self._input_stack:
return self._input_stack.pop()
try:
line1 = self.inputstream.readline(self.MAX_CHARS_PER_LINE).strip()
line2 = self.inputstream.readline(self.MAX_CHARS_PER_LINE).strip()
except IOError:
return None, None
if not line1 and not line2:
return None, None
try:
line1 = int(line1)
except ValueError:
log.warn("DXFImporter: Invalid key in line " \
+ "%d (int expected): %s" % (self.line_number, line1))
return None, None
if line1 in [self.KEYS[key] for key in ("P1_X", "P1_Y", "P1_Z",
"P2_X", "P2_Y", "P2_Z", "RADIUS", "ANGLE_START", "ANGLE_END",
"TEXT_HEIGHT", "TEXT_WIDTH_FINAL", "TEXT_ROTATION",
"TEXT_SKEW_ANGLE", "VERTEX_BULGE")]:
try:
line2 = float(line2)
except ValueError:
log.warn("DXFImporter: Invalid input in line " \
+ "%d (float expected): %s" % (self.line_number, line2))
line1 = None
line2 = None
elif line1 in [self.KEYS[key] for key in ("COLOR", "TEXT_MIRROR_FLAGS",
"TEXT_ALIGN_HORIZONTAL", "TEXT_ALIGN_VERTICAL",
"MTEXT_ALIGNMENT", "CURVE_TYPE", "VERTEX_FLAGS")]:
try:
line2 = int(line2)
except ValueError:
log.warn("DXFImporter: Invalid input in line " \
+ "%d (int expected): %s" % (self.line_number, line2))
line1 = None
line2 = None
elif line1 in [self.KEYS[key] for key in ("DEFAULT", "TEXT_MORE")]:
# check the string for invalid characters
try:
text = unicode(line2)
except UnicodeDecodeError:
log.warn("DXFImporter: Invalid character in string in " + \
"line %d" % self.line_number)
text_chars = []
for char in line2:
try:
text_chars.append(unicode(char))
except:
pass
text = u"".join(text_chars)
line2 = _unescape_control_characters(text)
else:
line2 = line2.upper()
self.line_number += 2
return line1, line2
开发者ID:I--Fox--I,项目名称:pycam,代码行数:56,代码来源:DXFImporter.py
示例16: parse_line
def parse_line(self):
start_line = self.line_number
# the z-level defaults to zero (for 2D models)
p1 = [None, None, 0]
p2 = [None, None, 0]
color = None
key, value = self._read_key_value()
while (not key is None) and (key != self.KEYS["MARKER"]):
if key == self.KEYS["P1_X"]:
p1[0] = value
elif key == self.KEYS["P1_Y"]:
p1[1] = value
elif key == self.KEYS["P1_Z"]:
p1[2] = value
elif key == self.KEYS["P2_X"]:
p2[0] = value
elif key == self.KEYS["P2_Y"]:
p2[1] = value
elif key == self.KEYS["P2_Z"]:
p2[2] = value
elif key == self.KEYS["COLOR"]:
color = value
else:
pass
key, value = self._read_key_value()
end_line = self.line_number
# The last lines were not used - they are just the marker for the next
# item.
if not key is None:
self._push_on_stack(key, value)
if (None in p1) or (None in p2):
log.warn("DXFImporter: Incomplete LINE definition between line " \
+ "%d and %d" % (start_line, end_line))
else:
if self._color_as_height and (not color is None):
# use the color code as the z coordinate
p1[2] = float(color) / 255
p2[2] = float(color) / 255
line = Line(Point(p1[0], p1[1], p1[2]), Point(p2[0], p2[1], p2[2]))
if line.p1 != line.p2:
self.lines.append(line)
else:
log.warn("DXFImporter: Ignoring zero-length LINE (between " \
+ "input line %d and %d): %s" % (start_line, end_line,
line))
开发者ID:I--Fox--I,项目名称:pycam,代码行数:45,代码来源:DXFImporter.py
示例17: save_preferences
def save_preferences(self):
""" save all settings that are available in the Preferences window to
a file in the user's home directory """
config_filename = pycam.Gui.Settings.get_config_filename()
if config_filename is None:
# failed to create the personal preferences directory
log.warn("Failed to create a preferences directory in " \
+ "your user's home directory.")
return
config = ConfigParser.ConfigParser()
for item in PREFERENCES_DEFAULTS.keys():
config.set("DEFAULT", item, self.settings.get(item))
try:
config_file = file(config_filename, "w")
config.write(config_file)
config_file.close()
except IOError, err_msg:
log.warn("Failed to write preferences file (%s): %s" % (config_filename, err_msg))
开发者ID:I--Fox--I,项目名称:pycam,代码行数:18,代码来源:Project.py
示例18: parse_content
def parse_content(self):
key, value = self._read_key_value()
while (not key is None) \
and not ((key == self.KEYS["MARKER"]) and (value == "EOF")):
if self.callback and self.callback():
return
if key == self.KEYS["MARKER"]:
if value in ("SECTION", "TABLE", "LAYER", "ENDTAB", "ENDSEC"):
# we don't handle these meta-information
pass
elif value == "LINE":
self.parse_line()
elif value == "LWPOLYLINE":
self.parse_lwpolyline()
elif value == "POLYLINE":
self.parse_polyline(True)
elif value == "VERTEX":
self.parse_vertex()
elif value == "SEQEND":
self.close_sequence()
elif value == "ARC":
self.parse_arc()
elif value == "CIRCLE":
self.parse_arc(circle=True)
elif value == "TEXT":
self.parse_text()
elif value == "MTEXT":
self.parse_mtext()
elif value == "3DFACE":
self.parse_3dface()
elif value in self.IGNORE_KEYS:
log.debug("DXFImporter: Ignored a blacklisted element " \
+ "in line %d: %s" % (self.line_number, value))
else:
# not supported
log.warn("DXFImporter: Ignored unsupported element " \
+ "in line %d: %s" % (self.line_number, value))
key, value = self._read_key_value()
开发者ID:I--Fox--I,项目名称:pycam,代码行数:38,代码来源:DXFImporter.py
示例19: get_font_dir
def get_font_dir():
if FONT_DIR_OVERRIDE:
if os.path.isdir(FONT_DIR_OVERRIDE):
return FONT_DIR_OVERRIDE
else:
log.warn(("You specified a font dir that does not exist (%s). " + "I will ignore it.") % FONT_DIR_OVERRIDE)
font_dir = get_data_file_location(FONTS_SUBDIR, silent=True)
if not font_dir is None:
return font_dir
else:
log.warn(
("Failed to locate the fonts directory '%s' below '%s'. " + "Falling back to '%s'.")
% (FONTS_SUBDIR, DATA_BASE_DIRS, ":".join(FONT_DIRS_FALLBACK))
)
for font_dir_fallback in FONT_DIRS_FALLBACK:
if os.path.isdir(font_dir_fallback):
return font_dir_fallback
else:
log.warn(
("None of the fallback font directories (%s) exist. " + "No fonts will be available.")
% ":".join(FONT_DIRS_FALLBACK)
)
return None
开发者ID:michaelr123,项目名称:pycam,代码行数:23,代码来源:locations.py
示例20: parse_mtext
def parse_mtext(self):
start_line = self.line_number
# the z-level defaults to zero (for 2D models)
ref_point = [None, None, 0]
direction_vector = [None, None, None]
color = None
text_groups_start = []
text_end = []
text_height = None
rotation = 0
width_final = None
font_name = "normal"
alignment = 0
key, value = self._read_key_value()
while (not key is None) and (key != self.KEYS["MARKER"]):
if key == self.KEYS["DEFAULT"]:
text_end = value
elif key == self.KEYS["TEXT_MORE"]:
text_groups_start.append(value)
elif key == self.KEYS["P1_X"]:
ref_point[0] = value
elif key == self.KEYS["P1_Y"]:
ref_point[1] = value
elif key == self.KEYS["P1_Z"]:
ref_point[2] = value
elif key == self.KEYS["P2_X"]:
direction_vector[0] = value
# according to DXF spec: the last one wins
rotation = None
elif key == self.KEYS["P2_Y"]:
direction_vector[1] = value
# according to DXF spec: the last one wins
rotation = None
elif key == self.KEYS["P2_Z"]:
direction_vector[2] = value
# according to DXF spec: the last one wins
rotation = None
elif key == self.KEYS["COLOR"]:
color = value
elif key == self.KEYS["TEXT_HEIGHT"]:
text_height = value
elif key == self.KEYS["TEXT_ROTATION"]:
rotation = value
# according to DXF spec: the last one wins
direction_vector = [None, None, None]
elif key == self.KEYS["TEXT_FONT"]:
font_name = value
elif key == self.KEYS["MTEXT_ALIGNMENT"]:
alignment = value
elif key == self.KEYS["TEXT_WIDTH_FINAL"]:
width_final = value
else:
pass
key, value = self._read_key_value()
end_line = self.line_number
# The last lines were not used - they are just the marker for the next
# item.
text = "".join(text_groups_start) + text_end
if not key is None:
self._push_on_stack(key, value)
if None in ref_point:
log.warn("DXFImporter: Incomplete MTEXT definition between line " \
+ "%d and %d: missing location point" % \
(start_line, end_line))
elif not text:
log.warn("DXFImporter: Incomplete MTEXT definition between line " \
+ "%d and %d: missing text" % (start_line, end_line))
elif not text_height:
log.warn("DXFImporter: Incomplete MTEXT definition between line " \
+ "%d and %d: missing height" % (start_line, end_line))
else:
if self._color_as_height and (not color is None):
# use the color code as the z coordinate
ref_point[2] = float(color) / 255
if self._fonts_cache:
font = self._fonts_cache.get_font(font_name)
else:
font = None
if not font:
log.warn("DXFImporter: No fonts are available - skipping " + \
"MTEXT item between line %d and %d" % \
(start_line, end_line))
return
model = font.render(text)
if (model.minx is None) or (model.miny is None) or \
(model.minz is None) or (model.minx == model.maxx) or \
(model.miny == model.maxy):
log.warn("DXFImporter: Empty rendered MTEXT item between " + \
"line %d and %d" % (start_line, end_line))
return
model.scale(text_height / (model.maxy - model.miny),
callback=self.callback)
# this setting seems to refer to a box - not the text width - ignore
if False and width_final:
scale_x = width_final / (model.maxx - model.minx)
model.scale(scale_x, callback=self.callback)
if rotation:
matrix = pycam.Geometry.Matrix.get_rotation_matrix_axis_angle(
(0, 0, 1), rotation)
elif not None in direction_vector:
#.........这里部分代码省略.........
开发者ID:I--Fox--I,项目名称:pycam,代码行数:101,代码来源:DXFImporter.py
注:本文中的pycam.Utils.log.warn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论