update
This commit is contained in:
@@ -45,24 +45,11 @@ __title__ = "PVPlant Frames"
|
||||
__author__ = "Javier Braña"
|
||||
__url__ = "http://www.sogos-solar.com"
|
||||
|
||||
|
||||
import os
|
||||
import PVPlantResources
|
||||
from PVPlantResources import DirIcons as DirIcons
|
||||
|
||||
def selectFrames():
|
||||
objectlist = list()
|
||||
#FreeCAD.ActiveDocument.findObjects(Name="Tracker")
|
||||
for obj in FreeCAD.ActiveDocument.Objects:
|
||||
if hasattr(obj, "Proxy") and obj.Proxy.isDerivedFrom("Frame"):
|
||||
objectlist.append(obj)
|
||||
return objectlist if len(objectlist) > 0 else None
|
||||
|
||||
def makeFrameSetup(name="FrameSetup"):
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", name)
|
||||
FrameSetup(obj)
|
||||
ViewProviderFrameSetup(obj.ViewObject)
|
||||
return obj
|
||||
|
||||
class FrameSetup:
|
||||
"A Base Frame Setup Class"
|
||||
def __init__(self, obj):
|
||||
@@ -72,6 +59,7 @@ class FrameSetup:
|
||||
def setProperties(self, obj):
|
||||
''' Definición de Propiedades: '''
|
||||
pl = obj.PropertiesList
|
||||
|
||||
# Modulo: ------------------------------------------------------------------------------------------------------
|
||||
if not "ModuleThick" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
@@ -175,14 +163,15 @@ class FrameSetup:
|
||||
"The facemaker type to use to build the profile of this object")
|
||||
)
|
||||
|
||||
# Frame --------------------------------------------------------------------------------------------------------
|
||||
'''if not "Tilt" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"Tilt",
|
||||
"Frame",
|
||||
# Poles --------------------------------------------------------------------------------------------------------
|
||||
if not "PoleType" in pl:
|
||||
obj.addProperty("App::PropertyLinkList",
|
||||
"PoleType",
|
||||
"Poles",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).Tilt = 30'''
|
||||
)
|
||||
|
||||
# Frame --------------------------------------------------------------------------------------------------------
|
||||
if not "MaxLengthwiseTilt" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"MaxLengthwiseTilt",
|
||||
@@ -217,268 +206,99 @@ class FrameSetup:
|
||||
)
|
||||
obj.setEditorMode("TotalAreaShape", 1)
|
||||
|
||||
|
||||
class Frame(ArchComponent.Component):
|
||||
"A Base Frame Obcject - Class"
|
||||
|
||||
def __init__(self, obj):
|
||||
# Definición de Variables:
|
||||
ArchComponent.Component.__init__(self, obj)
|
||||
self.obj = obj
|
||||
self.setProperties(obj)
|
||||
|
||||
# Does a IfcType exist?
|
||||
obj.IfcType = "Structural Item"
|
||||
obj.setEditorMode("IfcType", 1)
|
||||
|
||||
self.totalAreaShape = None
|
||||
self.changed = True
|
||||
|
||||
def setProperties(self, obj):
|
||||
# Definicion de Propiedades:
|
||||
print("Frame - setProperties")
|
||||
ArchComponent.Component.setProperties(self, obj)
|
||||
|
||||
pl = obj.PropertiesList
|
||||
# Modulo: ------------------------------------------------------------------------------------------------------
|
||||
if not "ModuleThick" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"ModuleThick",
|
||||
"Module",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).ModuleThick = 40
|
||||
if not "ModuleWidth" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"ModuleWidth",
|
||||
"Module",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The width of this object")
|
||||
).ModuleWidth = 992
|
||||
if not "ModuleHeight" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"ModuleHeight",
|
||||
"Module",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The Length of this object")
|
||||
).ModuleHeight = 1996
|
||||
if not "PoleCableLength" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"PoleCableLength",
|
||||
"Module",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The Length of this object")
|
||||
).PoleCableLength = 1200
|
||||
if not "ModulePower" in pl:
|
||||
obj.addProperty("App::PropertyQuantity",
|
||||
"ModulePower",
|
||||
"Module",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The Length of this object")
|
||||
).ModulePower = 400
|
||||
|
||||
# Array de modulos: -------------------------------------------------------------------------------------------
|
||||
if not "ModuleCols" in pl:
|
||||
obj.addProperty("App::PropertyQuantity",
|
||||
"ModuleCols",
|
||||
"Posicion de modulos",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).ModuleCols = 15
|
||||
|
||||
if not "ModuleRows" in pl:
|
||||
obj.addProperty("App::PropertyQuantity",
|
||||
"ModuleRows",
|
||||
"Posicion de modulos",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).ModuleRows = 2
|
||||
|
||||
if not "ModuleColGap" in pl:
|
||||
obj.addProperty("App::PropertyDistance",
|
||||
"ModuleColGap",
|
||||
"Posicion de modulos",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).ModuleColGap = 20
|
||||
|
||||
if not "ModuleRowGap" in pl:
|
||||
obj.addProperty("App::PropertyDistance",
|
||||
"ModuleRowGap",
|
||||
"Posicion de modulos",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).ModuleRowGap = 20
|
||||
|
||||
if not "ModuleOffsetX" in pl:
|
||||
obj.addProperty("App::PropertyDistance",
|
||||
"ModuleOffsetX",
|
||||
"Posicion de modulos",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).ModuleOffsetX = 0
|
||||
|
||||
if not "ModuleOffsetY" in pl:
|
||||
obj.addProperty("App::PropertyDistance",
|
||||
"ModuleOffsetY",
|
||||
"Posicion de modulos",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).ModuleOffsetY = 0
|
||||
|
||||
if not "ModuleOrientation" in pl:
|
||||
obj.addProperty("App::PropertyEnumeration",
|
||||
"ModuleOrientation",
|
||||
"Posicion de modulos",
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"The facemaker type to use to build the profile of this object")
|
||||
).ModuleOrientation = ["Portrait", "Landscape"]
|
||||
|
||||
if not "ModuleViews" in pl:
|
||||
obj.addProperty("App::PropertyBool",
|
||||
"ModuleViews",
|
||||
"Posicion de modulos",
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"The facemaker type to use to build the profile of this object")
|
||||
).ModuleViews = True
|
||||
'''
|
||||
if not "Modules" in pl:
|
||||
obj.addProperty("App::PropertyLinkSubListChild",
|
||||
"Modules",
|
||||
"Posicion de modulos",
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"The facemaker type to use to build the profile of this object")
|
||||
).ModuleViews = True
|
||||
'''
|
||||
|
||||
# Frame --------------------------------------------------------------------------------------------------------
|
||||
if not "Tilt" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"Tilt",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).Tilt = 30
|
||||
|
||||
if not "MaxLengthwiseTilt" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"MaxLengthwiseTilt",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property", "Máxima inclinación longitudinal")
|
||||
).MaxLengthwiseTilt = 15
|
||||
|
||||
# Frame outputs -----------------------------
|
||||
if not "Width" in pl:
|
||||
obj.addProperty("App::PropertyDistance",
|
||||
"Width",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"Ancho de la estructura")
|
||||
)
|
||||
obj.setEditorMode("Width", 1)
|
||||
|
||||
if not "Length" in pl:
|
||||
obj.addProperty("App::PropertyDistance",
|
||||
"Length",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"Largo de la estructura")
|
||||
)
|
||||
obj.setEditorMode("Length", 1)
|
||||
|
||||
if not "TotalArea" in pl:
|
||||
obj.addProperty("App::PropertyArea",
|
||||
"TotalArea",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("Part::PropertyPartShape",
|
||||
"Area total de los Paneles")
|
||||
)
|
||||
obj.setEditorMode("TotalArea", 1)
|
||||
|
||||
|
||||
# Neighbours:
|
||||
|
||||
if not "North" in pl:
|
||||
obj.addProperty("App::PropertyLink",
|
||||
"North",
|
||||
"Neighbours",
|
||||
QT_TRANSLATE_NOOP("Part::PropertyPartShape",
|
||||
"Area total de los Paneles")
|
||||
)
|
||||
|
||||
if not "South" in pl:
|
||||
obj.addProperty("App::PropertyLink",
|
||||
"South",
|
||||
"Neighbours",
|
||||
QT_TRANSLATE_NOOP("Part::PropertyPartShape",
|
||||
"Area total de los Paneles")
|
||||
)
|
||||
|
||||
if not "East" in pl:
|
||||
obj.addProperty("App::PropertyLink",
|
||||
"East",
|
||||
"Neighbours",
|
||||
QT_TRANSLATE_NOOP("Part::PropertyPartShape",
|
||||
"Area total de los Paneles")
|
||||
)
|
||||
|
||||
if not "West" in pl:
|
||||
obj.addProperty("App::PropertyLink",
|
||||
"West",
|
||||
"Neighbours",
|
||||
QT_TRANSLATE_NOOP("Part::PropertyPartShape",
|
||||
"Area total de los Paneles")
|
||||
)
|
||||
|
||||
|
||||
|
||||
'''# Placement
|
||||
if not "Route" in pl:
|
||||
obj.addProperty("App::PropertyLink",
|
||||
"Route",
|
||||
"Placement",
|
||||
QT_TRANSLATE_NOOP("Part::PropertyPartShape",
|
||||
"Total Area de los Paneles")
|
||||
)
|
||||
obj.setEditorMode("Route", 1)
|
||||
|
||||
if not "RouteSection" in pl:
|
||||
obj.addProperty("App::PropertyIntegerConstraint",
|
||||
"RouteSection",
|
||||
"Placement",
|
||||
QT_TRANSLATE_NOOP("Part::PropertyPartShape",
|
||||
"Total Area de los Paneles")
|
||||
)
|
||||
obj.setEditorMode("RouteSection", 1)'''
|
||||
|
||||
self.Type = "Frame"
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
if prop == "North":
|
||||
if obj.getPropertyByName(prop):
|
||||
obj.getPropertyByName("Route").South = obj
|
||||
|
||||
if (prop == "Route"):
|
||||
if obj.getPropertyByName(prop):
|
||||
obj.RouteSection = (1, 1, len(obj.getPropertyByName("Route").Shape.Edges) + 1, 1)
|
||||
|
||||
def getTotalAreaShape(self):
|
||||
return self.totalAreaShape
|
||||
|
||||
|
||||
''' ------------------------------------------- Fixed Structure --------------------------------------------------- '''
|
||||
|
||||
|
||||
def makeRack(name="Rack"):
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", name)
|
||||
_FixedRack(obj)
|
||||
_ViewProviderFixedRack(obj.ViewObject)
|
||||
# FreeCAD.ActiveDocument.recompute()
|
||||
obj.Label = name
|
||||
FixedRack(obj)
|
||||
ViewProviderFixedRack(obj.ViewObject)
|
||||
return obj
|
||||
|
||||
|
||||
class _FixedRack(Frame):
|
||||
class FixedRack(FrameSetup):
|
||||
"A Fixed Rack Obcject"
|
||||
|
||||
def __init__(self, obj):
|
||||
# Definición de Variables:
|
||||
Frame.__init__(self, obj)
|
||||
Frame.setProperties(self, obj)
|
||||
#FrameSetup.__init__(self, obj)
|
||||
super(FixedRack, self).__init__(obj)
|
||||
self.setProperties(obj)
|
||||
obj.ModuleColumns = 6
|
||||
obj.ModuleRows = 2
|
||||
obj.ModuleColGap = 20
|
||||
obj.ModuleRowGap = 20
|
||||
#obj.Tilt = 30
|
||||
# Does a IfcType exist?
|
||||
# obj.IfcType = "Fence"
|
||||
# obj.MoveWithHost = False
|
||||
|
||||
def setProperties(self, obj):
|
||||
FrameSetup.setProperties(self, obj)
|
||||
pl = obj.PropertiesList
|
||||
if not "ModuleElevation" in pl:
|
||||
obj.addProperty("App::PropertyDistance",
|
||||
"ModuleElevation",
|
||||
"ModuleArray",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).ModuleElevation = 500
|
||||
|
||||
# Frame: ------------------------------------------------------------------------------------------------------
|
||||
if not "Tilt" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"Tilt",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).Tilt = 0
|
||||
|
||||
if not "FrameType" in pl:
|
||||
obj.addProperty("App::PropertyEnumeration",
|
||||
"FrameType",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"The facemaker type to use to build the profile of this object")
|
||||
).FrameType = ["Simple", "West-Lest"]
|
||||
|
||||
|
||||
# Pole: ------------------------------------------------------------------------------------------------------
|
||||
if not "BackPostWidth" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"BackPostWidth",
|
||||
"Pole",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).BackPostWidth = 80
|
||||
|
||||
if not "BackPostHeight" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"BackPostHeight",
|
||||
"Pole",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).BackPostHeight = 160
|
||||
|
||||
if not "BackPostLength" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"BackPostLength",
|
||||
"Pole",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).BackPostLength = 3200
|
||||
|
||||
if not "FrontPostWidth" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"FrontPostWidth",
|
||||
"Pole",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).FrontPostWidth = 40
|
||||
|
||||
if not "FrontPostHeight" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"FrontPostHeight",
|
||||
"Pole",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).FrontPostHeight = 80
|
||||
|
||||
if not "FrontPostLength" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"FrontPostLength",
|
||||
"Pole",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).FrontPostLength = 2300
|
||||
|
||||
# Array of Posts: ------------------------------------------------------------------------------------------------------
|
||||
if not "NumberPostsX" in pl:
|
||||
@@ -486,7 +306,7 @@ class _FixedRack(Frame):
|
||||
"NumberPostsX",
|
||||
"Poles",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).NumberPostsX = 5
|
||||
).NumberPostsX = 3
|
||||
|
||||
if not "DistancePostsX" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
@@ -515,6 +335,7 @@ class _FixedRack(Frame):
|
||||
"Poles",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).RammingDeep = 1500
|
||||
|
||||
# Correas: ----------------------------------------------------------------------------------------------------
|
||||
if not "BeamHeight" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
@@ -545,9 +366,11 @@ class _FixedRack(Frame):
|
||||
).BeamSpacing = 1000
|
||||
|
||||
self.Type = "Fixed Rack"
|
||||
obj.Proxy = self
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
ArchComponent.Component.onDocumentRestored(self, obj)
|
||||
#ArchComponent.Component.onDocumentRestored(self, obj)
|
||||
super(FixedRack, self).onDocumentRestored(obj)
|
||||
self.setProperties(obj)
|
||||
|
||||
def __getstate__(self):
|
||||
@@ -557,153 +380,64 @@ class _FixedRack(Frame):
|
||||
if state:
|
||||
self.Type = state
|
||||
|
||||
'''
|
||||
def addObject(self, child):
|
||||
print("addObject")
|
||||
|
||||
def removeObject(self, child):
|
||||
print("removeObject")
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
|
||||
'''
|
||||
|
||||
def onChanged(self, fp, prop):
|
||||
'''Do something when a property has changed'''
|
||||
# FreeCAD.Console.PrintMessage("Change property: " + str(prop) + "\n")
|
||||
|
||||
def CalculateModuleArray(self, obj, totalh, totalw, moduleh, modulew):
|
||||
# ModuleThick
|
||||
# ModuleWidth
|
||||
# ModuleThinness
|
||||
# ModuleColor
|
||||
# ModuleCols
|
||||
# ModuleRows
|
||||
# ModuleColGap
|
||||
# ModuleRowGap
|
||||
|
||||
# BeamHeight
|
||||
# BeamWidth
|
||||
# BeamOffset
|
||||
|
||||
import Part
|
||||
|
||||
# pl = obj.Placement
|
||||
module = Part.makeBox(modulew, moduleh, obj.ModuleThick.Value)
|
||||
correa = Part.makeBox(totalw + obj.BeamOffset.Value * 2, obj.BeamWidth.Value, obj.BeamHeight.Value)
|
||||
|
||||
# Longitud poste - Produndidad de hincado + correas
|
||||
correaoffsetz = obj.BackPostLength.Value
|
||||
offsetz = correaoffsetz + obj.BeamHeight.Value
|
||||
|
||||
p1 = FreeCAD.Vector(0, 0, 0)
|
||||
p2 = FreeCAD.Vector(totalw, 0, 0)
|
||||
p3 = FreeCAD.Vector(totalw, totalh, 0)
|
||||
p4 = FreeCAD.Vector(0, totalh, 0)
|
||||
totalArea = Part.Face(Part.makePolygon([p1, p2, p3, p4, p1]))
|
||||
|
||||
totalArea = Part.makePlane(totalw, totalh)
|
||||
totalArea.Placement.Base.x = -totalw / 2
|
||||
totalArea.Placement.Base.y = -totalh / 2
|
||||
totalArea.Placement.Base.z = obj.BeamHeight.Value
|
||||
|
||||
self.ModuleArea = totalArea
|
||||
# if ShowtotalArea:
|
||||
self.ListModules.append(totalArea)
|
||||
|
||||
correaoffsety = (moduleh - obj.BeamSpacing.Value - obj.BeamWidth.Value) / 2
|
||||
def generate_modules(self, obj, h, w):
|
||||
modulos=[]
|
||||
for y in range(int(obj.ModuleRows.Value)):
|
||||
for x in range(int(obj.ModuleCols.Value)):
|
||||
xx = totalArea.Placement.Base.x + (modulew + obj.ModuleColGap.Value) * x
|
||||
yy = totalArea.Placement.Base.y + (moduleh + obj.ModuleRowGap.Value) * y
|
||||
zz = obj.BeamHeight.Value
|
||||
moduleCopy = module.copy()
|
||||
moduleCopy.Placement.Base.x = xx
|
||||
moduleCopy.Placement.Base.y = yy
|
||||
moduleCopy.Placement.Base.z = zz
|
||||
self.ListModules.append(moduleCopy)
|
||||
for x in range(int(obj.ModuleColumns.Value)):
|
||||
mod = Part.makeBox(w, h, obj.ModuleThick.Value)
|
||||
mod.Placement.Base = FreeCAD.Vector(
|
||||
x * (w + obj.ModuleColGap.Value),
|
||||
y * (h + obj.ModuleRowGap.Value),
|
||||
0
|
||||
)
|
||||
modulos.append(mod)
|
||||
|
||||
compound = Part.makeCompound(self.ListModules)
|
||||
compound.Placement.Base.z = correaoffsetz - obj.RammingDeep.Value
|
||||
compound = Part.makeCompound(modulos)
|
||||
'''center = FreeCAD.Vector(compound.BoundBox.Center)
|
||||
for mod in modulos:
|
||||
mod.Placement.Base -= FreeCAD.Vector(center.x, center.y, 0)
|
||||
compound = Part.makeCompound(modulos)'''
|
||||
return compound
|
||||
|
||||
if obj.FrontPost:
|
||||
base = FreeCAD.Vector(0, (-obj.BackPostHeight.Value + obj.DistancePostsY.Value) / 2,
|
||||
correaoffsetz - obj.RammingDeep.Value)
|
||||
else:
|
||||
base = FreeCAD.Vector(0, -obj.BackPostHeight.Value / 2 + totalh / 3,
|
||||
correaoffsetz - obj.RammingDeep.Value)
|
||||
|
||||
a = compound.rotate(base, FreeCAD.Vector(1, 0, 0), obj.Tilt)
|
||||
|
||||
del correa
|
||||
del module
|
||||
del compound
|
||||
del self.ListModules[:]
|
||||
|
||||
self.ListModules.append(a)
|
||||
|
||||
def CalculatePosts(self, obj, totalh, totalw):
|
||||
'''
|
||||
# NumberPostsX
|
||||
# NumberPostsY
|
||||
# PostHeight
|
||||
# PostWidth
|
||||
# PostLength
|
||||
# DistancePostsX
|
||||
# DistancePostsY
|
||||
'''
|
||||
|
||||
def generate_posts(self, obj):
|
||||
postBack = Part.makeBox(obj.BackPostWidth.Value, obj.BackPostHeight.Value, obj.BackPostLength.Value)
|
||||
postFront = Part.makeBox(obj.FrontPostWidth.Value, obj.FrontPostHeight.Value, obj.FrontPostLength.Value)
|
||||
|
||||
angle = obj.Placement.Rotation.toEuler()[1]
|
||||
offsetX = (-obj.DistancePostsX.Value * (obj.NumberPostsX.Value - 1)) / 2
|
||||
|
||||
# offsetY = (-obj.PostHeight.Value - obj.DistancePostsY * (obj.NumberPostsY - 1)) / 2
|
||||
if obj.FrontPost:
|
||||
offsetY = (-obj.BackPostHeight.Value + obj.DistancePostsY.Value) / 2
|
||||
else:
|
||||
# TODO: cambiar el totalh / 3 por el valor adecuado
|
||||
offsetY = -obj.BackPostHeight.Value / 2 + totalh / 3
|
||||
|
||||
offsetZ = -obj.RammingDeep.Value
|
||||
|
||||
post_back = []
|
||||
post_front = []
|
||||
for x in range(int(obj.NumberPostsX.Value)):
|
||||
xx = offsetX + (
|
||||
obj.NumberPostsX.Value + obj.DistancePostsX.Value) * x # * math.cos(obj.Placement.Rotation.toEuler()[1])
|
||||
yy = offsetY
|
||||
zz = offsetZ # * math.sin(obj.Placement.Rotation.toEuler()[1])
|
||||
|
||||
postCopy = postBack.copy()
|
||||
postCopy.Placement.Base.x = xx
|
||||
postCopy.Placement.Base.y = yy
|
||||
postCopy.Placement.Base.z = zz
|
||||
base = FreeCAD.Vector(xx, yy, obj.BackPostHeight.Value - offsetZ)
|
||||
postCopy = postCopy.rotate(base, FreeCAD.Vector(0, 1, 0), -angle)
|
||||
self.ListPosts.append(postCopy)
|
||||
postCopy.Placement.Base = FreeCAD.Vector(x * obj.DistancePostsX.Value, obj.DistancePostsY.Value, 0)
|
||||
post_back.append(postCopy)
|
||||
|
||||
if obj.FrontPost:
|
||||
postCopy = postFront.copy()
|
||||
postCopy.Placement.Base.x = xx
|
||||
postCopy.Placement.Base.y = -yy
|
||||
postCopy.Placement.Base.z = zz
|
||||
base = FreeCAD.Vector(xx, yy, obj.FrontPostHeight.Value - offsetZ)
|
||||
postCopy = postCopy.rotate(base, FreeCAD.Vector(0, 1, 0), -angle)
|
||||
self.ListPosts.append(postCopy)
|
||||
postCopy.Placement.Base = FreeCAD.Vector(x * obj.DistancePostsX.Value, 0, 0)
|
||||
post_front.append(postCopy)
|
||||
|
||||
del postBack
|
||||
del postFront
|
||||
return Part.makeCompound([Part.makeCompound(post_back), Part.makeCompound(post_front)])
|
||||
|
||||
def correct_placement(self, obj):
|
||||
center = FreeCAD.Vector(obj.BoundBox.Center)
|
||||
obj.Placement.Base -= FreeCAD.Vector(center.x, center.y, 0)
|
||||
|
||||
def execute(self, obj):
|
||||
# obj.Shape: compound
|
||||
# |- Modules and Beams: compound
|
||||
# |-- Modules array: compound
|
||||
# |--- Modules: solid
|
||||
# |-- Beams: compound
|
||||
# |--- MainBeam: solid
|
||||
# |--- Secundary Beams: solid (if exist)
|
||||
# |- Poles array: compound
|
||||
# |-- Poles: solid
|
||||
|
||||
pl = obj.Placement
|
||||
|
||||
del self.ListModules[:]
|
||||
del self.ListPosts[:]
|
||||
|
||||
self.ListModules = []
|
||||
self.ListPosts = []
|
||||
|
||||
if obj.ModuleOrientation == "Portrait":
|
||||
w = obj.ModuleWidth.Value
|
||||
h = obj.ModuleHeight.Value
|
||||
@@ -712,63 +446,38 @@ class _FixedRack(Frame):
|
||||
w = obj.ModuleHeight.Value
|
||||
|
||||
totalh = h * obj.ModuleRows + obj.ModuleRowGap.Value * (obj.ModuleRows - 1)
|
||||
totalw = w * obj.ModuleCols + obj.ModuleColGap.Value * (obj.ModuleCols - 1)
|
||||
obj.Width = totalw
|
||||
obj.Length = totalh
|
||||
totalw = w * obj.ModuleColumns + obj.ModuleColGap.Value * (obj.ModuleColumns - 1)
|
||||
|
||||
# hacer el shape:
|
||||
self.CalculateModuleArray(obj, totalh, totalw, h, w)
|
||||
self.CalculatePosts(obj, totalh, totalw)
|
||||
modules = self.generate_modules(obj, h, w)
|
||||
modules.Placement.Rotation = FreeCAD.Rotation(FreeCAD.Vector(1, 0, 0), obj.Tilt.Value)
|
||||
self.correct_placement(modules)
|
||||
modules.Placement.Base += FreeCAD.Vector(0, 0, obj.ModuleElevation.Value)
|
||||
posts = self.generate_posts(obj)
|
||||
self.correct_placement(posts)
|
||||
posts.Placement.Base -= FreeCAD.Vector(0, 0, obj.RammingDeep.Value)
|
||||
|
||||
allShapes = []
|
||||
allShapes.extend(self.ListModules)
|
||||
allShapes.extend(self.ListPosts)
|
||||
compound = Part.makeCompound(allShapes)
|
||||
compound = Part.makeCompound([modules, posts])
|
||||
obj.Shape = compound
|
||||
obj.Placement = pl
|
||||
|
||||
angle = obj.Placement.Rotation.toEuler()[1]
|
||||
if angle > obj.MaxLengthwiseTilt:
|
||||
obj.ViewObject.ShapeColor = (1.0, 0.0, 0.0)
|
||||
print("fin")
|
||||
|
||||
obj.Width = totalw
|
||||
obj.Length = totalh
|
||||
|
||||
class _ViewProviderFixedRack(ArchComponent.ViewProviderComponent):
|
||||
class ViewProviderFixedRack:
|
||||
"A View Provider for the Pipe object"
|
||||
|
||||
def __init__(self, vobj):
|
||||
ArchComponent.ViewProviderComponent.__init__(self, vobj)
|
||||
'''
|
||||
ArchSite._ViewProviderSite.__init__(self, vobj)
|
||||
vobj.Proxy = self
|
||||
vobj.addExtension("Gui::ViewProviderGroupExtensionPython", self)
|
||||
self.setProperties(vobj)
|
||||
'''
|
||||
|
||||
def getIcon(self):
|
||||
""" Return the path to the appropriate icon. """
|
||||
return str(os.path.join(DirIcons, "solar-fixed.svg"))
|
||||
|
||||
def setEdit(self, vobj, mode):
|
||||
"""Method called when the document requests the object to enter edit mode.
|
||||
|
||||
Edit mode is entered when a user double clicks on an object in the tree
|
||||
view, or when they use the menu option [Edit -> Toggle Edit Mode].
|
||||
|
||||
Just display the standard Arch component task panel.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
mode: int or str
|
||||
The edit mode the document has requested. Set to 0 when requested via
|
||||
a double click or [Edit -> Toggle Edit Mode].
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
If edit mode was entered.
|
||||
"""
|
||||
|
||||
if (mode == 0) and hasattr(self, "Object"):
|
||||
taskd = _FixedRackTaskPanel(self.Object)
|
||||
taskd.obj = self.Object
|
||||
@@ -783,15 +492,7 @@ class _FixedRackTaskPanel:
|
||||
# -------------------------------------------------------------------------------------------------------------
|
||||
# Module widget form
|
||||
# -------------------------------------------------------------------------------------------------------------
|
||||
self.formRack = FreeCADGui.PySideUic.loadUi(PVPlantResources.__dir__ + "/PVPlantFrame.ui")
|
||||
self.formRack.widgetTracker.setVisible(False)
|
||||
self.formRack.comboFrameType.currentIndexChanged.connect(self.selectionchange)
|
||||
|
||||
self.formPiling = FreeCADGui.PySideUic.loadUi(PVPlantResources.__dir__ + "/PVPlantRackFixedPiling.ui")
|
||||
self.formPiling.editBreadthwaysNumOfPost.valueChanged.connect(self.editBreadthwaysNumOfPostChange)
|
||||
self.formPiling.editAlongNumOfPost.valueChanged.connect(self.editAlongNumOfPostChange)
|
||||
|
||||
self.form = [self.formRack, self.formPiling]
|
||||
self.form = FreeCADGui.PySideUic.loadUi(PVPlantResources.__dir__ + "Mechanical/Frame/PVPlantFixedFrame.ui")
|
||||
|
||||
def selectionchange(self, i):
|
||||
vis = False
|
||||
@@ -839,7 +540,6 @@ def makeTrackerSetup(name="TrackerSetup"):
|
||||
pass
|
||||
return obj
|
||||
|
||||
|
||||
def getarray(array, numberofpoles):
|
||||
if len(array) == 0:
|
||||
newarray = [0] * numberofpoles
|
||||
@@ -899,36 +599,15 @@ class TrackerSetup(FrameSetup):
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).UseGroupsOfModules = False
|
||||
|
||||
# Poles: ------------------------------------------------------------------------------------------------------
|
||||
#TODO: cambiar todo esto por una lista de objetos??
|
||||
'''if not "PoleHeight" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"PoleHeight",
|
||||
"Pole",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).PoleHeight = 160
|
||||
|
||||
if not "PoleWidth" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"PoleWidth",
|
||||
"Pole",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The width of this object")
|
||||
).PoleWidth = 80
|
||||
|
||||
if not "PoleLength" in pl:
|
||||
obj.addProperty("App::PropertyLength",
|
||||
"PoleLength",
|
||||
"Pole",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).PoleLength = 3000'''
|
||||
|
||||
# Array of Posts: ------------------------------------------------------------------------------------------------------
|
||||
'''movido a la clase madre
|
||||
if not "PoleType" in pl:
|
||||
obj.addProperty("App::PropertyLinkList",
|
||||
"PoleType",
|
||||
"Poles",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
)
|
||||
)'''
|
||||
|
||||
if not "PoleSequence" in pl:
|
||||
obj.addProperty("App::PropertyIntegerList",
|
||||
@@ -1272,6 +951,7 @@ class TrackerSetup(FrameSetup):
|
||||
modules = self.CalculateModuleArray(obj, totalh, totalw, h, w)
|
||||
beams = self.calculateBeams(obj, totalh, totalw, h, w)
|
||||
poles, poleaxis = self.CalculatePosts(obj, totalh, totalw)
|
||||
|
||||
compound = Part.makeCompound([modules, beams])
|
||||
compound.Placement.Base.z = obj.MainBeamAxisPosition.Value - (obj.MainBeamHeight.Value / 2)
|
||||
obj.Shape = Part.makeCompound([compound, Part.makeCompound([poles, poleaxis])])
|
||||
@@ -1279,6 +959,7 @@ class TrackerSetup(FrameSetup):
|
||||
obj.Length = max(obj.Shape.BoundBox.XLength, obj.Shape.BoundBox.YLength)
|
||||
obj.TotalPower = obj.ModulePower.Value * obj.ModuleRows * obj.ModuleColumns
|
||||
|
||||
|
||||
class ViewProviderTrackerSetup:
|
||||
"A View Provider for the TrackerSetup object"
|
||||
|
||||
@@ -1297,6 +978,7 @@ class ViewProviderTrackerSetup:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def makeTracker(name = "Tracker", setup = None):
|
||||
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Tracker")
|
||||
obj.Label = name
|
||||
@@ -1306,6 +988,7 @@ def makeTracker(name = "Tracker", setup = None):
|
||||
obj.Setup = setup
|
||||
return obj
|
||||
|
||||
|
||||
class Tracker(ArchComponent.Component):
|
||||
"A 1 Axis single row Tracker Obcject"
|
||||
|
||||
@@ -1461,95 +1144,7 @@ class ViewProviderTracker(ArchComponent.ViewProviderComponent):
|
||||
|
||||
return False
|
||||
|
||||
class dualRowTracker(ArchComponent.Component):
|
||||
"A 1 Axis Dual Row Tracker Obcject"
|
||||
|
||||
def __init__(self, obj):
|
||||
# Definición de Variables:
|
||||
ArchComponent.Component.__init__(self, obj)
|
||||
self.setProperties(obj)
|
||||
self.Type = None
|
||||
self.oldTilt = 0
|
||||
self.oldRotation = None
|
||||
|
||||
def setProperties(self, obj):
|
||||
pl = obj.PropertiesList
|
||||
|
||||
if not "MotorPosition" in pl:
|
||||
obj.addProperty("App::PropertyLink",
|
||||
"MotorPosition",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
)
|
||||
|
||||
if not "MotorRow" in pl:
|
||||
obj.addProperty("App::PropertyLink",
|
||||
"MotorRow",
|
||||
"Frame",
|
||||
"The height of this object"
|
||||
)
|
||||
|
||||
if not "DrivenRow" in pl:
|
||||
obj.addProperty("App::PropertyLink",
|
||||
"DrivenRow",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
)
|
||||
|
||||
if not "Tilt" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"Tilt",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).Tilt = 0
|
||||
|
||||
if not "Tilt" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"Tilt",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
)
|
||||
|
||||
if not "Tilt" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"Tilt",
|
||||
"Frame",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
)
|
||||
|
||||
if not "AngleX" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"AngleX",
|
||||
"Outputs",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).AngleX = 0
|
||||
|
||||
if not "AngleY" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"AngleY",
|
||||
"Outputs",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).AngleX = 0
|
||||
|
||||
if not "AngleZ" in pl:
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"AngleZ",
|
||||
"Outputs",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).AngleX = 0
|
||||
|
||||
self.Type = "Tracker"
|
||||
# obj.Type = self.Type
|
||||
obj.Proxy = self
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
ArchComponent.Component.onDocumentRestored(self, obj)
|
||||
self.setProperties(obj)
|
||||
|
||||
def execute(self, obj):
|
||||
''' '''
|
||||
|
||||
|
||||
class _TrackerTaskPanel:
|
||||
def __init__(self, obj=None):
|
||||
|
||||
@@ -1657,7 +1252,7 @@ class _FrameTaskPanel:
|
||||
return True
|
||||
|
||||
|
||||
class _CommandFixedRack:
|
||||
class CommandFixedRack:
|
||||
"the Arch Building command definition"
|
||||
|
||||
def GetResources(self):
|
||||
@@ -1672,11 +1267,11 @@ class _CommandFixedRack:
|
||||
|
||||
def Activated(self):
|
||||
obj = makeRack()
|
||||
self.TaskPanel = _FixedRackTaskPanel(obj)
|
||||
FreeCADGui.Control.showDialog(self.TaskPanel)
|
||||
#self.TaskPanel = _FixedRackTaskPanel(obj)
|
||||
#FreeCADGui.Control.showDialog(self.TaskPanel)
|
||||
return
|
||||
|
||||
class _CommandTrackerSetup:
|
||||
class CommandTrackerSetup:
|
||||
"the Arch Building command definition"
|
||||
|
||||
def GetResources(self):
|
||||
@@ -1687,6 +1282,7 @@ class _CommandTrackerSetup:
|
||||
"Creates a TrackerSetup object from setup dialog.")}
|
||||
|
||||
def IsActive(self):
|
||||
return True
|
||||
return (not FreeCAD.ActiveDocument is None and
|
||||
not FreeCAD.ActiveDocument.getObject("Site") is None)
|
||||
|
||||
@@ -1696,7 +1292,7 @@ class _CommandTrackerSetup:
|
||||
FreeCADGui.Control.showDialog(self.TaskPanel)
|
||||
return
|
||||
|
||||
class _CommandTracker:
|
||||
class CommandTracker:
|
||||
"the Arch Building command definition"
|
||||
|
||||
def GetResources(self):
|
||||
@@ -1720,51 +1316,3 @@ class _CommandTracker:
|
||||
break
|
||||
makeTracker(setup=setupobj)
|
||||
return
|
||||
|
||||
class _CommandMultiRowTracker:
|
||||
"the Arch Building command definition"
|
||||
|
||||
def GetResources(self):
|
||||
return {'Pixmap': str(os.path.join(DirIcons, "solar-tracker.svg")),
|
||||
'MenuText': "Multi-row Tracker",
|
||||
'Accel': "R, M",
|
||||
'ToolTip': "Creates a multi-row Tracker object from trackers."}
|
||||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
if FreeCAD.ActiveDocument is not None:
|
||||
if FreeCADGui.Selection.getCompleteSelection():
|
||||
for ob in FreeCAD.ActiveDocument.Objects:
|
||||
if ob.Name[:4] == "Site":
|
||||
return True
|
||||
|
||||
def Activated(self):
|
||||
self.TaskPanel = _FixedRackTaskPanel()
|
||||
FreeCADGui.Control.showDialog(self.TaskPanel)
|
||||
return
|
||||
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
class CommandRackGroup:
|
||||
|
||||
def GetCommands(self):
|
||||
return tuple(['PVPlantFixedRack',
|
||||
'PVPlantTrackerSetup',
|
||||
'PVPlantTracker'
|
||||
])
|
||||
|
||||
def GetResources(self):
|
||||
return {'MenuText': QT_TRANSLATE_NOOP("", 'Rack Types'),
|
||||
'ToolTip': QT_TRANSLATE_NOOP("", 'Rack Types')
|
||||
}
|
||||
|
||||
def IsActive(self):
|
||||
return not FreeCAD.ActiveDocument is None
|
||||
|
||||
|
||||
FreeCADGui.addCommand('PVPlantFixedRack', _CommandFixedRack())
|
||||
FreeCADGui.addCommand('PVPlantTrackerSetup', _CommandTrackerSetup())
|
||||
FreeCADGui.addCommand('PVPlantTracker', _CommandTracker())
|
||||
FreeCADGui.addCommand('Multirow', _CommandMultiRowTracker())
|
||||
FreeCADGui.addCommand('RackType', CommandRackGroup())
|
||||
|
||||
Reference in New Issue
Block a user