Files
create/src/Mod/Draft/draftobjects/style_dimension.py
carlopav 5bbf3ad6cf [Draft] Dimension style object
still have to split viewprovider from object.
[Draft] Dimension Style code cleanup

thx @vocx-fc for reviewing
further cleanup


[Draft] Dimension Style improvements

Added a property to the dimension object to link the dimension style.
Improved the update of dimensions when style changes. This can be done in 2 different ways: by setting AutoUpdate property to True or by activating Update function from the viewprovider context menu.
2020-04-16 11:37:10 +02:00

54 lines
2.6 KiB
Python

# ***************************************************************************
# * (c) 2020 Carlo Pavan *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with FreeCAD; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
"""This module provides the object code for Draft DimensionStyle.
"""
## @package style_dimension
# \ingroup DRAFT
# \brief This module provides the object code for Draft DimensionStyle.
import FreeCAD as App
import Draft
from Draft import _DraftObject
from PySide.QtCore import QT_TRANSLATE_NOOP
if App.GuiUp:
import FreeCADGui as Gui
from draftviewproviders.view_style_dimension import ViewProviderDraftDimensionStyle
def make_dimension_style(existing_dimension = None):
"""
Make dimension style
"""
if not App.ActiveDocument:
App.Console.PrintError("No active document. Aborting\n")
return
obj = App.ActiveDocument.addObject("App::FeaturePython","DimensionStyle")
DimensionStyle(obj)
if App.GuiUp:
ViewProviderDraftDimensionStyle(obj.ViewObject, existing_dimension)
return obj
class DimensionStyle(_DraftObject):
def __init__(self, obj):
_DraftObject.__init__(self, obj, "DimensionStyle")