Arch: Added several properties to Equipment, Space, Floor & Site needed for gbXML - issue #2543
This commit is contained in:
parent
7ef31e499c
commit
6861574346
|
@ -241,6 +241,7 @@ class _Equipment(ArchComponent.Component):
|
|||
obj.addProperty("App::PropertyString","Model","Arch","The model description of this equipment")
|
||||
obj.addProperty("App::PropertyString","Url","Arch","The url of the product page of this equipment")
|
||||
obj.addProperty("App::PropertyVectorList","SnapPoints","Arch","Additional snap points for this equipment")
|
||||
obj.addProperty("App::PropertyFloat","EquipmentPower","Arch","The electric power needed by this equipment in Watts")
|
||||
self.Type = "Equipment"
|
||||
obj.Role = Roles
|
||||
obj.Proxy = self
|
||||
|
|
|
@ -98,6 +98,7 @@ class _Floor:
|
|||
"The Floor object"
|
||||
def __init__(self,obj):
|
||||
obj.addProperty("App::PropertyLength","Height","Arch","The height of this object")
|
||||
obj.addProperty("App::PropertyArea","Area", "Arch","The computed floor area of this floor")
|
||||
if not hasattr(obj,"Placement"):
|
||||
# obj can be a Part Feature and already has a placement
|
||||
obj.addProperty("App::PropertyPlacement","Placement","Arch","The placement of this object")
|
||||
|
@ -116,6 +117,14 @@ class _Floor:
|
|||
if not hasattr(self,"Object"):
|
||||
# on restore, self.Object is not there anymore
|
||||
self.Object = obj
|
||||
if (prop == "Group") and hasattr(obj,"Area"):
|
||||
a = 0
|
||||
for o in Draft.getObjectsOfType(Draft.getGroupContents(obj.Group,addgroups=True),"Space"):
|
||||
if hasattr(o,"Area"):
|
||||
if hasattr(o.Area,"Value"):
|
||||
a += o.Area.Value
|
||||
if obj.Area.Value != a:
|
||||
obj.Area = a
|
||||
|
||||
def execute(self,obj):
|
||||
# move children with this floor
|
||||
|
|
|
@ -117,6 +117,7 @@ class _Site(ArchFloor._Floor):
|
|||
obj.addProperty("App::PropertyString","Country","Arch","The country of this site")
|
||||
obj.addProperty("App::PropertyFloat","Latitude","Arch","The latitude of this site")
|
||||
obj.addProperty("App::PropertyFloat","Longitude","Arch","The latitude of this site")
|
||||
obj.addProperty("App::PropertyLength","Elevation","Arch","The elevation of level 0 of this site")
|
||||
obj.addProperty("App::PropertyString","Url","Arch","An url that shows this site in a mapping website")
|
||||
obj.addProperty("App::PropertyLinkList","Group","Arch","The objects that are part of this site")
|
||||
obj.addProperty("App::PropertyLinkList","Additions","Arch","Other shapes that are appended to this object")
|
||||
|
|
|
@ -141,6 +141,15 @@ SpaceTypes = [
|
|||
"Transportation - Terminal - Ticket Counter"
|
||||
]
|
||||
|
||||
ConditioningTypes = [
|
||||
"Unconditioned",
|
||||
"Heated",
|
||||
"Cooled",
|
||||
"HeatedAndCooled",
|
||||
"Vented",
|
||||
"NaturallyVentedOnly"
|
||||
]
|
||||
|
||||
import FreeCAD,ArchComponent,ArchCommands,math,Draft
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
|
@ -224,15 +233,22 @@ class _Space(ArchComponent.Component):
|
|||
def __init__(self,obj):
|
||||
ArchComponent.Component.__init__(self,obj)
|
||||
obj.addProperty("App::PropertyLinkSubList","Boundaries", "Arch","The objects that make the boundaries of this space object")
|
||||
obj.addProperty("App::PropertyFloat", "Area", "Arch","The computed floor area of this space")
|
||||
obj.addProperty("App::PropertyArea", "Area", "Arch","The computed floor area of this space")
|
||||
obj.addProperty("App::PropertyString", "FinishFloor", "Arch","The finishing of the floor of this space")
|
||||
obj.addProperty("App::PropertyString", "FinishWalls", "Arch","The finishing of the walls of this space")
|
||||
obj.addProperty("App::PropertyString", "FinishCeiling", "Arch","The finishing of the ceiling of this space")
|
||||
obj.addProperty("App::PropertyLinkList", "Group", "Arch","Objects that are included inside this space, such as furniture")
|
||||
obj.addProperty("App::PropertyEnumeration","SpaceType", "Arch","The type of this space")
|
||||
obj.addProperty("App::PropertyLength", "FloorThickness","Arch","The thickness of the floor finish")
|
||||
obj.addProperty("App::PropertyLink", "Zone", "Arch","A zone this space is part of")
|
||||
obj.addProperty("App::PropertyInteger", "NumberOfPeople","Arch","The number of people who typically occupy this space")
|
||||
obj.addProperty("App::PropertyFloat", "LightingPower", "Arch","The electric power needed to light this space in Watts")
|
||||
obj.addProperty("App::PropertyFloat", "EquipmentPower","Arch","The electric power needed by the equipments of this space in Watts")
|
||||
obj.addProperty("App::PropertyBool", "AutoPower", "Arch","If True, Equipment Power will be automatically filled by the equipments included in this space")
|
||||
obj.addProperty("App::PropertyEnumeration","Conditioning", "Arch","The type of air conditioning of this space")
|
||||
self.Type = "Space"
|
||||
self.SpaceType = "Undefined"
|
||||
obj.SpaceType = SpaceTypes
|
||||
obj.Conditioning = ConditioningTypes
|
||||
obj.Role = Roles
|
||||
|
||||
def execute(self,obj):
|
||||
|
@ -245,7 +261,19 @@ class _Space(ArchComponent.Component):
|
|||
def onChanged(self,obj,prop):
|
||||
if prop in ["Boundaries","Base"]:
|
||||
self.getShape(obj)
|
||||
obj.Area = self.getArea(obj)
|
||||
if hasattr(obj.Area,"Value"):
|
||||
a = self.getArea(obj)
|
||||
if obj.Area.Value != a:
|
||||
obj.Area = a
|
||||
elif prop == "Group":
|
||||
if hasattr(obj,"EquipmentPower"):
|
||||
if obj.AutoPower:
|
||||
p = 0
|
||||
for o in Draft.getObjectsOfType(Draft.getGroupContents(obj.Group,addgroups=True),"Equipment"):
|
||||
if hasattr(o,"EquipmentPower"):
|
||||
p += o.EquipmentPower
|
||||
if p != obj.EquipmentPower:
|
||||
obj.EquipmentPower = p
|
||||
if hasattr(obj,"Area"):
|
||||
obj.setEditorMode('Area',1)
|
||||
|
||||
|
|
|
@ -33,18 +33,15 @@ else:
|
|||
def translate(ctx,txt):
|
||||
return txt
|
||||
|
||||
if open.__module__ == '__builtin__':
|
||||
pyopen = open # because we'll redefine open below
|
||||
|
||||
|
||||
def export(objectslist,filename):
|
||||
|
||||
if len(objectslist) != 1:
|
||||
FreeCAD.Console.PrintError(translate("Arch","This exporter can currently only export one site object"))
|
||||
FreeCAD.Console.PrintError(translate("Arch","This exporter can currently only export one site object\n"))
|
||||
return
|
||||
site = objectslist[0]
|
||||
if Draft.getType(site) != "Site":
|
||||
FreeCAD.Console.PrintError(translate("Arch","This exporter can currently only export one site object"))
|
||||
FreeCAD.Console.PrintError(translate("Arch","This exporter can currently only export one site object\n"))
|
||||
return
|
||||
|
||||
filestream = pyopen(filename,"wb")
|
||||
|
@ -52,35 +49,84 @@ def export(objectslist,filename):
|
|||
# header
|
||||
filestream.write( '<?xml version="1.0"?>\n' )
|
||||
filestream.write( '<!-- Exported by FreeCAD %s -->\n' % FreeCAD.Version()[0]+FreeCAD.Version()[1]+FreeCAD.Version()[2] )
|
||||
filestream.write( '<gbXML xmlns="http://www.gbxml.org/schema" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gbxml.org/schema" temperatureUnit="C" lengthUnit="Millimeters" areaUnit="SquareMeters" volumeUnit="CubicMeters" useSIUnitsForResults="false">\n' )
|
||||
filestream.write( '<gbXML\n' )
|
||||
filestream.write( ' xmlns="http://www.gbxml.org/schema"\n' )
|
||||
filestream.write( ' xmlns:xhtml="http://www.w3.org/1999/xhtml"\n' )
|
||||
filestream.write( ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n' )
|
||||
filestream.write( ' xsi:schemaLocation="http://www.gbxml.org/schema"\n ' )
|
||||
filestream.write( ' temperatureUnit="C"\n' )
|
||||
filestream.write( ' lengthUnit="Meters"\n' )
|
||||
filestream.write( ' areaUnit="SquareMeters"\n' )
|
||||
filestream.write( ' volumeUnit="CubicMeters"\n' )
|
||||
filestream.write( ' useSIUnitsForResults="false" >\n' )
|
||||
filestream.write( '\n' )
|
||||
|
||||
# campus
|
||||
filestream.write( '<Campus id="%s">\n' % site.Name )
|
||||
filestream.write( '<Location>\n' )
|
||||
filestream.write( ' <ZipcodeOrPostalCode>%s</ZipcodeOrPostalCode>\n' % site.PostalCode )
|
||||
filestream.write( ' <Longitude>%f</Longitude>\n' % site.Longitude )
|
||||
filestream.write( ' <Latitude>%f</Latitude>\n' % site.Latitude )
|
||||
filestream.write( ' <Elevation>%f/Elevation>\n' % site.Elevation.Value )
|
||||
filestream.write( ' <Name>%s</Name>\n' % site.Label )
|
||||
#filestream.write( ' <CADModelAzimuth>0</CADModelAzimuth>\n' )
|
||||
#filestream.write( ' <StationId IDType="WMO">53158_2004</StationId>\n' )
|
||||
filestream.write( '</Location>\n' )
|
||||
|
||||
# building
|
||||
# buildings
|
||||
for building in site.Group:
|
||||
if Draft.getType(building) == "Building":
|
||||
area = 10000.0 # TODO calculate
|
||||
filestream.write( ' <Building id="$s" buildingType="$s">\n' % (building.Name,building.BuildingType) )
|
||||
filestream.write( ' <Area>$f</Area>\n' % area )
|
||||
|
||||
# space
|
||||
for space in Draft.getGroupContents(building):
|
||||
if Draft.getType(space) == "Space":
|
||||
zone = "BLABLA" # TODO build values
|
||||
filestream.write( ' <Space id="%s" spaceType="%s" zoneIdRef="%s">\n' % (space.Name, space.SpaceType, zone) )
|
||||
filestream.write( ' <Name>%s</Name>\n' % space.Label )
|
||||
filestream.write( ' <Description>%s</Description>\n' % space.Description )
|
||||
filestream.write( ' <Name>%s</Name>\n' % space.Label )
|
||||
#filestream.write( ' <PeopleNumber unit="NumberOfPeople">1.00000</PeopleNumber>\n' )
|
||||
#filestream.write( ' <LightPowerPerArea unit="WattPerSquareFoot">1.50000</LightPowerPerArea>\n' )
|
||||
#filestream.write( ' <EquipPowerPerArea unit="WattPerSquareFoot">0.00000</EquipPowerPerArea>\n' )
|
||||
filestream.write( ' <Area>$f</Area>\n' % space.Area
|
||||
filestream.write( ' <Area>$f</Area>\n' % str(building.Area.getValueAs("m^2")) )
|
||||
|
||||
# spaces
|
||||
for space in Draft.getObjectsOfType(Draft.getGroupContents(building.Group,addgroups=True),"Space"):
|
||||
if not space.Zone:
|
||||
FreeCAD.Console.PrintError(translate("Arch","Error: Space '%s' has no Zone. Aborting.\n") % space.Label)
|
||||
return
|
||||
filestream.write( ' <Space id="%s" spaceType="%s" zoneIdRef="%s" conditionType="%f">\n' % (space.Name, space.SpaceType, space.Zone.Name, space.Conditioning) )
|
||||
#filestream.write( ' <CADObjectId>%s</CADObjectId>\n' % space.Name ) # not sure what this is used for?
|
||||
filestream.write( ' <Name>%s</Name>\n' % space.Label )
|
||||
filestream.write( ' <Description>%s</Description>\n' % space.Description )
|
||||
filestream.write( ' <PeopleNumber unit="NumberOfPeople">%i</PeopleNumber>\n' % space.NumberOfPeople)
|
||||
filestream.write( ' <LightPowerPerArea unit="WattPerSquareMeter">%f</LightPowerPerArea>\n' % space.LightingPower/space.Area.getValueAs("m^2") )
|
||||
filestream.write( ' <EquipPowerPerArea unit="WattPerSquareMeter">%f</EquipPowerPerArea>\n' % space.EquipmentPower/space.Area.getValueAs("m^2") )
|
||||
filestream.write( ' <Area>$f</Area>\n' % space.Area.getValueAs("m^2") )
|
||||
filestream.write( ' <Volume>$f</Volume>\n' % FreeCAD.Units.Quantity(space.Shape.Volume,FreeCAD.Units.Volume).getValueAs("m^3") )
|
||||
filestream.write( ' <ShellGeometry id="%s_geometry">\n' % space.Name )
|
||||
|
||||
# shells
|
||||
for solid in space.Shape.Solids:
|
||||
filestream.write( ' <ClosedShell>\n' )
|
||||
for face in solid.Faces:
|
||||
filestream.write( ' <PolyLoop>\n' )
|
||||
for v in face.OuterWire.Vertexes:
|
||||
filestream.write( ' <CartesianPoint>\n' )
|
||||
filestream.write( ' <Coordinate>%f</Coordinate>\n' % v.Point.x )
|
||||
filestream.write( ' <Coordinate>%f</Coordinate>\n' % v.Point.y )
|
||||
filestream.write( ' <Coordinate>%f</Coordinate>\n' % v.Point.z )
|
||||
filestream.write( ' </CartesianPoint>\n' )
|
||||
filestream.write( ' </PolyLoop>\n' )
|
||||
filestream.write( ' </ClosedShell>\n' )
|
||||
filestream.write( ' </ShellGeometry>\n' )
|
||||
filestream.write( ' </Space>\n' )
|
||||
|
||||
# surfaces
|
||||
for i,face in enumerate(space.Shape.Faces):
|
||||
filestream.write( ' <SpaceBoundary isSecondLevelBoundary="false" surfaceIdRef="%s_Face%i"\n' % space.Name, i )
|
||||
filestream.write( ' <PlanarGeometry>\n' )
|
||||
filestream.write( ' <PolyLoop>\n' )
|
||||
for v in face.OuterWire.Vertexes:
|
||||
filestream.write( ' <CartesianPoint>\n' )
|
||||
filestream.write( ' <Coordinate>%f</Coordinate>\n' % v.Point.x )
|
||||
filestream.write( ' <Coordinate>%f</Coordinate>\n' % v.Point.y )
|
||||
filestream.write( ' <Coordinate>%f</Coordinate>\n' % v.Point.z )
|
||||
filestream.write( ' </CartesianPoint>\n' )
|
||||
filestream.write( ' </PolyLoop>\n' )
|
||||
filestream.write( ' </PlanarGeometry>\n' )
|
||||
filestream.write( ' </SpaceBoundary>\n' )
|
||||
|
||||
filestream.write( ' </Space>\n' )
|
||||
|
||||
filestream.write( ' </Building>\n' )
|
||||
|
||||
|
@ -127,6 +173,37 @@ def export(objectslist,filename):
|
|||
|
||||
</ClosedShell>
|
||||
</ShellGeometry>
|
||||
|
||||
<SpaceBoundary isSecondLevelBoundary="false" surfaceIdRef="aim1095">
|
||||
<PlanarGeometry>
|
||||
<PolyLoop>
|
||||
<CartesianPoint>
|
||||
<Coordinate>9.981497</Coordinate>
|
||||
<Coordinate>-31.19363</Coordinate>
|
||||
<Coordinate>0</Coordinate>
|
||||
</CartesianPoint>
|
||||
<CartesianPoint>
|
||||
<Coordinate>9.981497</Coordinate>
|
||||
<Coordinate>-5.193626</Coordinate>
|
||||
<Coordinate>0</Coordinate>
|
||||
</CartesianPoint>
|
||||
<CartesianPoint>
|
||||
<Coordinate>9.981497</Coordinate>
|
||||
<Coordinate>-5.193626</Coordinate>
|
||||
<Coordinate>100</Coordinate>
|
||||
</CartesianPoint>
|
||||
<CartesianPoint>
|
||||
<Coordinate>9.981497</Coordinate>
|
||||
<Coordinate>-31.19363</Coordinate>
|
||||
<Coordinate>100</Coordinate>
|
||||
</CartesianPoint>
|
||||
</PolyLoop>
|
||||
</PlanarGeometry>
|
||||
</SpaceBoundary>
|
||||
|
||||
|
||||
|
||||
|
||||
<CADObjectId>21E2</CADObjectId>
|
||||
</Space>
|
||||
|
||||
|
@ -393,6 +470,14 @@ def export(objectslist,filename):
|
|||
<DesignCoolT>80.00000</DesignCoolT>
|
||||
</Zone>
|
||||
|
||||
<DocumentHistory>
|
||||
<ProgramInfo id="adesk-rvt-1">
|
||||
<CompanyName>Autodesk, Inc.</CompanyName>
|
||||
<ProductName>Autodesk Project Vasari CEA</ProductName>
|
||||
<Version>TP2.0 20110514_1800</Version>
|
||||
<Platform>Microsoft Windows XP</Platform>
|
||||
</ProgramInfo>
|
||||
</DocumentHistory>
|
||||
|
||||
<Results xmlns="" id="sp3_LabandCorridor_Lab1" objectIdRef="sp3_LabandCorridor_Lab1" resultsType="CoolingLoad" unit="BtuPerHour">
|
||||
<ObjectId>sp3_LabandCorridor_Lab1</ObjectId>
|
||||
|
|
Loading…
Reference in New Issue
Block a user