Arch structures can now be based on axes systems
This commit is contained in:
parent
0de52ff73f
commit
d26ba5f11b
|
@ -34,6 +34,7 @@ def addToComponent(compobject,addobject,mod=None):
|
|||
"Components", the first one that exists in the component. Mod
|
||||
can be set to one of those attributes ("Objects", Base", etc...)
|
||||
to override the default.'''
|
||||
import Draft
|
||||
if compobject == addobject: return
|
||||
# first check is already there
|
||||
found = False
|
||||
|
@ -51,11 +52,17 @@ def addToComponent(compobject,addobject,mod=None):
|
|||
if hasattr(compobject,mod):
|
||||
if mod == "Base":
|
||||
setattr(compobject,mod,addobject)
|
||||
addobject.ViewObject.hide()
|
||||
elif mod == "Axes":
|
||||
if Draft.getType(addobject) == "Axis":
|
||||
l = getattr(compobject,mod)
|
||||
l.append(addobject)
|
||||
setattr(compobject,mod,l)
|
||||
else:
|
||||
l = getattr(compobject,mod)
|
||||
l.append(addobject)
|
||||
setattr(compobject,mod,l)
|
||||
addobject.ViewObject.hide()
|
||||
addobject.ViewObject.hide()
|
||||
else:
|
||||
for a in attribs[:3]:
|
||||
if hasattr(compobject,a):
|
||||
|
@ -103,7 +110,7 @@ class ComponentTaskPanel:
|
|||
# the categories are shown only if they are not empty.
|
||||
|
||||
self.obj = None
|
||||
self.attribs = ["Base","Additions","Subtractions","Objects","Components"]
|
||||
self.attribs = ["Base","Additions","Subtractions","Objects","Components","Axes"]
|
||||
self.form = QtGui.QWidget()
|
||||
self.form.setObjectName("TaskPanel")
|
||||
self.grid = QtGui.QGridLayout(self.form)
|
||||
|
@ -233,6 +240,7 @@ class ComponentTaskPanel:
|
|||
self.treeAdditions.setText(0,QtGui.QApplication.translate("Arch", "Additions", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.treeSubtractions.setText(0,QtGui.QApplication.translate("Arch", "Subtractions", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.treeObjects.setText(0,QtGui.QApplication.translate("Arch", "Objects", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.treeAxes.setText(0,QtGui.QApplication.translate("Arch", "Axes", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.treeComponents.setText(0,QtGui.QApplication.translate("Arch", "Components", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
||||
class Component:
|
||||
|
|
|
@ -84,15 +84,30 @@ class _Structure(ArchComponent.Component):
|
|||
"The width of this element, if not based on a profile")
|
||||
obj.addProperty("App::PropertyLength","Height","Base",
|
||||
"The height or extrusion depth of this element. Keep 0 for automatic")
|
||||
obj.addProperty("App::PropertyLinkList","Axes","Base",
|
||||
"Axes systems this structure is built on")
|
||||
self.Type = "Structure"
|
||||
|
||||
def execute(self,obj):
|
||||
self.createGeometry(obj)
|
||||
|
||||
def onChanged(self,obj,prop):
|
||||
if prop in ["Base","Length","Width","Height","Normal","Additions","Subtractions"]:
|
||||
if prop in ["Base","Length","Width","Height","Normal","Additions","Subtractions","Axes"]:
|
||||
self.createGeometry(obj)
|
||||
|
||||
def getAxisPoints(self,obj):
|
||||
"returns the gridpoints of linked axes"
|
||||
from draftlibs import fcgeo
|
||||
pts = []
|
||||
if len(obj.Axes) >= 2:
|
||||
set1 = obj.Axes[0].Shape.Edges
|
||||
set2 = obj.Axes[1].Shape.Edges
|
||||
for e1 in set1:
|
||||
for e2 in set2:
|
||||
pts.extend(fcgeo.findIntersection(e1,e2))
|
||||
return pts
|
||||
return None
|
||||
|
||||
def createGeometry(self,obj):
|
||||
import Part
|
||||
from draftlibs import fcgeo
|
||||
|
@ -158,8 +173,17 @@ class _Structure(ArchComponent.Component):
|
|||
base = base.cut(hole.Shape)
|
||||
hole.ViewObject.hide() # to be removed
|
||||
if base:
|
||||
obj.Shape = base
|
||||
if not fcgeo.isNull(pl): obj.Placement = pl
|
||||
pts = self.getAxisPoints(obj)
|
||||
if pts:
|
||||
fsh = []
|
||||
for p in pts:
|
||||
sh = base.copy()
|
||||
sh.translate(p)
|
||||
fsh.append(sh)
|
||||
obj.Shape = Part.makeCompound(fsh)
|
||||
else:
|
||||
obj.Shape = base
|
||||
if not fcgeo.isNull(pl): obj.Placement = pl
|
||||
|
||||
class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
|
||||
"A View Provider for the Structure object"
|
||||
|
|
|
@ -536,13 +536,13 @@ def makeCopy(obj):
|
|||
_Block(newobj)
|
||||
_ViewProviderDraftPart(newobj.ViewObject)
|
||||
elif getType(obj) == "Structure":
|
||||
import Structure
|
||||
Structure._Structure(newobj)
|
||||
Structure._ViewProviderStructure(newobj.ViewObject)
|
||||
import Arch
|
||||
Arch._Structure(newobj)
|
||||
Arch._ViewProviderStructure(newobj.ViewObject)
|
||||
elif getType(obj) == "Wall":
|
||||
import Wall
|
||||
Wall._Wall(newobj)
|
||||
Wall._ViewProviderWall(newobj.ViewObject)
|
||||
import Arch
|
||||
Arch._Wall(newobj)
|
||||
Arch._ViewProviderWall(newobj.ViewObject)
|
||||
elif obj.isDerivedFrom("Part::Feature"):
|
||||
newobj.Shape = obj.Shape
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user