Various fixes to Draft and Arch
+ Renamed Draft Scale object to Clone + Removed BasePoint property from Draft Clone + Reenabled Draft SelectPlane tool + Added Draft context tools to Arch module + Made the Arch module load pycollada later
This commit is contained in:
parent
c17ed6b3cd
commit
ccf878ec16
0
src/Mod/Arch/ArchWall.py
Executable file → Normal file
0
src/Mod/Arch/ArchWall.py
Executable file → Normal file
0
src/Mod/Arch/Init.py
Executable file → Normal file
0
src/Mod/Arch/Init.py
Executable file → Normal file
148
src/Mod/Arch/InitGui.py
Executable file → Normal file
148
src/Mod/Arch/InitGui.py
Executable file → Normal file
|
@ -22,78 +22,84 @@
|
|||
#***************************************************************************
|
||||
|
||||
class ArchWorkbench(Workbench):
|
||||
"Arch workbench object"
|
||||
Icon = """
|
||||
/* XPM */
|
||||
static char * arch_xpm[] = {
|
||||
"16 16 9 1",
|
||||
" c None",
|
||||
". c #543016",
|
||||
"+ c #6D2F08",
|
||||
"@ c #954109",
|
||||
"# c #874C24",
|
||||
"$ c #AE6331",
|
||||
"% c #C86423",
|
||||
"& c #FD7C26",
|
||||
"* c #F5924F",
|
||||
" ",
|
||||
" ",
|
||||
" # ",
|
||||
" ***$# ",
|
||||
" .*******. ",
|
||||
" *##$****#+ ",
|
||||
" #**%&&##$#@@ ",
|
||||
".$**%&&&&+@@+ ",
|
||||
"@&@#$$%&&@@+.. ",
|
||||
"@&&&%#.#$#+..#$.",
|
||||
" %&&&&+%#.$**$@+",
|
||||
" @%&+&&&$##@@+",
|
||||
" @.&&&&&@@@ ",
|
||||
" @%&&@@ ",
|
||||
" @+ ",
|
||||
" "};
|
||||
"""
|
||||
MenuText = "Arch"
|
||||
ToolTip = "Architecture workbench"
|
||||
"Arch workbench object"
|
||||
Icon = """
|
||||
/* XPM */
|
||||
static char * arch_xpm[] = {
|
||||
"16 16 9 1",
|
||||
" c None",
|
||||
". c #543016",
|
||||
"+ c #6D2F08",
|
||||
"@ c #954109",
|
||||
"# c #874C24",
|
||||
"$ c #AE6331",
|
||||
"% c #C86423",
|
||||
"& c #FD7C26",
|
||||
"* c #F5924F",
|
||||
" ",
|
||||
" ",
|
||||
" # ",
|
||||
" ***$# ",
|
||||
" .*******. ",
|
||||
" *##$****#+ ",
|
||||
" #**%&&##$#@@ ",
|
||||
".$**%&&&&+@@+ ",
|
||||
"@&@#$$%&&@@+.. ",
|
||||
"@&&&%#.#$#+..#$.",
|
||||
" %&&&&+%#.$**$@+",
|
||||
" @%&+&&&$##@@+",
|
||||
" @.&&&&&@@@ ",
|
||||
" @%&&@@ ",
|
||||
" @+ ",
|
||||
" "};
|
||||
"""
|
||||
MenuText = "Arch"
|
||||
ToolTip = "Architecture workbench"
|
||||
|
||||
def Initialize(self):
|
||||
import DraftTools,DraftGui,Arch_rc,Arch
|
||||
archtools = ["Arch_Wall","Arch_Structure","Arch_Cell",
|
||||
"Arch_Floor","Arch_Building","Arch_Site",
|
||||
"Arch_Window","Arch_Axis",
|
||||
"Arch_SectionPlane","Arch_Add","Arch_Remove"]
|
||||
drafttools = ["Draft_Line","Draft_Wire","Draft_Rectangle",
|
||||
"Draft_Polygon","Draft_Arc",
|
||||
"Draft_Circle","Draft_Dimension",
|
||||
"Draft_Move","Draft_Rotate",
|
||||
"Draft_Offset","Draft_Upgrade",
|
||||
"Draft_Downgrade","Draft_Trimex"]
|
||||
meshtools = ["Arch_SplitMesh","Arch_MeshToShape",
|
||||
"Arch_SelectNonSolidMeshes","Arch_RemoveShape"]
|
||||
self.appendToolbar(str(DraftTools.translate("arch","Arch tools")),archtools)
|
||||
self.appendToolbar(str(DraftTools.translate("arch","Draft tools")),drafttools)
|
||||
self.appendMenu([str(DraftTools.translate("arch","Architecture")),str(DraftTools.translate("arch","Tools"))],meshtools)
|
||||
self.appendMenu(str(DraftTools.translate("arch","Architecture")),archtools)
|
||||
self.appendMenu(str(DraftTools.translate("arch","Draft")),drafttools)
|
||||
FreeCADGui.addIconPath(":/icons")
|
||||
FreeCADGui.addLanguagePath(":/translations")
|
||||
FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui","Arch")
|
||||
FreeCAD.addImportType("Industry Foundation Classes (*.ifc)","importIFC")
|
||||
FreeCAD.addExportType("Wavefront OBJ - Arch module (*.obj)","importOBJ")
|
||||
try:
|
||||
import collada
|
||||
except:
|
||||
Log("pycollada not found, no collada support\n")
|
||||
else:
|
||||
FreeCAD.addImportType("Collada (*.dae)","importDAE")
|
||||
FreeCAD.addExportType("Collada (*.dae)","importDAE")
|
||||
Log ('Loading Arch module... done\n')
|
||||
def Activated(self):
|
||||
FreeCADGui.draftToolBar.Activated()
|
||||
Msg("Arch workbench activated\n")
|
||||
def Deactivated(self):
|
||||
FreeCADGui.draftToolBar.Deactivated()
|
||||
Msg("Arch workbench deactivated\n")
|
||||
def Initialize(self):
|
||||
import DraftTools,DraftGui,Arch_rc,Arch
|
||||
self.archtools = ["Arch_Wall","Arch_Structure","Arch_Cell",
|
||||
"Arch_Floor","Arch_Building","Arch_Site",
|
||||
"Arch_Window","Arch_Axis",
|
||||
"Arch_SectionPlane","Arch_Add","Arch_Remove"]
|
||||
self.drafttools = ["Draft_Line","Draft_Wire","Draft_Rectangle",
|
||||
"Draft_Polygon","Draft_Arc",
|
||||
"Draft_Circle","Draft_Dimension",
|
||||
"Draft_Move","Draft_Rotate",
|
||||
"Draft_Offset","Draft_Upgrade",
|
||||
"Draft_Downgrade","Draft_Trimex"]
|
||||
self.draftcontexttools = ["Draft_ApplyStyle","Draft_ToggleDisplayMode",
|
||||
"Draft_AddToGroup","Draft_SelectGroup",
|
||||
"Draft_SelectPlane"]
|
||||
self.meshtools = ["Arch_SplitMesh","Arch_MeshToShape",
|
||||
"Arch_SelectNonSolidMeshes","Arch_RemoveShape"]
|
||||
self.appendToolbar(str(DraftTools.translate("arch","Arch tools")),self.archtools)
|
||||
self.appendToolbar(str(DraftTools.translate("arch","Draft tools")),self.drafttools)
|
||||
self.appendMenu([str(DraftTools.translate("arch","Architecture")),str(DraftTools.translate("arch","Tools"))],self.meshtools)
|
||||
self.appendMenu(str(DraftTools.translate("arch","Architecture")),self.archtools)
|
||||
self.appendMenu(str(DraftTools.translate("arch","Draft")),self.drafttools+self.draftcontexttools)
|
||||
FreeCADGui.addIconPath(":/icons")
|
||||
FreeCADGui.addLanguagePath(":/translations")
|
||||
FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui","Arch")
|
||||
FreeCAD.addImportType("Industry Foundation Classes (*.ifc)","importIFC")
|
||||
FreeCAD.addExportType("Wavefront OBJ - Arch module (*.obj)","importOBJ")
|
||||
FreeCAD.addImportType("Collada (*.dae)","importDAE")
|
||||
FreeCAD.addExportType("Collada (*.dae)","importDAE")
|
||||
Log ('Loading Arch module... done\n')
|
||||
|
||||
def Activated(self):
|
||||
FreeCADGui.draftToolBar.Activated()
|
||||
Msg("Arch workbench activated\n")
|
||||
|
||||
def Deactivated(self):
|
||||
FreeCADGui.draftToolBar.Deactivated()
|
||||
Msg("Arch workbench deactivated\n")
|
||||
|
||||
def ContextMenu(self, recipient):
|
||||
self.appendContextMenu("Display tools",self.draftcontexttools)
|
||||
|
||||
def GetClassName(self):
|
||||
return "Gui::PythonWorkbench"
|
||||
|
||||
FreeCADGui.addWorkbench(ArchWorkbench)
|
||||
|
||||
|
|
0
src/Mod/Arch/ifcReader.py
Executable file → Normal file
0
src/Mod/Arch/ifcReader.py
Executable file → Normal file
|
@ -21,7 +21,7 @@
|
|||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import FreeCAD, collada, Mesh, os, numpy
|
||||
import FreeCAD, Mesh, os, numpy
|
||||
|
||||
__title__="FreeCAD Collada importer"
|
||||
__author__ = "Yorik van Havre"
|
||||
|
@ -29,8 +29,19 @@ __url__ = "http://free-cad.sourceforge.net"
|
|||
|
||||
DEBUG = True
|
||||
|
||||
def checkCollada():
|
||||
"checks if collada if available"
|
||||
try:
|
||||
import collada
|
||||
except:
|
||||
FreeCAD.Console.PrintError("pycollada not found, no collada support.\n")
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def open(filename):
|
||||
"called when freecad wants to open a file"
|
||||
if not checkCollada(): return
|
||||
docname = os.path.splitext(os.path.basename(filename))[0]
|
||||
doc = FreeCAD.newDocument(docname)
|
||||
doc.Label = decode(docname)
|
||||
|
@ -76,6 +87,7 @@ def read(filename):
|
|||
|
||||
def export(exportList,filename):
|
||||
"called when freecad exports a file"
|
||||
if not checkCollada(): return
|
||||
colmesh = collada.Collada()
|
||||
effect = collada.material.Effect("effect0", [], "phong", diffuse=(.7,.7,.7), specular=(1,1,1))
|
||||
mat = collada.material.Material("material0", "mymaterial", effect)
|
||||
|
|
|
@ -796,11 +796,16 @@ def scale(objectslist,delta=Vector(1,1,1),center=Vector(0,0,0),copy=False,legacy
|
|||
return newobjlist
|
||||
else:
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Scale")
|
||||
_Scale(obj)
|
||||
_Clone(obj)
|
||||
_ViewProviderDraft(obj.ViewObject)
|
||||
obj.Objects = objectslist
|
||||
obj.Scale = delta
|
||||
obj.BasePoint = center
|
||||
corr = Vector(center.x,center.y,center.z)
|
||||
corr.scale(delta.x,delta.y,delta.z)
|
||||
corr = fcvec.neg(corr.sub(center))
|
||||
p = obj.Placement
|
||||
p.move(corr)
|
||||
obj.Placement = p
|
||||
if not copy:
|
||||
for o in objectslist:
|
||||
o.ViewObject.hide()
|
||||
|
@ -2422,25 +2427,23 @@ class _ViewProviderPoint:
|
|||
def getIcon(self):
|
||||
return ":/icons/Draft_Dot.svg"
|
||||
|
||||
class _Scale:
|
||||
"The Scale object"
|
||||
class _Clone:
|
||||
"The Clone object"
|
||||
|
||||
def __init__(self,obj):
|
||||
obj.addProperty("App::PropertyLinkList","Objects","Base",
|
||||
"The objects included in this scale object")
|
||||
obj.addProperty("App::PropertyVector","Scale","Base",
|
||||
"The scale vector of this object")
|
||||
obj.addProperty("App::PropertyVector","BasePoint","Base",
|
||||
"The base point of this scale object")
|
||||
obj.Scale = Vector(1,1,1)
|
||||
obj.Proxy = self
|
||||
self.Type = "Scale"
|
||||
self.Type = "Clone"
|
||||
|
||||
def execute(self,obj):
|
||||
self.createGeometry(obj)
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
if prop in ["Scale","BasePoint","Objects"]:
|
||||
if prop in ["Scale","Objects"]:
|
||||
self.createGeometry(obj)
|
||||
|
||||
def createGeometry(self,obj):
|
||||
|
@ -2449,15 +2452,11 @@ class _Scale:
|
|||
pl = obj.Placement
|
||||
shapes = []
|
||||
for o in obj.Objects:
|
||||
if hasattr(o,"Shape"):
|
||||
if o.isDerivedFrom("Part::Feature"):
|
||||
sh = o.Shape.copy()
|
||||
m = FreeCAD.Matrix()
|
||||
m.scale(obj.Scale)
|
||||
sh = sh.transformGeometry(m)
|
||||
corr = Vector(obj.BasePoint)
|
||||
corr.scale(obj.Scale.x,obj.Scale.y,obj.Scale.z)
|
||||
corr = fcvec.neg(corr.sub(obj.BasePoint))
|
||||
sh.translate(corr)
|
||||
shapes.append(sh)
|
||||
if shapes:
|
||||
obj.Shape = Part.makeCompound(shapes)
|
||||
|
|
0
src/Mod/Draft/DraftTools.py
Executable file → Normal file
0
src/Mod/Draft/DraftTools.py
Executable file → Normal file
|
@ -178,10 +178,10 @@ class DraftWorkbench (Workbench):
|
|||
FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
|
||||
else:
|
||||
return
|
||||
Log ('Loading Draft GUI...\n')
|
||||
try:
|
||||
import macros,DraftTools,DraftGui
|
||||
self.appendMenu(["&Macro",str(DraftTools.translate("draft","Installed Macros"))],macros.macrosList)
|
||||
Log ('Loading Draft GUI...done\n')
|
||||
except:
|
||||
pass
|
||||
self.cmdList = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc",
|
||||
|
@ -191,7 +191,7 @@ class DraftWorkbench (Workbench):
|
|||
"Draft_Trimex", "Draft_Upgrade", "Draft_Downgrade", "Draft_Scale",
|
||||
"Draft_Drawing","Draft_Edit","Draft_WireToBSpline","Draft_AddPoint",
|
||||
"Draft_DelPoint","Draft_Shape2DView","Draft_Draft2Sketch","Draft_Array"]
|
||||
self.treecmdList = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup","Draft_SelectGroup"]
|
||||
self.treecmdList = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup","Draft_SelectGroup","Draft_SelectPlane"]
|
||||
self.lineList = ["Draft_UndoLine","Draft_FinishLine","Draft_CloseLine"]
|
||||
self.appendToolbar(str(DraftTools.translate("draft","Draft creation tools")),self.cmdList)
|
||||
self.appendToolbar(str(DraftTools.translate("draft","Draft modification tools")),self.modList)
|
||||
|
@ -208,17 +208,17 @@ class DraftWorkbench (Workbench):
|
|||
def ContextMenu(self, recipient):
|
||||
if (recipient == "View"):
|
||||
if (FreeCAD.activeDraftCommand == None):
|
||||
if (FreeCADGui.Selection.getSelection() != []):
|
||||
self.appendContextMenu(str(DraftTools.translate("draft","Draft")),self.cmdList+self.modList)
|
||||
self.appendContextMenu(str(DraftTools.translate("draft","Display options")),self.treecmdList)
|
||||
if (FreeCADGui.Selection.getSelection()):
|
||||
self.appendContextMenu("Draft",self.cmdList+self.modList)
|
||||
self.appendContextMenu("Display options",self.treecmdList)
|
||||
else:
|
||||
self.appendContextMenu(str(DraftTools.translate("draft","Draft")),self.cmdList)
|
||||
self.appendContextMenu("Draft",self.cmdList)
|
||||
else:
|
||||
if (FreeCAD.activeDraftCommand.featureName == "Line"):
|
||||
self.appendContextMenu("",self.lineList)
|
||||
else:
|
||||
if (FreeCADGui.Selection.getSelection() != []):
|
||||
self.appendContextMenu(str(DraftTools.translate("draft","Display options")),self.treecmdList)
|
||||
if (FreeCADGui.Selection.getSelection()):
|
||||
self.appendContextMenu("Display options",self.treecmdList)
|
||||
|
||||
def GetClassName(self):
|
||||
return "Gui::PythonWorkbench"
|
||||
|
|
0
src/Mod/Draft/importAirfoilDAT.py
Executable file → Normal file
0
src/Mod/Draft/importAirfoilDAT.py
Executable file → Normal file
0
src/Mod/Draft/macros.py
Executable file → Normal file
0
src/Mod/Draft/macros.py
Executable file → Normal file
Loading…
Reference in New Issue
Block a user