algo
This commit is contained in:
@@ -50,12 +50,9 @@ version = "0.1.0"
|
||||
|
||||
|
||||
def selectionFilter(sel, objtype):
|
||||
print("type: ", objtype)
|
||||
fil = []
|
||||
for obj in sel:
|
||||
if hasattr(obj, "Proxy"):
|
||||
print("objeto:", obj.Proxy.__class__)
|
||||
print(obj.Proxy.__class__ is objtype)
|
||||
if obj.Proxy.__class__ is objtype:
|
||||
fil.append(obj)
|
||||
return fil
|
||||
@@ -143,7 +140,7 @@ class _PVPlantPlacementTaskPanel:
|
||||
|
||||
def calculateWorkingArea(self):
|
||||
self.Area = self.getProjected(self.PVArea.Shape)
|
||||
tmp = FreeCAD.ActiveDocument.findObjects(Name="ProhibitedArea")
|
||||
tmp = FreeCAD.ActiveDocument.findObjects(Name="ExclusionArea")
|
||||
if len(tmp):
|
||||
ProhibitedAreas = list()
|
||||
for obj in tmp:
|
||||
@@ -189,7 +186,6 @@ class _PVPlantPlacementTaskPanel:
|
||||
def adjustToTerrain(self, coordinates):
|
||||
mode = 1
|
||||
terrain = self.Terrain.Mesh
|
||||
type = 0
|
||||
|
||||
def placeRegion(df): # TODO: new
|
||||
import MeshPart as mp
|
||||
@@ -210,11 +206,10 @@ class _PVPlantPlacementTaskPanel:
|
||||
pbot = FreeCAD.Vector(base)
|
||||
pbot.y -= yl
|
||||
line = Part.LineSegment(ptop, pbot).toShape()
|
||||
if type == 0: # Mesh:
|
||||
profilepoints = mp.projectShapeOnMesh(line, terrain, FreeCAD.Vector(0, 0, 1))[0]
|
||||
else: # Shape:
|
||||
profilepoints = mp.projectShapeOnMesh(line, terrain, FreeCAD.Vector(0, 0, 1))[0]
|
||||
'''else: # Shape: sumamente lento por lo que quedaría eliminado si no se encuetra otro modo.
|
||||
tmp = terrain.makeParallelProjection(line, FreeCAD.Vector(0, 0, 1))
|
||||
profilepoints = [ver.Point for ver in tmp.Vertexes]
|
||||
profilepoints = [ver.Point for ver in tmp.Vertexes]'''
|
||||
|
||||
xx = list()
|
||||
yy = list()
|
||||
@@ -285,7 +280,7 @@ class _PVPlantPlacementTaskPanel:
|
||||
placeRegion(df)
|
||||
return df
|
||||
|
||||
def placeonregion_old(frames): # old
|
||||
"""def placeonregion_old(frames): # old
|
||||
for colnum, col in enumerate(frames):
|
||||
groups = list()
|
||||
groups.append([col[0]])
|
||||
@@ -381,7 +376,7 @@ class _PVPlantPlacementTaskPanel:
|
||||
rot = FreeCAD.Rotation(FreeCAD.Vector(-1, 0, 0), vec)
|
||||
pl.Rotation = FreeCAD.Rotation(rot.toEuler()[0], rot.toEuler()[1], 0)
|
||||
placements.append(pl)
|
||||
return placements
|
||||
return placements"""
|
||||
|
||||
def isInside(self, frame, point):
|
||||
if self.Area.isInside(point, 10, True):
|
||||
@@ -456,6 +451,8 @@ class _PVPlantPlacementTaskPanel:
|
||||
if countcols == self.form.editColCount.value():
|
||||
offsetcols += valcols
|
||||
countcols = 0
|
||||
print("/n/n")
|
||||
print(cols)
|
||||
return self.adjustToTerrain(cols)
|
||||
|
||||
def calculateNonAlignedArray(self):
|
||||
@@ -566,19 +563,20 @@ class _PVPlantPlacementTaskPanel:
|
||||
self.offsetY = FreeCAD.Units.Quantity(self.form.editOffsetVertical.text()).Value
|
||||
|
||||
FreeCAD.ActiveDocument.openTransaction("Create Placement")
|
||||
# 1. Calculate working area:
|
||||
self.calculateWorkingArea()
|
||||
|
||||
# 2. Calculate aligned array:
|
||||
if self.form.cbAlignFrames.isChecked():
|
||||
dataframe = self.calculateAlignedArray()
|
||||
else:
|
||||
dataframe = self.calculateNonAlignedArray()
|
||||
# 3. Adjust to terrain:
|
||||
self.createFrameFromPoints(dataframe)
|
||||
FreeCAD.ActiveDocument.commitTransaction()
|
||||
|
||||
# last step: ------------------------------
|
||||
FreeCAD.ActiveDocument.RecomputesFrozen = False
|
||||
params.SetBool("AutoSaveEnabled", auto_save_enabled)
|
||||
|
||||
self.createFrameFromPoints(dataframe)
|
||||
|
||||
total_time = datetime.now() - starttime
|
||||
print(" -- Tiempo tardado:", total_time)
|
||||
FreeCADGui.Control.closeDialog()
|
||||
|
||||
Reference in New Issue
Block a user