def onChanged(self, obj, prop): ArchIFC.onChanged(obj, prop) if prop == "Terrain": if obj.Terrain: if FreeCAD.GuiUp: obj.Terrain.ViewObject.hide() self.execute(obj)
def onChanged(self,obj,prop): ArchIFC.onChanged(obj, prop) if prop == "Terrain": if obj.Terrain: if FreeCAD.GuiUp: obj.Terrain.ViewObject.hide() self.execute(obj)
def setProperties(self,obj): import ArchIFC ArchIFC.setProperties(obj) pl = obj.PropertiesList if not "Terrain" in pl: obj.addProperty("App::PropertyLink","Terrain","Site",QT_TRANSLATE_NOOP("App::Property","The base terrain of this site")) if not "Address" in pl: obj.addProperty("App::PropertyString","Address","Site",QT_TRANSLATE_NOOP("App::Property","The street and house number of this site, with postal box or apartment number if needed")) if not "PostalCode" in pl: obj.addProperty("App::PropertyString","PostalCode","Site",QT_TRANSLATE_NOOP("App::Property","The postal or zip code of this site")) if not "City" in pl: obj.addProperty("App::PropertyString","City","Site",QT_TRANSLATE_NOOP("App::Property","The city of this site")) if not "Region" in pl: obj.addProperty("App::PropertyString","Region","Site",QT_TRANSLATE_NOOP("App::Property","The region, province or county of this site")) if not "Country" in pl: obj.addProperty("App::PropertyString","Country","Site",QT_TRANSLATE_NOOP("App::Property","The country of this site")) if not "Latitude" in pl: obj.addProperty("App::PropertyFloat","Latitude","Site",QT_TRANSLATE_NOOP("App::Property","The latitude of this site")) if not "Longitude" in pl: obj.addProperty("App::PropertyFloat","Longitude","Site",QT_TRANSLATE_NOOP("App::Property","The latitude of this site")) if not "Declination" in pl: obj.addProperty("App::PropertyAngle","Declination","Site",QT_TRANSLATE_NOOP("App::Property","Angle between the true North and the North direction in this document")) if "NorthDeviation"in pl: obj.Declination = obj.NorthDeviation.Value obj.removeProperty("NorthDeviation") if not "Elevation" in pl: obj.addProperty("App::PropertyLength","Elevation","Site",QT_TRANSLATE_NOOP("App::Property","The elevation of level 0 of this site")) if not "Url" in pl: obj.addProperty("App::PropertyString","Url","Site",QT_TRANSLATE_NOOP("App::Property","A url that shows this site in a mapping website")) if not "Additions" in pl: obj.addProperty("App::PropertyLinkList","Additions","Site",QT_TRANSLATE_NOOP("App::Property","Other shapes that are appended to this object")) if not "Subtractions" in pl: obj.addProperty("App::PropertyLinkList","Subtractions","Site",QT_TRANSLATE_NOOP("App::Property","Other shapes that are subtracted from this object")) if not "ProjectedArea" in pl: obj.addProperty("App::PropertyArea","ProjectedArea","Site",QT_TRANSLATE_NOOP("App::Property","The area of the projection of this object onto the XY plane")) if not "Perimeter" in pl: obj.addProperty("App::PropertyLength","Perimeter","Site",QT_TRANSLATE_NOOP("App::Property","The perimeter length of this terrain")) if not "AdditionVolume" in pl: obj.addProperty("App::PropertyVolume","AdditionVolume","Site",QT_TRANSLATE_NOOP("App::Property","The volume of earth to be added to this terrain")) if not "SubtractionVolume" in pl: obj.addProperty("App::PropertyVolume","SubtractionVolume","Site",QT_TRANSLATE_NOOP("App::Property","The volume of earth to be removed from this terrain")) if not "ExtrusionVector" in pl: obj.addProperty("App::PropertyVector","ExtrusionVector","Site",QT_TRANSLATE_NOOP("App::Property","An extrusion vector to use when performing boolean operations")) obj.ExtrusionVector = FreeCAD.Vector(0,0,-100000) if not "RemoveSplitter" in pl: obj.addProperty("App::PropertyBool","RemoveSplitter","Site",QT_TRANSLATE_NOOP("App::Property","Remove splitters from the resulting shape")) if not "OriginOffset" in pl: obj.addProperty("App::PropertyVector","OriginOffset","Site",QT_TRANSLATE_NOOP("App::Property","An optional offset between the model (0,0,0) origin and the point indicated by the geocoordinates")) if not hasattr(obj,"Group"): obj.addExtension("App::GroupExtensionPython", self) if not "IfcType" in pl: obj.addProperty("App::PropertyEnumeration","IfcType","IFC",QT_TRANSLATE_NOOP("App::Property","The type of this object")) obj.IfcType = ArchIFC.IfcTypes obj.IcfType = "Site" self.Type = "Site"
def onChanged(self, obj, prop): ArchIFC.onChanged(obj, prop) ArchFloor._Floor.onChanged(self, obj, prop) if prop == "Terrain": if obj.Terrain: if FreeCAD.GuiUp: obj.Terrain.ViewObject.hide() self.execute(obj) if prop in ["UpdateDeclination", "CompassRotation", "Placement"]: self.updateDeclination()
def setProperties(self, obj): ArchIFC.setProperties(obj) pl = obj.PropertiesList if not "Height" in pl: obj.addProperty( "App::PropertyLength", "Height", "BuildingPart", QT_TRANSLATE_NOOP("App::Property", "The height of this object")) if not "LevelOffset" in pl: obj.addProperty( "App::PropertyLength", "LevelOffset", "BuildingPart", QT_TRANSLATE_NOOP( "App::Property", "The level of the (0,0,0) point of this level")) if not "Area" in pl: obj.addProperty( "App::PropertyArea", "Area", "BuildingPart", QT_TRANSLATE_NOOP("App::Property", "The computed floor area of this floor")) if not "IfcRole" in pl: obj.addProperty( "App::PropertyEnumeration", "IfcRole", "Component", QT_TRANSLATE_NOOP("App::Property", "The role of this object")) import ArchComponent obj.IfcRole = ArchComponent.IfcRoles if not "Description" in pl: obj.addProperty( "App::PropertyString", "Description", "Component", QT_TRANSLATE_NOOP( "App::Property", "An optional description for this component")) if not "Tag" in pl: obj.addProperty( "App::PropertyString", "Tag", "Component", QT_TRANSLATE_NOOP("App::Property", "An optional tag for this component")) if not "IfcAttributes" in pl: obj.addProperty( "App::PropertyMap", "IfcAttributes", "Component", QT_TRANSLATE_NOOP("App::Property", "Custom IFC properties and attributes")) if not "Shape" in pl: obj.addProperty( "Part::PropertyPartShape", "Shape", "BuildingPart", QT_TRANSLATE_NOOP("App::Property", "The shape of this object")) if not "IfcProperties" in pl: obj.addProperty( "App::PropertyMap", "IfcProperties", "Component", QT_TRANSLATE_NOOP("App::Property", "Stores IFC properties")) self.Type = "BuildingPart"
def onChanged(self, obj, prop): ArchIFC.onChanged(obj, prop) if prop == "Height": for child in obj.Group: if Draft.getType(child) in ["Wall", "Structure"]: if not child.Height.Value: #print("Executing ",child.Label) child.Proxy.execute(child) elif prop == "Placement": if hasattr(self, "oldPlacement"): if self.oldPlacement: deltap = obj.Placement.Base.sub(self.oldPlacement.Base) if deltap.Length == 0: deltap = None v = FreeCAD.Vector(0, 0, 1) deltar = FreeCAD.Rotation( self.oldPlacement.Rotation.multVec(v), obj.Placement.Rotation.multVec(v)) #print "Rotation",deltar.Axis,deltar.Angle if deltar.Angle < 0.0001: deltar = None for child in obj.Group: if ((not hasattr(child, "MoveWithHost")) or child.MoveWithHost) and hasattr( child, "Placement"): #print "moving ",child.Label if deltar: #child.Placement.Rotation = child.Placement.Rotation.multiply(deltar) - not enough, child must also move # use shape methods to obtain a correct placement import Part, math shape = Part.Shape() shape.Placement = child.Placement #print("angle before rotation:",shape.Placement.Rotation.Angle) #print("rotation angle:",math.degrees(deltar.Angle)) shape.rotate( DraftVecUtils.tup(obj.Placement.Base), DraftVecUtils.tup(deltar.Axis), math.degrees(deltar.Angle)) #print("angle after rotation:",shape.Placement.Rotation.Angle) child.Placement = shape.Placement if deltap: child.Placement.move(deltap) elif prop == "Group": obj.Area = self.getArea(obj)
def setProperties(self, obj): ArchIFC.setProperties(obj) pl = obj.PropertiesList if not "Height" in pl: obj.addProperty( "App::PropertyLength", "Height", "BuildingPart", QT_TRANSLATE_NOOP("App::Property", "The height of this object")) if not "LevelOffset" in pl: obj.addProperty( "App::PropertyLength", "LevelOffset", "BuildingPart", QT_TRANSLATE_NOOP( "App::Property", "The level of the (0,0,0) point of this level")) if not "Area" in pl: obj.addProperty( "App::PropertyArea", "Area", "BuildingPart", QT_TRANSLATE_NOOP("App::Property", "The computed floor area of this floor")) if not "Description" in pl: obj.addProperty( "App::PropertyString", "Description", "Component", QT_TRANSLATE_NOOP( "App::Property", "An optional description for this component")) if not "Tag" in pl: obj.addProperty( "App::PropertyString", "Tag", "Component", QT_TRANSLATE_NOOP("App::Property", "An optional tag for this component")) if not "Shape" in pl: obj.addProperty( "Part::PropertyPartShape", "Shape", "BuildingPart", QT_TRANSLATE_NOOP("App::Property", "The shape of this object")) if not "SavedInventor" in pl: obj.addProperty( "App::PropertyFileIncluded", "SavedInventor", "BuildingPart", QT_TRANSLATE_NOOP( "App::Property", "This property stores an inventor representation for this object" )) obj.setEditorMode("SavedInventor", 2) self.Type = "BuildingPart"
def setProperties(self,obj): ArchIFC.setProperties(obj) pl = obj.PropertiesList if not "Height" in pl: obj.addProperty("App::PropertyLength","Height","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The height of this object")) if not "LevelOffset" in pl: obj.addProperty("App::PropertyLength","LevelOffset","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The level of the (0,0,0) point of this level")) if not "Area" in pl: obj.addProperty("App::PropertyArea","Area", "BuildingPart",QT_TRANSLATE_NOOP("App::Property","The computed floor area of this floor")) if not "Description" in pl: obj.addProperty("App::PropertyString","Description","Component",QT_TRANSLATE_NOOP("App::Property","An optional description for this component")) if not "Tag" in pl: obj.addProperty("App::PropertyString","Tag","Component",QT_TRANSLATE_NOOP("App::Property","An optional tag for this component")) if not "Shape" in pl: obj.addProperty("Part::PropertyPartShape","Shape","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The shape of this object")) self.Type = "BuildingPart"
def onChanged(self,obj,prop): ArchIFC.onChanged(obj, prop) if prop == "Height": for child in obj.Group: if Draft.getType(child) in ["Wall","Structure"]: if not child.Height.Value: #print("Executing ",child.Label) child.Proxy.execute(child) elif prop == "Placement": if hasattr(self,"oldPlacement"): if self.oldPlacement: deltap = obj.Placement.Base.sub(self.oldPlacement.Base) if deltap.Length == 0: deltap = None v = FreeCAD.Vector(0,0,1) deltar = FreeCAD.Rotation(self.oldPlacement.Rotation.multVec(v),obj.Placement.Rotation.multVec(v)) #print "Rotation",deltar.Axis,deltar.Angle if deltar.Angle < 0.0001: deltar = None for child in obj.Group: if ((not hasattr(child,"MoveWithHost")) or child.MoveWithHost) and hasattr(child,"Placement"): #print "moving ",child.Label if deltar: #child.Placement.Rotation = child.Placement.Rotation.multiply(deltar) - not enough, child must also move # use shape methods to obtain a correct placement import Part,math shape = Part.Shape() shape.Placement = child.Placement #print("angle before rotation:",shape.Placement.Rotation.Angle) #print("rotation angle:",math.degrees(deltar.Angle)) shape.rotate(DraftVecUtils.tup(obj.Placement.Base), DraftVecUtils.tup(deltar.Axis), math.degrees(deltar.Angle)) #print("angle after rotation:",shape.Placement.Rotation.Angle) child.Placement = shape.Placement if deltap: child.Placement.move(deltap)
def setAttributes(obj, ifcproduct): """sets the IFC attributes of a component""" ifctype = ArchIFC.uncamel(ifcproduct.is_a()) if ifcproduct.Name: obj.Label = ifcproduct.Name if ifctype in ArchIFC.IfcTypes: obj.IfcType = ifctype for attr in dir(ifcproduct): if attr in obj.PropertiesList: value = getattr(ifcproduct, attr) if value: try: setattr(obj, attr, value) except Exception: pass