Optimize and order
This commit is contained in:
170
InitGui.py
170
InitGui.py
@@ -20,53 +20,62 @@
|
||||
# * *
|
||||
# ***********************************************************************
|
||||
|
||||
__title__="FreeCAD Fotovoltaic Power Plant Toolkit"
|
||||
__title__ = "FreeCAD Fotovoltaic Power Plant Toolkit"
|
||||
__author__ = "Javier Braña"
|
||||
__url__ = "sn"
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import os
|
||||
import FreeCADGui
|
||||
|
||||
FreeCADGui.updateLocale()
|
||||
|
||||
try:
|
||||
import PVPlantGeoreferencing, PVPlantPlacement, \
|
||||
PVPlantTerrainAnalisys, PVPlantSite, PVPlantImportGrid, PVPlantFence, \
|
||||
PVPlantFoundation, PVPlantCreateTerrainMesh, \
|
||||
PVPlantTreeGenerator, PVPlantBuilding, PVPlantTrench, PVPlantEarthWorks, \
|
||||
PVPlantStringing, \
|
||||
PVPlantPad, PVPlantRoad, PVPlantTerrain, PVPlantManhole, \
|
||||
GraphProfile, Utils.PVPlantTrace, \
|
||||
reload
|
||||
import PVPlantRackChecking
|
||||
|
||||
from Project.Area import PVPlantArea, PVPlantAreaUtils
|
||||
from Project import ProjectSetup
|
||||
|
||||
from Importer import importDXF
|
||||
|
||||
from Mechanical.Frame import PVPlantFrame
|
||||
|
||||
from Electrical.Cable import PVPlantCable, PVPlantElectricalLine
|
||||
from Electrical.CombinerBox import PVPlantStringBox
|
||||
from Electrical.Inverter import PVPlantInverter
|
||||
except ImportError as e:
|
||||
print(f"Error importing modules: {e}")
|
||||
|
||||
|
||||
class PVPlantWorkbench (Workbench):
|
||||
import os
|
||||
class PVPlantWorkbench(Workbench):
|
||||
from PVPlantResources import DirIcons as DirIcons
|
||||
|
||||
MenuText = "PVPlant"
|
||||
ToolTip = "Workbench for PV design"
|
||||
Icon = str(os.path.join(DirIcons, "icon.svg"))
|
||||
|
||||
def Initialize(self):
|
||||
import sys
|
||||
sys.path.append(r"C:\Users\javie\AppData\Roaming\FreeCAD\Mod")
|
||||
|
||||
# Mias
|
||||
import PVPlantGeoreferencing, PVPlantPlacement, \
|
||||
PVPlantTerrainAnalisys, PVPlantSite, PVPlantImportGrid, PVPlantFence,\
|
||||
PVPlantFoundation, PVPlantCreateTerrainMesh, \
|
||||
PVPlantTreeGenerator, PVPlantBuilding, PVPlantTrench, PVPlantEarthWorks, \
|
||||
PVPlantStringing, \
|
||||
PVPlantPad, PVPlantRoad, PVPlantTerrain, PVPlantManhole, \
|
||||
GraphProfile, Utils.PVPlantTrace,\
|
||||
reload
|
||||
import PVPlantRackChecking
|
||||
#sys.path.append(r"C:\Users\javie\AppData\Roaming\FreeCAD\Mod")
|
||||
sys.path.append(os.path.join(FreeCAD.getUserAppDataDir(), 'Mod'))
|
||||
import PVPlantTools
|
||||
|
||||
from Project.Area import PVPlantArea, PVPlantAreaUtils
|
||||
from Project import ProjectSetup
|
||||
from Export import exportPVSyst, PVPlantBOQMechanical, PVPlantBOQElectrical, PVPlantBOQCivil,\
|
||||
exportDXF
|
||||
from Importer import importDXF
|
||||
|
||||
from Mechanical.Frame import PVPlantFrame
|
||||
|
||||
from Electrical.Cable import PVPlantCable, PVPlantElectricalLine
|
||||
from Electrical.CombinerBox import PVPlantStringBox
|
||||
from Electrical.Inverter import PVPlantInverter
|
||||
self.projectlist = PVPlantTools.projectlist
|
||||
|
||||
# A list of command names created in the line above
|
||||
self.projectlist = ["Reload",
|
||||
'''self.projectlist = ["Reload",
|
||||
"PVPlantSite",
|
||||
"PVPlantGeoreferencing",
|
||||
"ProjectSetup",
|
||||
#"ImportGrid",
|
||||
# "ImportGrid",
|
||||
"Terrain",
|
||||
"PointsGroup",
|
||||
"PVPlantCreateTerrainMesh",
|
||||
@@ -78,35 +87,28 @@ class PVPlantWorkbench (Workbench):
|
||||
"PVPlantPad",
|
||||
"PVPlantRoad",
|
||||
"PVPlantManhole",
|
||||
#"PVPlantFoundation"
|
||||
# "PVPlantFoundation"
|
||||
"GraphTerrainProfile",
|
||||
"Trace",
|
||||
]
|
||||
]'''
|
||||
self.framelist = [
|
||||
"RackType",
|
||||
"PVPlantRackCheck",
|
||||
"Separator",
|
||||
"PVPlantPlacement",
|
||||
"PVPlantAdjustToTerrain",
|
||||
"PVPlantConvertTo",
|
||||
"PVArea"
|
||||
]
|
||||
"RackType",
|
||||
"PVPlantRackCheck",
|
||||
"Separator",
|
||||
"PVPlantPlacement",
|
||||
"PVPlantAdjustToTerrain",
|
||||
"PVPlantConvertTo",
|
||||
"PVArea"
|
||||
]
|
||||
|
||||
self.objectlist = [
|
||||
"PVPlantTree",
|
||||
"PVPlantBuilding",
|
||||
"PVPlantFenceGroup",
|
||||
]
|
||||
|
||||
self.inportExportlist = ["BOQCivil",
|
||||
"BOQMechanical",
|
||||
"BOQElectrical",
|
||||
"Separator",
|
||||
"exportDXF",
|
||||
#"importDXF",
|
||||
"ExportToPVSyst",
|
||||
]
|
||||
"PVPlantTree",
|
||||
"PVPlantBuilding",
|
||||
"PVPlantFenceGroup",
|
||||
]
|
||||
|
||||
from Export import ExporterCommands
|
||||
self.inportExportlist = ExporterCommands.Exportlist
|
||||
self.electricalList = ["PVPlantStringBox",
|
||||
"PVPlantCable",
|
||||
"PVPlanElectricalLine",
|
||||
@@ -114,14 +116,14 @@ class PVPlantWorkbench (Workbench):
|
||||
"Stringing",
|
||||
"Separator",
|
||||
"StringInverter",
|
||||
]
|
||||
]
|
||||
|
||||
self.roads = ["PVPlantRoad",
|
||||
|
||||
]
|
||||
]
|
||||
|
||||
self.pads = ["PVPlantPad",
|
||||
"Separator"
|
||||
self.pads = ["PVPlantPad",
|
||||
"Separator"
|
||||
]
|
||||
|
||||
# Toolbar
|
||||
@@ -140,34 +142,36 @@ class PVPlantWorkbench (Workbench):
|
||||
|
||||
# Draft tools
|
||||
from DraftTools import translate
|
||||
self.drafttools = ["Draft_Line","Draft_Wire","Draft_Circle","Draft_Arc","Draft_Ellipse",
|
||||
"Draft_Polygon","Draft_Rectangle", "Draft_Text",
|
||||
"Draft_Dimension", "Draft_BSpline","Draft_Point",
|
||||
"Draft_Facebinder","Draft_BezCurve","Draft_Label"]
|
||||
self.draftmodtools = ["Draft_Move","Draft_Rotate","Draft_Offset",
|
||||
"Draft_Trimex", "Draft_Upgrade", "Draft_Downgrade", "Draft_Scale",
|
||||
"Draft_Shape2DView","Draft_Draft2Sketch","Draft_Array",
|
||||
"Draft_Clone"]
|
||||
self.draftextratools = ["Draft_WireToBSpline","Draft_ShapeString",
|
||||
"Draft_PathArray","Draft_Mirror","Draft_Stretch"]
|
||||
self.draftcontexttools = ["Draft_ApplyStyle","Draft_ToggleDisplayMode","Draft_AddToGroup","Draft_AutoGroup",
|
||||
"Draft_SelectGroup","Draft_SelectPlane",
|
||||
"Draft_ShowSnapBar","Draft_ToggleGrid",]
|
||||
self.draftutils = ["Draft_Heal","Draft_FlipDimension",
|
||||
"Draft_ToggleConstructionMode","Draft_ToggleContinueMode","Draft_Edit",
|
||||
"Draft_Slope","Draft_AddConstruction"]
|
||||
self.snapList = ['Draft_Snap_Lock','Draft_Snap_Midpoint','Draft_Snap_Perpendicular',
|
||||
'Draft_Snap_Grid','Draft_Snap_Intersection','Draft_Snap_Parallel',
|
||||
'Draft_Snap_Endpoint','Draft_Snap_Angle','Draft_Snap_Center',
|
||||
'Draft_Snap_Extension','Draft_Snap_Near','Draft_Snap_Ortho','Draft_Snap_Special',
|
||||
'Draft_Snap_Dimensions','Draft_Snap_WorkingPlane']
|
||||
|
||||
self.drafttools = ["Draft_Line", "Draft_Wire", "Draft_Circle", "Draft_Arc", "Draft_Ellipse",
|
||||
"Draft_Polygon", "Draft_Rectangle", "Draft_Text",
|
||||
"Draft_Dimension", "Draft_BSpline", "Draft_Point",
|
||||
"Draft_Facebinder", "Draft_BezCurve", "Draft_Label"]
|
||||
self.draftmodtools = ["Draft_Move", "Draft_Rotate", "Draft_Offset",
|
||||
"Draft_Trimex", "Draft_Upgrade", "Draft_Downgrade", "Draft_Scale",
|
||||
"Draft_Shape2DView", "Draft_Draft2Sketch", "Draft_Array",
|
||||
"Draft_Clone"]
|
||||
self.draftextratools = ["Draft_WireToBSpline", "Draft_ShapeString",
|
||||
"Draft_PathArray", "Draft_Mirror", "Draft_Stretch"]
|
||||
self.draftcontexttools = ["Draft_ApplyStyle", "Draft_ToggleDisplayMode", "Draft_AddToGroup", "Draft_AutoGroup",
|
||||
"Draft_SelectGroup", "Draft_SelectPlane",
|
||||
"Draft_ShowSnapBar", "Draft_ToggleGrid", ]
|
||||
self.draftutils = ["Draft_Heal", "Draft_FlipDimension",
|
||||
"Draft_ToggleConstructionMode", "Draft_ToggleContinueMode", "Draft_Edit",
|
||||
"Draft_Slope", "Draft_AddConstruction"]
|
||||
self.snapList = ['Draft_Snap_Lock', 'Draft_Snap_Midpoint', 'Draft_Snap_Perpendicular',
|
||||
'Draft_Snap_Grid', 'Draft_Snap_Intersection', 'Draft_Snap_Parallel',
|
||||
'Draft_Snap_Endpoint', 'Draft_Snap_Angle', 'Draft_Snap_Center',
|
||||
'Draft_Snap_Extension', 'Draft_Snap_Near', 'Draft_Snap_Ortho', 'Draft_Snap_Special',
|
||||
'Draft_Snap_Dimensions', 'Draft_Snap_WorkingPlane']
|
||||
|
||||
def QT_TRANSLATE_NOOP(scope, text): return text
|
||||
|
||||
self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "Draft tools"), self.drafttools)
|
||||
self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "Draft mod tools"), self.draftmodtools)
|
||||
self.appendMenu(QT_TRANSLATE_NOOP("arch", "&Draft"), self.drafttools + self.draftmodtools + self.draftextratools)
|
||||
self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"), QT_TRANSLATE_NOOP("arch", "Utilities")], self.draftutils + self.draftcontexttools)
|
||||
self.appendMenu(QT_TRANSLATE_NOOP("arch", "&Draft"),
|
||||
self.drafttools + self.draftmodtools + self.draftextratools)
|
||||
self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"), QT_TRANSLATE_NOOP("arch", "Utilities")],
|
||||
self.draftutils + self.draftcontexttools)
|
||||
self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"), QT_TRANSLATE_NOOP("arch", "Snapping")], self.snapList)
|
||||
|
||||
import Part
|
||||
@@ -205,10 +209,10 @@ class PVPlantWorkbench (Workbench):
|
||||
"This is executed whenever the user right-clicks on screen"
|
||||
# "recipient" will be either "view" or "tree"
|
||||
|
||||
#if FreeCAD.activeDraftCommand is None:
|
||||
# if FreeCAD.activeDraftCommand is None:
|
||||
if recipient.lower() == "view":
|
||||
print("Menus en la 'View'")
|
||||
#if FreeCAD.activeDraftCommand is None:
|
||||
# if FreeCAD.activeDraftCommand is None:
|
||||
presel = FreeCADGui.Selection.getPreselection()
|
||||
print(presel.SubElementNames, " - ", presel.PickedPoints)
|
||||
if not presel is None:
|
||||
@@ -239,7 +243,7 @@ class PVPlantWorkbench (Workbench):
|
||||
self.contextMenu.show()
|
||||
'''
|
||||
|
||||
def GetClassName(self):
|
||||
def GetClassName(self):
|
||||
# this function is mandatory if this is a full python workbench
|
||||
return "Gui::PythonWorkbench"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user