updates
This commit is contained in:
@@ -540,6 +540,7 @@ def makeTrackerSetup(name="TrackerSetup"):
|
||||
pass
|
||||
return obj
|
||||
|
||||
|
||||
def getarray(array, numberofpoles):
|
||||
if len(array) == 0:
|
||||
newarray = [0] * numberofpoles
|
||||
@@ -568,6 +569,7 @@ def getarray(array, numberofpoles):
|
||||
newarray = [array[0]] * numberofpoles
|
||||
return newarray
|
||||
|
||||
|
||||
class TrackerSetup(FrameSetup):
|
||||
"A 1 Axis Tracker Obcject"
|
||||
|
||||
@@ -589,7 +591,7 @@ class TrackerSetup(FrameSetup):
|
||||
obj.addProperty("App::PropertyDistance",
|
||||
"MotorGap",
|
||||
"ModuleArray",
|
||||
QT_TRANSLATE_NOOP("App::Property", "Thse height of this object")
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).MotorGap = 550
|
||||
|
||||
if not "UseGroupsOfModules" in pl:
|
||||
@@ -880,6 +882,9 @@ class TrackerSetup(FrameSetup):
|
||||
|
||||
def CalculatePosts(self, obj, totalh, totalw):
|
||||
# Temp: utilizar el uso de versiones:
|
||||
if len(obj.PoleType) == 0:
|
||||
return None, None
|
||||
|
||||
ver = 1
|
||||
if ver == 0:
|
||||
# versión 0:
|
||||
@@ -906,8 +911,8 @@ class TrackerSetup(FrameSetup):
|
||||
elif ver == 1:
|
||||
# versión 1:
|
||||
linetmp = Part.LineSegment(FreeCAD.Vector(0), FreeCAD.Vector(0, 10, 0)).toShape()
|
||||
compoundPoles = Part.makeCompound([])
|
||||
compoundAxis = Part.makeCompound([])
|
||||
compound_poles = Part.makeCompound([])
|
||||
compound_axis = Part.makeCompound([])
|
||||
|
||||
offsetX = - totalw / 2
|
||||
arrayDistance = obj.DistancePole
|
||||
@@ -915,15 +920,16 @@ class TrackerSetup(FrameSetup):
|
||||
arrayPost = obj.PoleSequence
|
||||
|
||||
for x in range(int(obj.NumberPole.Value)):
|
||||
postCopy = obj.PoleType[arrayPost[x]].Shape.copy()
|
||||
post_copy = obj.PoleType[arrayPost[x]].Shape.copy()
|
||||
offsetX += arrayDistance[x]
|
||||
postCopy.Placement.Base = FreeCAD.Vector(offsetX, 0, -(postCopy.BoundBox.ZLength - arrayAerial[x]))
|
||||
compoundPoles.add(postCopy)
|
||||
post_copy.Placement.Base = FreeCAD.Vector(offsetX, 0, -(post_copy.BoundBox.ZLength - arrayAerial[x]))
|
||||
compound_poles.add(post_copy)
|
||||
|
||||
axis = linetmp.copy()
|
||||
axis.Placement.Base = FreeCAD.Vector(offsetX, 0, arrayAerial[x])
|
||||
compoundAxis.add(axis)
|
||||
return compoundPoles, compoundAxis
|
||||
compound_axis.add(axis)
|
||||
|
||||
return compound_poles, compound_axis
|
||||
|
||||
def execute(self, obj):
|
||||
# obj.Shape: compound
|
||||
@@ -1029,14 +1035,14 @@ class Tracker(ArchComponent.Component):
|
||||
"AngleY",
|
||||
"Outputs",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).AngleX = 0
|
||||
).AngleY = 0
|
||||
|
||||
if not ("AngleZ" in pl):
|
||||
obj.addProperty("App::PropertyAngle",
|
||||
"AngleZ",
|
||||
"Outputs",
|
||||
QT_TRANSLATE_NOOP("App::Property", "The height of this object")
|
||||
).AngleX = 0
|
||||
).AngleZ = 0
|
||||
|
||||
self.Type = "Tracker"
|
||||
#obj.Type = self.Type
|
||||
@@ -1056,12 +1062,15 @@ class Tracker(ArchComponent.Component):
|
||||
if prop.startswith("Angle"):
|
||||
base = obj.Placement.Base
|
||||
angles = obj.Placement.Rotation.toEulerAngles("XYZ")
|
||||
|
||||
# Actualizar rotación según el ángulo modificado
|
||||
if prop == "AngleX":
|
||||
rot = FreeCAD.Rotation(angles[2], angles[1], obj.AngleX.Value)
|
||||
elif prop == "AngleY":
|
||||
rot = FreeCAD.Rotation(angles[2], obj.AngleY.Value, angles[0])
|
||||
elif prop == "AngleZ":
|
||||
rot = FreeCAD.Rotation(obj.AngleZ.Value, angles[1], angles[0])
|
||||
|
||||
obj.Placement = FreeCAD.Placement(base, rot, FreeCAD.Vector(0,0,0))
|
||||
|
||||
if hasattr(FreeCAD.ActiveDocument, "FramesChecking"):
|
||||
@@ -1083,28 +1092,38 @@ class Tracker(ArchComponent.Component):
|
||||
# |-- PoleAxes: Edge
|
||||
|
||||
if obj.Setup is None:
|
||||
print("Warning: No Setup defined for tracker")
|
||||
return
|
||||
pl = obj.Placement
|
||||
shape = obj.Setup.Shape.copy()
|
||||
try:
|
||||
pl = obj.Placement
|
||||
shape = obj.Setup.Shape.copy()
|
||||
|
||||
p1 = shape.SubShapes[0].SubShapes[1].SubShapes[0].CenterOfMass
|
||||
p2 = min(shape.SubShapes[0].SubShapes[1].SubShapes[0].Faces, key=lambda face: face.Area).CenterOfMass
|
||||
axis = p1 - p2
|
||||
modules = shape.SubShapes[0].rotate(p1, axis, obj.Tilt.Value)
|
||||
# Rotar módulos
|
||||
p1 = shape.SubShapes[0].SubShapes[1].SubShapes[0].CenterOfMass
|
||||
p2 = min(shape.SubShapes[0].SubShapes[1].SubShapes[0].Faces, key=lambda face: face.Area).CenterOfMass
|
||||
axis = p1 - p2
|
||||
modules = shape.SubShapes[0].rotate(p1, axis, obj.Tilt.Value)
|
||||
|
||||
angle = obj.Placement.Rotation.toEuler()[1]
|
||||
newpoles = Part.makeCompound([])
|
||||
for i in range(len(shape.SubShapes[1].SubShapes[0].SubShapes)):
|
||||
pole = shape.SubShapes[1].SubShapes[0].SubShapes[i]
|
||||
axis = shape.SubShapes[1].SubShapes[1].SubShapes[i]
|
||||
base = axis.Vertexes[0].Point
|
||||
axis = axis.Vertexes[1].Point - axis.Vertexes[0].Point
|
||||
newpoles.add(pole.rotate(base, axis, -angle))
|
||||
poles = Part.makeCompound([newpoles, shape.SubShapes[1].SubShapes[1].copy()])
|
||||
# Rotar postes
|
||||
angle = obj.Placement.Rotation.toEuler()[1]
|
||||
newpoles = Part.makeCompound([])
|
||||
for i in range(len(shape.SubShapes[1].SubShapes[0].SubShapes)):
|
||||
pole = shape.SubShapes[1].SubShapes[0].SubShapes[i]
|
||||
axis = shape.SubShapes[1].SubShapes[1].SubShapes[i]
|
||||
base = axis.Vertexes[0].Point
|
||||
axis = axis.Vertexes[1].Point - axis.Vertexes[0].Point
|
||||
newpoles.add(pole.rotate(base, axis, -angle))
|
||||
poles = Part.makeCompound([newpoles, shape.SubShapes[1].SubShapes[1].copy()])
|
||||
|
||||
obj.Shape = Part.makeCompound([modules, poles])
|
||||
obj.Placement = pl
|
||||
obj.AngleX, obj.AngleY, obj.AngleZ = obj.Placement.Rotation.toEulerAngles("XYZ")
|
||||
# Crear forma final
|
||||
obj.Shape = Part.makeCompound([modules, poles])
|
||||
obj.Placement = pl
|
||||
|
||||
# Sincronizar propiedades de ángulo
|
||||
obj.AngleX, obj.AngleY, obj.AngleZ = obj.Placement.Rotation.toEulerAngles("XYZ")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error in Tracker execution: {str(e)}")
|
||||
|
||||
|
||||
class ViewProviderTracker(ArchComponent.ViewProviderComponent):
|
||||
@@ -1271,6 +1290,7 @@ class CommandFixedRack:
|
||||
#FreeCADGui.Control.showDialog(self.TaskPanel)
|
||||
return
|
||||
|
||||
|
||||
class CommandTrackerSetup:
|
||||
"the Arch Building command definition"
|
||||
|
||||
@@ -1292,6 +1312,7 @@ class CommandTrackerSetup:
|
||||
FreeCADGui.Control.showDialog(self.TaskPanel)
|
||||
return
|
||||
|
||||
|
||||
class CommandTracker:
|
||||
"the Arch Building command definition"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user