Draft: Reorganizing DraftEdit and future Draft command modules

This commit is contained in:
Yorik van Havre
2019-08-12 21:30:45 -03:00
parent 537a011a1d
commit 16c26cb3b1
4 changed files with 25 additions and 12 deletions

View File

@@ -64,9 +64,6 @@ class ArchWorkbench(Workbench):
FreeCADGui.addCommand('Arch_RebarTools', RebarGroupCommand())
self.archtools[2] = "Arch_RebarTools"
# setup Draft_Edit command
import DraftEdit
FreeCADGui.addCommand('Draft_Edit',DraftEdit.Edit())
# draft tools
self.drafttools = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Ellipse",

View File

@@ -27,16 +27,24 @@ __title__="FreeCAD Draft Edit Tool"
__author__ = "Yorik van Havre, Werner Mayer, Martin Burbaum, Ken Cline, Dmitry Chigrin"
__url__ = "http://www.freecadweb.org"
import FreeCAD, FreeCADGui, Draft, DraftTools, math
import FreeCAD
import Draft
import math
from FreeCAD import Vector
from DraftTrackers import *
from PySide import QtCore
from PySide.QtCore import QT_TRANSLATE_NOOP
from DraftTools import translate
# Do not import GUI-related modules if GUI is not there
if FreeCAD.GuiUp:
import FreeCADGui
import DraftTools
from DraftTrackers import *
from PySide import QtCore
from PySide.QtCore import QT_TRANSLATE_NOOP
from DraftTools import translate
class Edit():
"The Draft_Edit FreeCAD command definition"
def __init__(self):
@@ -1125,3 +1133,9 @@ class Edit():
self.obj.TagPosition = self.invpl.multVec(v)
else:
self.obj.Group[self.editing-1].Placement.Base = self.invpl.multVec(v)
if FreeCAD.GuiUp:
# setup command
FreeCADGui.addCommand('Draft_Edit', Edit())

View File

@@ -46,6 +46,12 @@ from DraftSnap import *
from DraftTrackers import *
from pivy import coin
#---------------------------------------------------------------------------
# Commands that have been migrated to their own modules
#---------------------------------------------------------------------------
import DraftEdit
#---------------------------------------------------------------------------
# Preflight stuff
#---------------------------------------------------------------------------

View File

@@ -65,7 +65,6 @@ class DraftWorkbench(Workbench):
# Import Draft tools, icons
try:
import os, Draft_rc, DraftTools, DraftGui
import DraftEdit
from DraftTools import translate
FreeCADGui.addLanguagePath(":/translations")
FreeCADGui.addIconPath(":/icons")
@@ -73,9 +72,6 @@ class DraftWorkbench(Workbench):
print(inst)
FreeCAD.Console.PrintError("Error: Initializing one or more of the Draft modules failed, Draft will not work as expected.\n")
# setup commands
FreeCADGui.addCommand('Draft_Edit', DraftEdit.Edit())
# setup menus
self.cmdList = ["Draft_Line", "Draft_Wire", "Draft_Circle",
"Draft_ArcTools", "Draft_Ellipse",