def getDefaultStyle(cls): if cls.__defstyle is None: _s = style.Style(u'Polyline Default Style', linetype.Linetype(u'Solid', None), color.Color(0xffffff), 1.0) cls.__defstyle = _s return cls.__defstyle
def _initialize_styles(): _style = graphicobject.GraphicObject.getDefaultStyle() globals.prefs['LINE_STYLE'] = _style globals.prefs['LINE_COLOR'] = _style.getColor() globals.prefs['LINE_TYPE'] = _style.getLinetype() globals.prefs['LINE_THICKNESS'] = _style.getThickness() # # set this style as the class default for the "real" drawing entities # segment.Segment.setDefaultStyle(_style) circle.Circle.setDefaultStyle(_style) arc.Arc.setDefaultStyle(_style) leader.Leader.setDefaultStyle(_style) polyline.Polyline.setDefaultStyle(_style) segjoint.SegJoint.setDefaultStyle(_style) segjoint.Chamfer.setDefaultStyle(_style) segjoint.Fillet.setDefaultStyle(_style) # # define and set a construction line style # _color = color.get_color(0xff, 0, 0) # red _lt = linetype.Linetype(u'Construction Lines', [2, 2]) _style = style.Style(u'Construction Objects', _lt, _color, 0.0) conobject.ConstructionObject.setDefaultStyle(_style) # # define and add the default text style and use values in the # text style to define various global key/value pairs # _ts = text.TextBlock.getDefaultTextStyle() globals.prefs['TEXT_STYLE'] = _ts globals.prefs['FONT_COLOR'] = _ts.getColor() globals.prefs['FONT_WEIGHT'] = _ts.getWeight() globals.prefs['FONT_STYLE'] = _ts.getStyle() globals.prefs['FONT_FAMILY'] = _ts.getFamily() globals.prefs['TEXT_SIZE'] = _ts.getSize() globals.prefs['TEXT_ANGLE'] = _ts.getAngle() globals.prefs['TEXT_ALIGNMENT'] = _ts.getAlignment() # # define and add the default dimension style and use the # values in that style to define various global preference # key/value pairs # _ds = dimension.Dimension.getDefaultDimStyle() globals.dimstyles.append(_ds) globals.prefs['DIM_STYLE'] = _ds for _key in _ds.getOptions(): _value = _ds.getOption(_key) globals.prefs[_key] = _value
def _initialize_linetypes(): _lt = linetype.Linetype(u'Solid') # solid globals.linetypes[_lt] = _lt _lt = linetype.Linetype(u'Dash1', [4, 1]) # dashed line globals.linetypes[_lt] = _lt _lt = linetype.Linetype(u'Dash2', [8, 2]) # dashed line globals.linetypes[_lt] = _lt _lt = linetype.Linetype(u'Dash3', [12, 2]) # dashed line globals.linetypes[_lt] = _lt _lt = linetype.Linetype(u'Dash4', [10, 2, 2, 2]) # dashed line globals.linetypes[_lt] = _lt _lt = linetype.Linetype(u'Dash5', [15, 5, 5, 5]) # dashed line globals.linetypes[_lt] = _lt
def __init__(self, name, lt=None, col=None, t=None): """Instatiate a Style object. Style(name [, lt, col, t]) name: A string giving the style a name Option arguments: lt: A Linetype object - defaults to a solid line Linetype col: A Color object - defaults to the default Color object t: A positive float value - defaults to 1.0 """ if not isinstance(name, types.StringTypes): raise TypeError, "Invalid Style name: " + ` name ` _n = name if not isinstance(_n, unicode): _n = unicode(name) _lt = lt if _lt is None: _lt = linetype.Linetype('Default_Solid', None) if not isinstance(_lt, linetype.Linetype): raise TypeError, "Invalid linetype: " + ` _lt ` _c = col if _c is None: _c = Style.__defcolor if not isinstance(_c, color.Color): _c = color.Color(color) _t = t if _t is None: _t = 1.0 _t = util.get_float(_t) if _t < 0.0: raise ValueError, "Invalid line thickness: %g" % _t self.__name = _n self.__linetype = _lt self.__color = _c self.__thickness = _t