Arch: Minor fixes

This commit is contained in:
Yorik van Havre 2012-07-18 15:04:56 -03:00
parent 9d1cd19afb
commit 7b0d0aa2f7
4 changed files with 44 additions and 21 deletions

View File

@ -57,7 +57,7 @@ class ArchWorkbench(Workbench):
ToolTip = "Architecture workbench"
def Initialize(self):
import DraftTools,DraftGui,Arch_rc,Arch
import DraftTools,DraftGui,Arch_rc,Arch,Draft_rc
# arch tools
self.archtools = ["Arch_Wall","Arch_Structure",
@ -91,6 +91,8 @@ class ArchWorkbench(Workbench):
FreeCADGui.addIconPath(":/icons")
FreeCADGui.addLanguagePath(":/translations")
FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui","Arch")
FreeCADGui.addPreferencePage(":/ui/userprefs-base.ui","Draft")
FreeCADGui.addPreferencePage(":/ui/userprefs-import.ui","Draft")
Log ('Loading Arch module... done\n')
def Activated(self):
@ -106,7 +108,7 @@ class ArchWorkbench(Workbench):
Msg("Arch workbench deactivated\n")
def ContextMenu(self, recipient):
self.appendContextMenu("Display tools",self.draftcontexttools)
self.appendContextMenu("Draft context tools",self.draftcontexttools)
def GetClassName(self):
return "Gui::PythonWorkbench"

View File

@ -21,7 +21,9 @@
#* *
#***************************************************************************
import FreeCAD, DraftGeomUtils, Part
import FreeCAD, DraftGeomUtils, Part, Draft
p = Draft.precision()
if open.__module__ == '__builtin__':
pythonopen = open
@ -29,8 +31,10 @@ if open.__module__ == '__builtin__':
def findVert(aVertex,aList):
"finds aVertex in aList, returns index"
for i in range(len(aList)):
if (aVertex.X == aList[i].X) and (aVertex.Y == aList[i].Y) and (aVertex.Z == aList[i].Z):
return i
if ( round(aVertex.X,p) == round(aList[i].X,p) ):
if ( round(aVertex.Y,p) == round(aList[i].Y,p) ):
if ( round(aVertex.Z,p) == round(aList[i].Z,p) ):
return i
def getIndices(shape,offset):
"returns a list with 2 lists: vertices and face indexes, offsetted with the given amount"
@ -38,23 +42,33 @@ def getIndices(shape,offset):
elist = []
flist = []
for v in shape.Vertexes:
vlist.append(" "+str(round(v.X,4))+" "+str(round(v.Y,4))+" "+str(round(v.Z,4)))
vlist.append(" "+str(round(v.X,p))+" "+str(round(v.Y,p))+" "+str(round(v.Z,p)))
if not shape.Faces:
for e in shape.Edges:
if isinstance(e,Part.Line):
ei = " " + str(findVert(e.Vertexes[0],shape.Vertexes)+offset)
ei += " " + str(findVert(e.Vertexes[-1],shape.Vertexes)+offset)
ei = " " + str(findVert(e.Vertexes[0],shape.Vertexes) + offset)
ei += " " + str(findVert(e.Vertexes[-1],shape.Vertexes) + offset)
elist.append(ei)
for f in shape.Faces:
fi = ""
# OCC vertices are unsorted. We need to sort in the right order...
edges = DraftGeomUtils.sortEdges(f.Wire.Edges)
#print edges
for e in edges:
#print e.Vertexes[0].Point,e.Vertexes[1].Point
v = e.Vertexes[0]
fi+=" "+str(findVert(v,shape.Vertexes)+offset)
flist.append(fi)
if len(f.Wires) > 1:
# if we have holes, we triangulate
tris = f.tessellate(1)
for fdata in tris[1]:
fi = ""
for vi in fdata:
vdata = Part.Vertex(tris[0][vi])
fi += " " + str(findVert(vdata,shape.Vertexes) + offset)
flist.append(fi)
else:
fi = ""
# OCC vertices are unsorted. We need to sort in the right order...
edges = DraftGeomUtils.sortEdges(f.Wire.Edges)
#print edges
for e in edges:
#print e.Vertexes[0].Point,e.Vertexes[1].Point
v = e.Vertexes[0]
fi += " " + str(findVert(v,shape.Vertexes) + offset)
flist.append(fi)
return vlist,elist,flist
def export(exportList,filename):

View File

@ -3617,7 +3617,7 @@ class WireToBSpline(Modifier):
def finish(self):
Modifier.finish(self)
class SelectGroup():
"The SelectGroup FreeCAD command definition"
@ -3634,7 +3634,14 @@ class SelectGroup():
def Activated(self):
sellist = []
for ob in Draft.getSelection():
sel = Draft.getSelection()
if len(sel) == 1:
if sel[0].isDerivedFrom("App::DocumentObjectGroup"):
cts = Draft.getGroupContents(FreeCADGui.Selection.getSelection())
for o in cts:
FreeCADGui.Selection.addSelection(o)
return
for ob in sel:
for child in ob.OutList:
FreeCADGui.Selection.addSelection(child)
for parent in ob.InList:
@ -3642,7 +3649,7 @@ class SelectGroup():
for child in parent.OutList:
FreeCADGui.Selection.addSelection(child)
class Shape2DView():
"The Shape2DView FreeCAD command definition"
def GetResources(self):

View File

@ -225,7 +225,7 @@ class DraftWorkbench (Workbench):
self.appendContextMenu("",self.lineList)
else:
if (FreeCADGui.Selection.getSelection()):
self.appendContextMenu("Display options",self.treecmdList)
self.appendContextMenu("Draft context tools",self.treecmdList)
def GetClassName(self):
return "Gui::PythonWorkbench"