Example #1
0
 def GetResources(self):
     return {'Pixmap'  : 'Arch_Panel',
             'MenuText': QT_TRANSLATE_NOOP("Arch_Panel","Panel"),
             'Accel': "P, A",
             'ToolTip': QT_TRANSLATE_NOOP("Arch_Panel","Creates a panel object from scratch or from a selected object (sketch, wire, face or solid)")}
Example #2
0
    def setProperties(self, obj):
        """Gives the object properties unique to sites.

        Adds the IFC product properties, and sites' unique properties like
        Terrain.

        You can learn more about properties here:
        https://wiki.freecadweb.org/property
        """

        ArchIFC.IfcProduct.setProperties(self, 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")
        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"
        if not "TimeZone" in pl:
            obj.addProperty(
                "App::PropertyInteger", "TimeZone", "Site",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The time zone where this site is located"))
        if not "EPWFile" in pl:
            obj.addProperty(
                "App::PropertyFileIncluded", "EPWFile", "Site",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "An optional EPW File for the location of this site. Refer to the Site documentation to know how to obtain one"
                ))
        self.Type = "Site"
Example #3
0
def convertFloors(floor=None):

    """convert the given Floor or Building (or all Arch Floors from the active document if none is given) into BuildingParts"""

    todel = []
    if floor:
        objset = [floor]
    else:
        objset = FreeCAD.ActiveDocument.Objects
    for obj in objset:
        if Draft.getType(obj) in ["Floor","Building"]:
            nobj = makeBuildingPart(obj.Group)
            if Draft.getType(obj) == "Floor":
                nobj.IfcType = "Building Storey"
            else:
                nobj.IfcType = "Building"
                nobj.addProperty("App::PropertyEnumeration","BuildingType","Building",QT_TRANSLATE_NOOP("App::Property","The type of this building"))
                nobj.BuildingType = BuildingTypes
            label = obj.Label
            for parent in obj.InList:
                if hasattr(parent,"Group"):
                    if obj in parent.Group:
                        parent.addObject(nobj)
                        #g = parent.Group
                        #g.append(nobj)
                        #parent.Group = g
                else:
                    print("Warning: couldn't add new object '"+label+"' to parent object '"+parent.Label+"'")
            todel.append(obj.Name)
            if obj.ViewObject:
                obj.ViewObject.Proxy.Object = None # some bug makes this trigger even efter the object has been deleted...
            obj.Label = obj.Label+" to delete" # in case FreeCAD doesn't allow 2 objs with same label
            nobj.Label = label
    for n in todel:
        from DraftGui import todo
        todo.delay(FreeCAD.ActiveDocument.removeObject,n)
Example #4
0
    def setProperties(self, obj):

        # http://en.wikipedia.org/wiki/Stairs

        pl = obj.PropertiesList

        # base properties
        if not "Length" in pl:
            obj.addProperty(
                "App::PropertyLength", "Length", "Stairs",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The length of these stairs, if no baseline is defined"))
        if not "Width" in pl:
            obj.addProperty(
                "App::PropertyLength", "Width", "Stairs",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The width of these stairs"))
        if not "Height" in pl:
            obj.addProperty(
                "App::PropertyLength", "Height", "Stairs",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The total height of these stairs"))
        if not "Align" in pl:
            obj.addProperty(
                "App::PropertyEnumeration", "Align", "Stairs",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The alignment of these stairs on their baseline, if applicable"
                ))
            obj.Align = ['Left', 'Right', 'Center']

        # steps properties
        if not "NumberOfSteps" in pl:
            obj.addProperty(
                "App::PropertyInteger", "NumberOfSteps", "Steps",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The number of risers in these stairs"))
        if not "TreadDepth" in pl:
            obj.addProperty(
                "App::PropertyLength", "TreadDepth", "Steps",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The depth of the treads of these stairs"))
            obj.setEditorMode("TreadDepth", 1)
        if not "RiserHeight" in pl:
            obj.addProperty(
                "App::PropertyLength", "RiserHeight", "Steps",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The height of the risers of these stairs"))
            obj.setEditorMode("RiserHeight", 1)
        if not "Nosing" in pl:
            obj.addProperty(
                "App::PropertyLength", "Nosing", "Steps",
                QT_TRANSLATE_NOOP("App::Property", "The size of the nosing"))
        if not "TreadThickness" in pl:
            obj.addProperty(
                "App::PropertyLength", "TreadThickness", "Steps",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The thickness of the treads"))
        if not "BlondelRatio" in pl:
            obj.addProperty(
                "App::PropertyFloat", "BlondelRatio", "Steps",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The Blondel ratio indicates comfortable stairs and should be between 62 and 64cm or 24.5 and 25.5in"
                ))
            obj.setEditorMode("BlondelRatio", 1)
        if not hasattr(obj, "LandingDepth"):
            obj.addProperty(
                "App::PropertyLength", "LandingDepth", "Steps",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The depth of the landing of these stairs"))

        # structural properties
        if not "Landings" in pl:
            obj.addProperty(
                "App::PropertyEnumeration", "Landings", "Structure",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The type of landings of these stairs"))
            obj.Landings = ["None", "At center", "At each corner"]
        if not "Winders" in pl:
            obj.addProperty(
                "App::PropertyEnumeration", "Winders", "Structure",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The type of winders in these stairs"))
            obj.Winders = ["None", "All", "Corners strict", "Corners relaxed"]
        if not "Structure" in pl:
            obj.addProperty(
                "App::PropertyEnumeration", "Structure", "Structure",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The type of structure of these stairs"))
            obj.Structure = [
                "None", "Massive", "One stringer", "Two stringers"
            ]
        if not "StructureThickness" in pl:
            obj.addProperty(
                "App::PropertyLength", "StructureThickness", "Structure",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The thickness of the massive structure or of the stringers"
                ))
        if not "StringerWidth" in pl:
            obj.addProperty(
                "App::PropertyLength", "StringerWidth", "Structure",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The width of the stringers"))
        if not "StructureOffset" in pl:
            obj.addProperty(
                "App::PropertyLength", "StructureOffset", "Structure",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The offset between the border of the stairs and the structure"
                ))
        if not "StringerOverlap" in pl:
            obj.addProperty(
                "App::PropertyLength", "StringerOverlap", "Structure",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The overlap of the stringers above the bottom of the treads"
                ))

        self.Type = "Stairs"
Example #5
0
            else:
                if FreeCAD.activeDraftCommand.featureName == translate(
                        "draft", "Line"):
                    # BUG: line subcommands are not usable while another command is active
                    self.appendContextMenu("", self.line_commands)
        else:
            if FreeCADGui.Selection.getSelection():
                self.appendContextMenu("Utilities", self.context_commands)

    def GetClassName(self):
        """Type of workbench."""
        return "Gui::PythonWorkbench"


FreeCADGui.addWorkbench(DraftWorkbench)

# Preference pages for importing and exporting various file formats
# are independent of the loading of the workbench and can be loaded at startup
import Draft_rc
from PySide.QtCore import QT_TRANSLATE_NOOP
FreeCADGui.addPreferencePage(":/ui/preferences-dxf.ui",
                             QT_TRANSLATE_NOOP("Draft", "Import-Export"))
FreeCADGui.addPreferencePage(":/ui/preferences-dwg.ui",
                             QT_TRANSLATE_NOOP("Draft", "Import-Export"))
FreeCADGui.addPreferencePage(":/ui/preferences-svg.ui",
                             QT_TRANSLATE_NOOP("Draft", "Import-Export"))
FreeCADGui.addPreferencePage(":/ui/preferences-oca.ui",
                             QT_TRANSLATE_NOOP("Draft", "Import-Export"))

FreeCAD.__unit_test__ += ["TestDraft"]
Example #6
0
    def add_parameter(self, kind, name, category, description):

        return self.Object.addProperty(kind, name, category, QT_TRANSLATE_NOOP("App::Property", description))
Example #7
0
 def set_properties(self, vobj):
     pl = vobj.PropertiesList
     d = 0
     if "DisplaySize" in pl:
         d = vobj.DisplaySize.Value
         vobj.removeProperty("DisplaySize")
     if not "DisplayLength" in pl:
         vobj.addProperty(
             "App::PropertyLength", "DisplayLength", "SectionPlane",
             QT_TRANSLATE_NOOP("App::Property",
                               "The display length of this section plane"))
         if d:
             vobj.DisplayLength = d
         else:
             vobj.DisplayLength = 1000
     if not "DisplayHeight" in pl:
         vobj.addProperty(
             "App::PropertyLength", "DisplayHeight", "SectionPlane",
             QT_TRANSLATE_NOOP("App::Property",
                               "The display height of this section plane"))
         if d:
             vobj.DisplayHeight = d
         else:
             vobj.DisplayHeight = 1000
     if not "ArrowSize" in pl:
         vobj.addProperty(
             "App::PropertyLength", "ArrowSize", "SectionPlane",
             QT_TRANSLATE_NOOP(
                 "App::Property",
                 "The size of the arrows of this section plane"))
         vobj.ArrowSize = 50
     if not "Transparency" in pl:
         vobj.addProperty(
             "App::PropertyPercent", "Transparency", "SectionPlane",
             QT_TRANSLATE_NOOP("App::Property",
                               "The transparency of this object"))
         vobj.Transparency = 85
     if not "LineWidth" in pl:
         vobj.addProperty(
             "App::PropertyFloat", "LineWidth", "SectionPlane",
             QT_TRANSLATE_NOOP("App::Property",
                               "The line width of this object"))
         vobj.LineWidth = 1
     if not "CutDistance" in pl:
         vobj.addProperty(
             "App::PropertyLength", "CutDistance", "SectionPlane",
             QT_TRANSLATE_NOOP("App::Property",
                               "Show the cut in the 3D view"))
     if not "LineColor" in pl:
         vobj.addProperty(
             "App::PropertyColor", "LineColor", "SectionPlane",
             QT_TRANSLATE_NOOP("App::Property", "The color of this object"))
         #vobj.LineColor = ArchCommands.getDefaultColor("Helpers")
     if not "CutView" in pl:
         vobj.addProperty(
             "App::PropertyBool", "CutView", "SectionPlane",
             QT_TRANSLATE_NOOP("App::Property",
                               "Show the cut in the 3D view"))
     if not "CutMargin" in pl:
         vobj.addProperty(
             "App::PropertyLength", "CutMargin", "SectionPlane",
             QT_TRANSLATE_NOOP(
                 "App::Property",
                 "The distance between the cut plane and the actual view cut (keep this a very small value but not zero)"
             ))
         vobj.CutMargin = 1
Example #8
0
 def __init__(self,obj, profile):
     obj.addProperty("App::PropertyLength","Width","Draft",QT_TRANSLATE_NOOP("App::Property","Width of the beam")).Width = profile[4]
     obj.addProperty("App::PropertyLength","Height","Draft",QT_TRANSLATE_NOOP("App::Property","Height of the beam")).Height = profile[5]
     obj.addProperty("App::PropertyLength","WebThickness","Draft",QT_TRANSLATE_NOOP("App::Property","Thickness of the webs")).WebThickness = profile[6]
     obj.addProperty("App::PropertyLength","FlangeThickness","Draft",QT_TRANSLATE_NOOP("App::Property","Thickness of the flange")).FlangeThickness = profile[7]
     _Profile.__init__(self,obj,profile)
Example #9
0
    def __init__(self, obj):
        super(Block, self).__init__(obj, "Block")

        _tip = QT_TRANSLATE_NOOP("App::Property",
                                 "The components of this block")
        obj.addProperty("App::PropertyLinkList", "Components", "Draft", _tip)
Example #10
0
 def __init__(self,obj, profile):
     obj.addProperty("App::PropertyLength","OutDiameter","Draft",QT_TRANSLATE_NOOP("App::Property","Outside Diameter")).OutDiameter = profile[4]
     obj.addProperty("App::PropertyLength","Thickness","Draft",QT_TRANSLATE_NOOP("App::Property","Wall thickness")).Thickness = profile[5]
     _Profile.__init__(self,obj,profile)
Example #11
0
 def __init__(self,obj, profile):
     obj.addProperty("App::PropertyLength","Width","Draft",QT_TRANSLATE_NOOP("App::Property","Width of the beam")).Width = profile[4]
     obj.addProperty("App::PropertyLength","Height","Draft",QT_TRANSLATE_NOOP("App::Property","Height of the beam")).Height = profile[5]
     _Profile.__init__(self,obj,profile)
Example #12
0
    def GetResources(self):

        return {'Pixmap'  : 'Arch_Profile',
                'MenuText': QT_TRANSLATE_NOOP("Arch_Profile","Profile"),
                'Accel': "P, F",
                'ToolTip': QT_TRANSLATE_NOOP("Arch_Profile","Creates a profile object")}
Example #13
0
class Camera:
    """A camera for rendering.

    This object allows to record camera settings from the Coin camera, and to
    reuse them for rendering.

    Camera Orientation is defined by a Rotation Axis and a Rotation Angle,
    applied to 'default camera'.
    Default camera looks from (0,0,1) towards the origin (target is (0,0,-1),
    and the up direction is (0,1,0).

    For more information, see Coin documentation, Camera section.
    <https://developer.openinventor.com/UserGuides/Oiv9/Inventor_Mentor/Cameras_and_Lights/Cameras.html>
    """

    # Enumeration of allowed values for ViewportMapping parameter (see Coin
    # documentation)
    # Nota: Keep following tuple in original order, as relationship between
    # values and indexes matters and is used for reverse transcoding
    VIEWPORTMAPPINGENUM = ("CROP_VIEWPORT_FILL_FRAME",
                           "CROP_VIEWPORT_LINE_FRAME",
                           "CROP_VIEWPORT_NO_FRAME", "ADJUST_CAMERA",
                           "LEAVE_ALONE")

    Prop = namedtuple('Prop', ['Type', 'Group', 'Doc', 'Default'])

    # FeaturePython object properties
    PROPERTIES = {
        "Projection":
        Prop(
            "App::PropertyEnumeration", "Camera",
            QT_TRANSLATE_NOOP("Render",
                              "Type of projection: Perspective/Orthographic"),
            ("Perspective", "Orthographic")),
        "Placement":
        Prop("App::PropertyPlacement", "",
             QT_TRANSLATE_NOOP("Render", "Placement of camera"),
             App.Placement(App.Vector(0, 0, 0), App.Vector(0, 0, 1), 0)),
        "ViewportMapping":
        Prop("App::PropertyEnumeration", "Camera",
             QT_TRANSLATE_NOOP("Render", "(See Coin documentation)"),
             VIEWPORTMAPPINGENUM),
        "AspectRatio":
        Prop("App::PropertyFloat", "Camera",
             QT_TRANSLATE_NOOP("Render", "Ratio width/height of the camera."),
             1.0),
        "NearDistance":
        Prop("App::PropertyDistance", "Camera",
             QT_TRANSLATE_NOOP("Render", "Near distance, for clipping"), 0.0),
        "FarDistance":
        Prop("App::PropertyDistance", "Camera",
             QT_TRANSLATE_NOOP("Render", "Far distance, for clipping"), 200.0),
        "FocalDistance":
        Prop("App::PropertyDistance", "Camera",
             QT_TRANSLATE_NOOP("Render", "Focal distance"), 100.0),
        "Height":
        Prop("App::PropertyLength", "Camera",
             QT_TRANSLATE_NOOP("Render", "Height, for orthographic camera"),
             5.0),
        "HeightAngle":
        Prop(
            "App::PropertyAngle", "Camera",
            QT_TRANSLATE_NOOP(
                "Render", "Height angle, for perspective camera, in"
                "degrees. Important: This value will be sent as "
                "'Field of View' to the renderers."), 60),
    }
    # ~FeaturePython object properties

    _fpos = dict()  # FeaturePython objects

    @classmethod
    def set_properties(cls, fpo):
        """Set underlying FeaturePython object's properties."""
        for name in cls.PROPERTIES.keys() - set(fpo.PropertiesList):
            spec = cls.PROPERTIES[name]
            prop = fpo.addProperty(spec.Type, name, spec.Group, spec.Doc, 0)
            setattr(prop, name, spec.Default)

    def __init__(self, fpo):
        """Initialize Camera.

        Args:
            fpo -- A FeaturePython object created with FreeCAD.addObject.
        """
        self.type = "Camera"
        fpo.Proxy = self
        self.fpo = fpo
        self.set_properties(fpo)

    @property
    def fpo(self):
        """Get underlying FeaturePython object."""
        return self._fpos[id(self)]

    @fpo.setter
    def fpo(self, new_fpo):
        """Set underlying FeaturePython object attribute."""
        self._fpos[id(self)] = new_fpo

    @staticmethod
    def create(document=None):
        """Create a Camera object in a document.

        Factory method to create a new camera object.
        The camera is created into the active document (default).
        Optionally, it is possible to specify a target document, in which case
        the camera is created in the given document.

        If Gui is up, the camera is initialized to current active camera;
        otherwise it is set to DEFAULT_CAMERA_STRING.
        This method also create the FeaturePython and the ViewProviderCamera
        related objects.

        Args:
            document -- The document where to create the camera (optional).

        Returns:
            The newly created Camera, the FeaturePython and the
            ViewProviderCamera objects.
        """
        doc = document if document else App.ActiveDocument
        fpo = doc.addObject("App::FeaturePython", "Camera")
        cam = Camera(fpo)
        viewp = ViewProviderCamera(fpo.ViewObject)
        if App.GuiUp:
            viewp.set_camera_from_gui()
        else:
            set_cam_from_coin_string(fpo, DEFAULT_CAMERA_STRING)
        App.ActiveDocument.recompute()
        return cam, fpo, viewp

    def onDocumentRestored(self, fpo):
        """Respond to document restoration event (callback)."""
        self.type = "Camera"
        fpo.Proxy = self
        self.fpo = fpo
        self.set_properties(fpo)

    def execute(self, fpo):
        # pylint: disable=no-self-use
        """Respond to document recomputation event (callback, mandatory)."""

    def point_at(self, point):
        """Make camera point at a given target point.

        Args:
            point -- Geometrical point to point at (having x, y, z properties).
        """
        fpo = self.fpo
        current_target = fpo.Placement.Rotation.multVec(App.Vector(0, 0, -1))
        base = fpo.Placement.Base
        new_target = App.Vector(point.x - base.x, point.y - base.y,
                                point.z - base.z)
        axis = current_target.cross(new_target)
        if not axis.Length:
            # Don't try to rotate if axis is a null vector...
            return
        angle = degrees(new_target.getAngle(current_target))
        rotation = App.Rotation(axis, angle)

        fpo.Placement.Rotation = rotation.multiply(fpo.Placement.Rotation)
Example #14
0
    def setProperties(self,vobj):

        pl = vobj.PropertiesList
        if not "LineWidth" in pl:
            vobj.addProperty("App::PropertyFloat","LineWidth","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The line width of this object"))
            vobj.LineWidth = 1
        if not "OverrideUnit" in pl:
            vobj.addProperty("App::PropertyString","OverrideUnit","BuildingPart",QT_TRANSLATE_NOOP("App::Property","An optional unit to express levels"))
        if not "DisplayOffset" in pl:
            vobj.addProperty("App::PropertyPlacement","DisplayOffset","BuildingPart",QT_TRANSLATE_NOOP("App::Property","A transformation to apply to the level mark"))
        if not "ShowLevel" in pl:
            vobj.addProperty("App::PropertyBool","ShowLevel","BuildingPart",QT_TRANSLATE_NOOP("App::Property","If true, show the level"))
            vobj.ShowLevel = True
        if not "ShowUnit" in pl:
            vobj.addProperty("App::PropertyBool","ShowUnit","BuildingPart",QT_TRANSLATE_NOOP("App::Property","If true, show the unit on the level tag"))
        if not "SetWorkingPlane" in pl:
            vobj.addProperty("App::PropertyBool","SetWorkingPlane","BuildingPart",QT_TRANSLATE_NOOP("App::Property","If true, when activated, the working plane will automatically adapt to this level"))
            vobj.SetWorkingPlane = True
        if not "OriginOffset" in pl:
            vobj.addProperty("App::PropertyBool","OriginOffset","BuildingPart",QT_TRANSLATE_NOOP("App::Property","If true, when activated, Display offset will affect the origin mark too"))
        if not "ShowLabel" in pl:
            vobj.addProperty("App::PropertyBool","ShowLabel","BuildingPart",QT_TRANSLATE_NOOP("App::Property","If true, when activated, the object's label is displayed"))
            vobj.ShowLabel = True
        if not "FontName" in pl:
            vobj.addProperty("App::PropertyFont","FontName","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The font to be used for texts"))
            vobj.FontName = Draft.getParam("textfont","Arial")
        if not "FontSize" in pl:
            vobj.addProperty("App::PropertyLength","FontSize","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The font size of texts"))
            vobj.FontSize = Draft.getParam("textheight",2.0)
        if not "ViewData" in pl:
            vobj.addProperty("App::PropertyFloatList","ViewData","BuildingPart",QT_TRANSLATE_NOOP("App::Property","Camera position data associated with this object"))
        if not "RestoreView" in pl:
            vobj.addProperty("App::PropertyBool","RestoreView","BuildingPart",QT_TRANSLATE_NOOP("App::Property","If set, the view stored in this object will be restored on double-click"))
        if not "DiffuseColor" in pl:
            vobj.addProperty("App::PropertyColorList","DiffuseColor","BuildingPart",QT_TRANSLATE_NOOP("App::Property","The individual face colors"))
Example #15
0
    def setProperties(self, obj):

        pl = obj.PropertiesList
        if not "Boundaries" in pl:
            obj.addProperty(
                "App::PropertyLinkSubList", "Boundaries", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The objects that make the boundaries of this space object"
                ))
        if not "Area" in pl:
            obj.addProperty(
                "App::PropertyArea", "Area", "Space",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The computed floor area of this space"))
        if not "FinishFloor" in pl:
            obj.addProperty(
                "App::PropertyString", "FinishFloor", "Space",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The finishing of the floor of this space"))
        if not "FinishWalls" in pl:
            obj.addProperty(
                "App::PropertyString", "FinishWalls", "Space",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The finishing of the walls of this space"))
        if not "FinishCeiling" in pl:
            obj.addProperty(
                "App::PropertyString", "FinishCeiling", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The finishing of the ceiling of this space"))
        if not "Group" in pl:
            obj.addProperty(
                "App::PropertyLinkList", "Group", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "Objects that are included inside this space, such as furniture"
                ))
        if not "SpaceType" in pl:
            obj.addProperty(
                "App::PropertyEnumeration", "SpaceType", "Space",
                QT_TRANSLATE_NOOP("App::Property", "The type of this space"))
            obj.SpaceType = SpaceTypes
        if not "FloorThickness" in pl:
            obj.addProperty(
                "App::PropertyLength", "FloorThickness", "Space",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The thickness of the floor finish"))
        if not "NumberOfPeople" in pl:
            obj.addProperty(
                "App::PropertyInteger", "NumberOfPeople", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The number of people who typically occupy this space"))
        if not "LightingPower" in pl:
            obj.addProperty(
                "App::PropertyFloat", "LightingPower", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The electric power needed to light this space in Watts"))
        if not "EquipmentPower" in pl:
            obj.addProperty(
                "App::PropertyFloat", "EquipmentPower", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The electric power needed by the equipment of this space in Watts"
                ))
        if not "AutoPower" in pl:
            obj.addProperty(
                "App::PropertyBool", "AutoPower", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "If True, Equipment Power will be automatically filled by the equipment included in this space"
                ))
        if not "Conditioning" in pl:
            obj.addProperty(
                "App::PropertyEnumeration", "Conditioning", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The type of air conditioning of this space"))
            obj.Conditioning = ConditioningTypes
        if not "Internal" in pl:
            obj.addProperty(
                "App::PropertyBool", "Internal", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "Specifies if this space is internal or external"))
            obj.Internal = True
        self.Type = "Space"
        obj.setEditorMode("HorizontalArea", 2)
Example #16
0
    def setProperties(self, vobj):

        pl = vobj.PropertiesList
        if not "LineWidth" in pl:
            vobj.addProperty(
                "App::PropertyFloat", "LineWidth", "BuildingPart",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The line width of this object"))
            vobj.LineWidth = 1
        if not "OverrideUnit" in pl:
            vobj.addProperty(
                "App::PropertyString", "OverrideUnit", "BuildingPart",
                QT_TRANSLATE_NOOP("App::Property",
                                  "An optional unit to express levels"))
        if not "DisplayOffset" in pl:
            vobj.addProperty(
                "App::PropertyPlacement", "DisplayOffset", "BuildingPart",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "A transformation to apply to the level mark"))
            vobj.DisplayOffset = FreeCAD.Placement(
                FreeCAD.Vector(0, 0, 0),
                FreeCAD.Rotation(FreeCAD.Vector(1, 0, 0), 90))
        if not "ShowLevel" in pl:
            vobj.addProperty(
                "App::PropertyBool", "ShowLevel", "BuildingPart",
                QT_TRANSLATE_NOOP("App::Property", "If true, show the level"))
            vobj.ShowLevel = True
        if not "ShowUnit" in pl:
            vobj.addProperty(
                "App::PropertyBool", "ShowUnit", "BuildingPart",
                QT_TRANSLATE_NOOP("App::Property",
                                  "If true, show the unit on the level tag"))
        if not "OriginOffset" in pl:
            vobj.addProperty(
                "App::PropertyBool", "OriginOffset", "BuildingPart",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "If true, display offset will affect the origin mark too"))
        if not "ShowLabel" in pl:
            vobj.addProperty(
                "App::PropertyBool", "ShowLabel", "BuildingPart",
                QT_TRANSLATE_NOOP("App::Property",
                                  "If true, the object's label is displayed"))
            vobj.ShowLabel = True
        if not "FontName" in pl:
            vobj.addProperty(
                "App::PropertyFont", "FontName", "BuildingPart",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The font to be used for texts"))
            vobj.FontName = Draft.getParam("textfont", "Arial")
        if not "FontSize" in pl:
            vobj.addProperty(
                "App::PropertyLength", "FontSize", "BuildingPart",
                QT_TRANSLATE_NOOP("App::Property", "The font size of texts"))
            vobj.FontSize = Draft.getParam("textheight", 2.0)
        if not "DiffuseColor" in pl:
            vobj.addProperty(
                "App::PropertyColorList", "DiffuseColor", "BuildingPart",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The individual face colors"))

        # Interaction properties
        if not "SetWorkingPlane" in pl:
            vobj.addProperty(
                "App::PropertyBool", "SetWorkingPlane", "Interaction",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "If true, when activated, the working plane will automatically adapt to this level"
                ))
            vobj.SetWorkingPlane = True
        if not "AutoWorkingPlane" in pl:
            vobj.addProperty(
                "App::PropertyBool", "AutoWorkingPlane", "Interaction",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "If set to True, the working plane will be kept on Auto mode"
                ))
        if not "ViewData" in pl:
            vobj.addProperty(
                "App::PropertyFloatList", "ViewData", "Interaction",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "Camera position data associated with this object"))
            vobj.setEditorMode("ViewData", 2)
        if not "RestoreView" in pl:
            vobj.addProperty(
                "App::PropertyBool", "RestoreView", "Interaction",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "If set, the view stored in this object will be restored on double-click"
                ))
        if not "DoubleClickActivates" in pl:
            vobj.addProperty(
                "App::PropertyBool", "DoubleClickActivates", "Interaction",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "If True, double-clicking this object in the tree activates it"
                ))

        # inventor saving
        if not "SaveInventor" in pl:
            vobj.addProperty(
                "App::PropertyBool", "SaveInventor", "Interaction",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "If this is enabled, the inventor representation of this object will be saved in the FreeCAD file, allowing to reference it in other files in lightweight mode."
                ))
        if not "SavedInventor" in pl:
            vobj.addProperty(
                "App::PropertyFileIncluded", "SavedInventor", "Interaction",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "A slot to save the inventor representation of this object, if enabled"
                ))
            vobj.setEditorMode("SavedInventor", 2)

        # children properties
        if not "ChildrenOverride" in pl:
            vobj.addProperty(
                "App::PropertyBool", "ChildrenOverride", "Children",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "If true, show the objects contained in this Building Part will adopt these line, color and transparency settings"
                ))
        if not "ChildrenLineWidth" in pl:
            vobj.addProperty(
                "App::PropertyFloat", "ChildrenLineWidth", "Children",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The line width of child objects"))
            vobj.LineWidth = 1
        if not "ChildrenLineColor" in pl:
            vobj.addProperty(
                "App::PropertyColor", "ChildrenLineColor", "Children",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The line color of child objects"))
            c = FreeCAD.ParamGet(
                "User parameter:BaseApp/Preferences/View").GetUnsigned(
                    "DefaultShapeLineColor", 255)
            vobj.ChildrenLineColor = (float((c >> 24) & 0xFF) / 255.0,
                                      float((c >> 16) & 0xFF) / 255.0,
                                      float((c >> 8) & 0xFF) / 255.0, 0.0)
        if not "ChildrenShapeolor" in pl:
            vobj.addProperty(
                "App::PropertyColor", "ChildrenShapeColor", "Children",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The shape color of child objects"))
            c = FreeCAD.ParamGet(
                "User parameter:BaseApp/Preferences/View").GetUnsigned(
                    "DefaultShapeColor", 4294967295)
            vobj.ChildrenLineColor = (float((c >> 24) & 0xFF) / 255.0,
                                      float((c >> 16) & 0xFF) / 255.0,
                                      float((c >> 8) & 0xFF) / 255.0, 0.0)
        if not "ChildrenTransparency" in pl:
            vobj.addProperty(
                "App::PropertyPercent", "ChildrenTransparency", "Children",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The transparency of child objects"))

        # clip properties
        if not "CutView" in pl:
            vobj.addProperty(
                "App::PropertyBool", "CutView", "Clip",
                QT_TRANSLATE_NOOP("App::Property",
                                  "Cut the view above this level"))
        if not "CutMargin" in pl:
            vobj.addProperty(
                "App::PropertyLength", "CutMargin", "Clip",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The distance between the level plane and the cut line"))
            vobj.CutMargin = 1600
        if not "AutoCutView" in pl:
            vobj.addProperty(
                "App::PropertyBool", "AutoCutView", "Clip",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "Turn cutting on when activating this level"))
Example #17
0
    def setProperties(self, vobj):

        pl = vobj.PropertiesList
        if not "Text" in pl:
            vobj.addProperty(
                "App::PropertyStringList", "Text", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The text to show. Use $area, $label, $tag, $floor, $walls, $ceiling to insert the respective data"
                ))
            vobj.Text = ["$label", "$area"]
        if not "FontName" in pl:
            vobj.addProperty(
                "App::PropertyFont", "FontName", "Space",
                QT_TRANSLATE_NOOP("App::Property", "The name of the font"))
            vobj.FontName = Draft.getParam("textfont", "")
        if not "TextColor" in pl:
            vobj.addProperty(
                "App::PropertyColor", "TextColor", "Space",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The color of the area text"))
            vobj.TextColor = (0.0, 0.0, 0.0, 1.0)
        if not "FontSize" in pl:
            vobj.addProperty(
                "App::PropertyLength", "FontSize", "Space",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The size of the text font"))
            vobj.FontSize = Draft.getParam("textheight", 10)
        if not "FirstLine" in pl:
            vobj.addProperty(
                "App::PropertyLength", "FirstLine", "Space",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The size of the first line of text"))
            vobj.FirstLine = Draft.getParam("textheight", 10)
        if not "LineSpacing" in pl:
            vobj.addProperty(
                "App::PropertyFloat", "LineSpacing", "Space",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The space between the lines of text"))
            vobj.LineSpacing = 1.0
        if not "TextPosition" in pl:
            vobj.addProperty(
                "App::PropertyVectorDistance", "TextPosition", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The position of the text. Leave (0,0,0) for automatic position"
                ))
        if not "TextAlign" in pl:
            vobj.addProperty(
                "App::PropertyEnumeration", "TextAlign", "Space",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The justification of the text"))
            vobj.TextAlign = ["Left", "Center", "Right"]
            vobj.TextAlign = "Center"
        if not "Decimals" in pl:
            vobj.addProperty(
                "App::PropertyInteger", "Decimals", "Space",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The number of decimals to use for calculated texts"))
            vobj.Decimals = Draft.getParam("dimPrecision", 2)
        if not "ShowUnit" in pl:
            vobj.addProperty(
                "App::PropertyBool", "ShowUnit", "Space",
                QT_TRANSLATE_NOOP("App::Property", "Show the unit suffix"))
            vobj.ShowUnit = Draft.getParam("showUnit", True)
Example #18
0
    def GetResources(self):
        """Set icon, menu and tooltip."""

        return {'Pixmap': 'Draft_2DShapeView',
                'MenuText': QT_TRANSLATE_NOOP("Draft_Shape2DView", "Shape 2D view"),
                'ToolTip': QT_TRANSLATE_NOOP("Draft_Shape2DView", "Creates a 2D projection of the selected objects on the XY plane.\nThe initial projection direction is the negative of the current active view direction.\nYou can select individual faces to project, or the entire solid, and also include hidden lines.\nThese projections can be used to create technical drawings with the TechDraw Workbench.")}
Example #19
0
    def setProperties(self, 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 appartment 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)
        self.Type = "Site"
        obj.setEditorMode('Height', 2)
Example #20
0
 def testQtTranslateNoop(self):
     refcnt = sys.getrefcount(self.txt)
     result = QT_TRANSLATE_NOOP(None, self.txt)
     self.assertEqual(result, self.txt)
     self.assertEqual(sys.getrefcount(result), refcnt + 1)
Example #21
0
    def initAreaOp(self, obj):
        """initAreaOp(obj) ... create pocket specific properties.
        Do not overwrite, implement initPocketOp(obj) instead."""
        PathLog.track()

        # Pocket Properties
        obj.addProperty(
            "App::PropertyEnumeration",
            "CutMode",
            "Pocket",
            QT_TRANSLATE_NOOP(
                "App::Property",
                "The direction that the toolpath should go around the part ClockWise (CW) or CounterClockWise (CCW)",
            ),
        )
        obj.addProperty(
            "App::PropertyDistance",
            "ExtraOffset",
            "Pocket",
            QT_TRANSLATE_NOOP(
                "App::Property",
                "Extra offset to apply to the operation. Direction is operation dependent.",
            ),
        )
        obj.addProperty(
            "App::PropertyEnumeration",
            "StartAt",
            "Pocket",
            QT_TRANSLATE_NOOP("App::Property",
                              "Start pocketing at center or boundary"),
        )
        obj.addProperty(
            "App::PropertyPercent",
            "StepOver",
            "Pocket",
            QT_TRANSLATE_NOOP(
                "App::Property",
                "Percent of cutter diameter to step over on each pass"),
        )
        obj.addProperty(
            "App::PropertyFloat",
            "ZigZagAngle",
            "Pocket",
            QT_TRANSLATE_NOOP("App::Property", "Angle of the zigzag pattern"),
        )
        obj.addProperty(
            "App::PropertyEnumeration",
            "OffsetPattern",
            "Face",
            QT_TRANSLATE_NOOP("App::Property", "Clearing pattern to use"),
        )
        obj.addProperty(
            "App::PropertyBool",
            "MinTravel",
            "Pocket",
            QT_TRANSLATE_NOOP("App::Property", "Use 3D Sorting of Path"),
        )
        obj.addProperty(
            "App::PropertyBool",
            "KeepToolDown",
            "Pocket",
            QT_TRANSLATE_NOOP("App::Property",
                              "Attempts to avoid unnecessary retractions."),
        )

        for n in self.pocketPropertyEnumerations():
            setattr(obj, n[0], n[1])

        self.initPocketOp(obj)
Example #22
0
 def GetResources(self):
     return {'Pixmap'  : 'Arch_Site',
             'MenuText': QT_TRANSLATE_NOOP("Arch_Site","Site"),
             'Accel': "S, I",
             'ToolTip': QT_TRANSLATE_NOOP("Arch_Site","Creates a site object including selected objects.")}
Example #23
0
    def makeStraightStairs(self, obj, edge, numberofsteps=None):

        "builds a simple, straight staircase from a straight edge"

        # Upgrade obj if it is from an older version of FreeCAD
        if not (hasattr(obj, "StringerOverlap")):
            obj.addProperty(
                "App::PropertyLength", "StringerOverlap", "Structure",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The overlap of the stringers above the bottom of the treads"
                ))

        # general data
        import Part, DraftGeomUtils
        if not numberofsteps:
            numberofsteps = obj.NumberOfSteps
        v = DraftGeomUtils.vec(edge)
        vLength = DraftVecUtils.scaleTo(
            v,
            float(edge.Length) / (numberofsteps - 1))
        vLength = Vector(vLength.x, vLength.y, 0)
        if round(v.z, Draft.precision()) != 0:
            h = v.z
        else:
            h = obj.Height.Value
        vHeight = Vector(0, 0, float(h) / numberofsteps)
        vWidth = DraftVecUtils.scaleTo(vLength.cross(Vector(0, 0, 1)),
                                       obj.Width.Value)
        vBase = edge.Vertexes[0].Point
        vNose = DraftVecUtils.scaleTo(vLength, -abs(obj.Nosing.Value))
        a = math.atan(vHeight.Length / vLength.Length)
        #print("stair data:",vLength.Length,":",vHeight.Length)

        # steps
        for i in range(numberofsteps - 1):
            p1 = vBase.add((Vector(vLength).multiply(i)).add(
                Vector(vHeight).multiply(i + 1)))
            p1 = self.align(p1, obj.Align, vWidth)
            p1 = p1.add(vNose).add(Vector(0, 0,
                                          -abs(obj.TreadThickness.Value)))
            p2 = p1.add(DraftVecUtils.neg(vNose)).add(vLength)
            p3 = p2.add(vWidth)
            p4 = p3.add(DraftVecUtils.neg(vLength)).add(vNose)
            step = Part.Face(Part.makePolygon([p1, p2, p3, p4, p1]))
            if obj.TreadThickness.Value:
                step = step.extrude(Vector(0, 0,
                                           abs(obj.TreadThickness.Value)))
                self.steps.append(step)
            else:
                self.pseudosteps.append(step)

        # structure
        lProfile = []
        struct = None
        if obj.Structure == "Massive":
            if obj.StructureThickness.Value:
                for i in range(numberofsteps - 1):
                    if not lProfile:
                        lProfile.append(vBase)
                    last = lProfile[-1]
                    if len(lProfile) == 1:
                        last = last.add(
                            Vector(0, 0, -abs(obj.TreadThickness.Value)))
                    lProfile.append(last.add(vHeight))
                    lProfile.append(lProfile[-1].add(vLength))
                resHeight1 = obj.StructureThickness.Value / math.cos(a)
                lProfile.append(lProfile[-1].add(Vector(0, 0, -resHeight1)))
                resHeight2 = ((numberofsteps - 1) * vHeight.Length) - (
                    resHeight1 + obj.TreadThickness.Value)
                resLength = (vLength.Length / vHeight.Length) * resHeight2
                h = DraftVecUtils.scaleTo(vLength, -resLength)
                lProfile.append(lProfile[-1].add(Vector(h.x, h.y,
                                                        -resHeight2)))
                lProfile.append(vBase)
                #print(lProfile)
                pol = Part.makePolygon(lProfile)
                struct = Part.Face(pol)
                evec = vWidth
                if obj.StructureOffset.Value:
                    mvec = DraftVecUtils.scaleTo(vWidth,
                                                 obj.StructureOffset.Value)
                    struct.translate(mvec)
                    evec = DraftVecUtils.scaleTo(
                        evec, evec.Length - (2 * mvec.Length))
                struct = struct.extrude(evec)
        elif obj.Structure in ["One stringer", "Two stringers"]:
            if obj.StringerWidth.Value and obj.StructureThickness.Value:
                hyp = math.sqrt(vHeight.Length**2 + vLength.Length**2)
                l1 = Vector(vLength).multiply(numberofsteps - 1)
                h1 = Vector(vHeight).multiply(numberofsteps - 1).add(
                    Vector(
                        0, 0, -abs(obj.TreadThickness.Value) +
                        obj.StringerOverlap.Value))
                p1 = vBase.add(l1).add(h1)
                p1 = self.align(p1, obj.Align, vWidth)
                if obj.StringerOverlap.Value <= float(h) / numberofsteps:
                    lProfile.append(p1)
                else:
                    p1b = vBase.add(l1).add(Vector(0, 0, float(h)))
                    p1a = p1b.add(
                        Vector(vLength).multiply(
                            (p1b.z - p1.z) / vHeight.Length))
                    lProfile.append(p1a)
                    lProfile.append(p1b)
                h2 = (obj.StructureThickness.Value / vLength.Length) * hyp
                lProfile.append(p1.add(Vector(0, 0, -abs(h2))))
                h3 = lProfile[-1].z - vBase.z
                l3 = (h3 / vHeight.Length) * vLength.Length
                v3 = DraftVecUtils.scaleTo(vLength, -l3)
                lProfile.append(lProfile[-1].add(Vector(0, 0,
                                                        -abs(h3))).add(v3))
                l4 = (obj.StructureThickness.Value / vHeight.Length) * hyp
                v4 = DraftVecUtils.scaleTo(vLength, -l4)
                lProfile.append(lProfile[-1].add(v4))
                lProfile.append(lProfile[0])
                #print(lProfile)
                pol = Part.makePolygon(lProfile)
                pol = Part.Face(pol)
                evec = DraftVecUtils.scaleTo(vWidth, obj.StringerWidth.Value)
                if obj.Structure == "One stringer":
                    if obj.StructureOffset.Value:
                        mvec = DraftVecUtils.scaleTo(vWidth,
                                                     obj.StructureOffset.Value)
                    else:
                        mvec = DraftVecUtils.scaleTo(
                            vWidth,
                            (vWidth.Length / 2) - obj.StringerWidth.Value / 2)
                    pol.translate(mvec)
                    struct = pol.extrude(evec)
                elif obj.Structure == "Two stringers":
                    pol2 = pol.copy()
                    if obj.StructureOffset.Value:
                        mvec = DraftVecUtils.scaleTo(vWidth,
                                                     obj.StructureOffset.Value)
                        pol.translate(mvec)
                        mvec = vWidth.add(mvec.negative())
                        pol2.translate(mvec)
                    else:
                        pol2.translate(vWidth)
                    s1 = pol.extrude(evec)
                    s2 = pol2.extrude(evec.negative())
                    struct = Part.makeCompound([s1, s2])
        if struct:
            self.structures.append(struct)
Example #24
0
    def __init__(self,obj):

        ArchFloor._Floor.__init__(self,obj)
        obj.addProperty("App::PropertyLink","Terrain","Arch",QT_TRANSLATE_NOOP("App::Property","The base terrain of this site"))
        obj.addProperty("App::PropertyString","Address","Arch",QT_TRANSLATE_NOOP("App::Property","The street and house number of this site"))
        obj.addProperty("App::PropertyString","PostalCode","Arch",QT_TRANSLATE_NOOP("App::Property","The postal or zip code of this site"))
        obj.addProperty("App::PropertyString","City","Arch",QT_TRANSLATE_NOOP("App::Property","The city of this site"))
        obj.addProperty("App::PropertyString","Country","Arch",QT_TRANSLATE_NOOP("App::Property","The country of this site"))
        obj.addProperty("App::PropertyFloat","Latitude","Arch",QT_TRANSLATE_NOOP("App::Property","The latitude of this site"))
        obj.addProperty("App::PropertyFloat","Longitude","Arch",QT_TRANSLATE_NOOP("App::Property","The latitude of this site"))
        obj.addProperty("App::PropertyAngle","NorthDeviation","Arch",QT_TRANSLATE_NOOP("App::Property","Angle between the true North and the North direction in this document"))
        obj.addProperty("App::PropertyLength","Elevation","Arch",QT_TRANSLATE_NOOP("App::Property","The elevation of level 0 of this site"))
        obj.addProperty("App::PropertyString","Url","Arch",QT_TRANSLATE_NOOP("App::Property","A url that shows this site in a mapping website"))
        obj.addProperty("App::PropertyLinkList","Additions","Arch",QT_TRANSLATE_NOOP("App::Property","Other shapes that are appended to this object"))
        obj.addProperty("App::PropertyLinkList","Subtractions","Arch",QT_TRANSLATE_NOOP("App::Property","Other shapes that are subtracted from this object"))
        obj.addProperty("App::PropertyArea","ProjectedArea","Arch",QT_TRANSLATE_NOOP("App::Property","The area of the projection of this object onto the XY plane"))
        obj.addProperty("App::PropertyLength","Perimeter","Arch",QT_TRANSLATE_NOOP("App::Property","The perimeter length of this terrain"))
        obj.addProperty("App::PropertyVolume","AdditionVolume","Arch",QT_TRANSLATE_NOOP("App::Property","The volume of earth to be added to this terrain"))
        obj.addProperty("App::PropertyVolume","SubtractionVolume","Arch",QT_TRANSLATE_NOOP("App::Property","The volume of earth to be removed from this terrain"))
        obj.addProperty("App::PropertyVector","ExtrusionVector","Arch",QT_TRANSLATE_NOOP("App::Property","An extrusion vector to use when performing boolean operations"))
        obj.addProperty("App::PropertyBool","RemoveSplitter","Arch",QT_TRANSLATE_NOOP("App::Property","Remove splitters from the resulting shape"))
        obj.addExtension("App::GroupExtensionPython", self)
        self.Type = "Site"
        obj.setEditorMode('Height',2)
        obj.ExtrusionVector = FreeCAD.Vector(0,0,-100000)
Example #25
0
    def Initialize(self):
        """When the workbench is first loaded."""
        def QT_TRANSLATE_NOOP(context, text):
            return text

        # Run self-tests
        dependencies_OK = False
        try:
            from pivy import coin
            if FreeCADGui.getSoDBVersion() != coin.SoDB.getVersion():
                raise AssertionError("FreeCAD and Pivy use different versions "
                                     "of Coin. "
                                     "This will lead to unexpected behaviour.")
        except AssertionError:
            FreeCAD.Console.PrintWarning("Error: FreeCAD and Pivy "
                                         "use different versions of Coin. "
                                         "This will lead to unexpected "
                                         "behaviour.\n")
        except ImportError:
            FreeCAD.Console.PrintWarning("Error: Pivy not found, "
                                         "Draft Workbench will be disabled.\n")
        except Exception:
            FreeCAD.Console.PrintWarning("Error: Unknown error "
                                         "while trying to load Pivy.\n")
        else:
            dependencies_OK = True

        if not dependencies_OK:
            return

        # Import Draft tools, icons
        try:
            import Draft_rc
            import DraftTools
            import DraftGui
            import DraftFillet
            from draftguitools import gui_circulararray
            from draftguitools import gui_polararray
            FreeCADGui.addLanguagePath(":/translations")
            FreeCADGui.addIconPath(":/icons")
        except Exception as exc:
            FreeCAD.Console.PrintError(exc)
            FreeCAD.Console.PrintError("Error: Initializing one or more "
                                       "of the Draft modules failed, "
                                       "Draft will not work as expected.\n")

        # Set up command lists
        import draftutils.init_tools as it
        self.drawing_commands = it.get_draft_drawing_commands()
        self.annotation_commands = it.get_draft_annotation_commands()
        self.modification_commands = it.get_draft_modification_commands()
        self.context_commands = it.get_draft_context_commands()
        self.line_commands = it.get_draft_line_commands()
        self.utility_commands = it.get_draft_utility_commands()

        # Set up toolbars
        self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft creation tools"),
                           self.drawing_commands)
        self.appendToolbar(
            QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"),
            self.annotation_commands)
        self.appendToolbar(
            QT_TRANSLATE_NOOP("Draft", "Draft modification tools"),
            self.modification_commands)

        # Set up menus
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"),
                        self.drawing_commands)
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Annotation"),
                        self.annotation_commands)
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Modification"),
                        self.modification_commands)
        self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Utilities"),
                        self.utility_commands + self.context_commands)

        # Set up preferences pages
        if hasattr(FreeCADGui, "draftToolBar"):
            if not hasattr(FreeCADGui.draftToolBar, "loadedPreferences"):
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draft.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftsnap.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-draftvisual.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.addPreferencePage(
                    ":/ui/preferences-drafttexts.ui",
                    QT_TRANSLATE_NOOP("Draft", "Draft"))
                FreeCADGui.draftToolBar.loadedPreferences = True

        FreeCAD.Console.PrintLog('Loading Draft workbench, done.\n')
def makeHelicalRebar(
    s_cover, b_cover, diameter, t_cover, pitch, structure=None, facename=None
):
    """makeHelicalRebar(SideCover, BottomCover, Diameter, TopCover, Pitch,
    Structure, Facename):
    Adds the Helical reinforcement bar to the selected structural object."""
    if not structure and not facename:
        selected_obj = FreeCADGui.Selection.getSelectionEx()[0]
        structure = selected_obj.Object
        facename = selected_obj.SubElementNames[0]
    face = structure.Shape.Faces[getFaceNumber(facename) - 1]
    # StructurePRM = getTrueParametersOfStructure(structure)
    FacePRM = getParametersOfFace(structure, facename, False)
    if not FacePRM:
        FreeCAD.Console.PrintError(
            "Cannot identify shape or from which base object structural "
            "element is derived\n"
        )
        return
    size = (
        ArchCommands.projectToVector(
            structure.Shape.copy(), face.normalAt(0, 0)
        )
    ).Length
    normal = face.normalAt(0, 0)
    # normal = face.Placement.Rotation.inverted().multVec(normal)
    import Arch

    helix = createHelicalWire(
        FacePRM, s_cover, b_cover, t_cover, pitch, size, normal, diameter
    )
    helix.Support = [(structure, facename)]
    rebar = Arch.makeRebar(
        structure, helix, diameter, 1, diameter / 2, name="HelicalRebar"
    )
    rebar.OffsetStart = diameter / 2
    rebar.OffsetEnd = diameter / 2
    FreeCAD.ActiveDocument.recompute()
    # Adds properties to the rebar object
    rebar.addProperty(
        "App::PropertyEnumeration",
        "RebarShape",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Shape of rebar"),
    ).RebarShape = RebarTypes.tolist()
    rebar.RebarShape = "HelicalRebar"
    rebar.setEditorMode("RebarShape", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "SideCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar"),
    ).SideCover = s_cover
    rebar.setEditorMode("SideCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "Pitch",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Left Side cover of rebar"),
    ).Pitch = pitch
    rebar.setEditorMode("Pitch", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "BottomCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar"),
    ).BottomCover = b_cover
    rebar.setEditorMode("BottomCover", 2)
    rebar.addProperty(
        "App::PropertyDistance",
        "TopCover",
        "RebarDialog",
        QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar"),
    ).TopCover = t_cover
    rebar.setEditorMode("TopCover", 2)
    FreeCAD.ActiveDocument.recompute()
    return rebar
Example #27
0
    def setProperties(self, vobj):
        """Give the site view provider its site view provider specific properties.

        These include solar diagram and compass data, dealing the orientation
        of the site, and its orientation to the sun.

        You can learn more about properties here: https://wiki.freecadweb.org/property
        """

        pl = vobj.PropertiesList
        if not "WindRose" in pl:
            vobj.addProperty(
                "App::PropertyBool", "WindRose", "Site",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "Show wind rose diagram or not. Uses solar diagram scale. Needs Ladybug module"
                ))
        if not "SolarDiagram" in pl:
            vobj.addProperty(
                "App::PropertyBool", "SolarDiagram", "Site",
                QT_TRANSLATE_NOOP("App::Property",
                                  "Show solar diagram or not"))
        if not "SolarDiagramScale" in pl:
            vobj.addProperty(
                "App::PropertyFloat", "SolarDiagramScale", "Site",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The scale of the solar diagram"))
            vobj.SolarDiagramScale = 1
        if not "SolarDiagramPosition" in pl:
            vobj.addProperty(
                "App::PropertyVector", "SolarDiagramPosition", "Site",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The position of the solar diagram"))
        if not "SolarDiagramColor" in pl:
            vobj.addProperty(
                "App::PropertyColor", "SolarDiagramColor", "Site",
                QT_TRANSLATE_NOOP("App::Property",
                                  "The color of the solar diagram"))
            vobj.SolarDiagramColor = (0.16, 0.16, 0.25)
        if not "Orientation" in pl:
            vobj.addProperty(
                "App::PropertyEnumeration", "Orientation", "Site",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "When set to 'True North' the whole geometry will be rotated to match the true north of this site"
                ))
            vobj.Orientation = ["Project North", "True North"]
            vobj.Orientation = "Project North"
        if not "Compass" in pl:
            vobj.addProperty(
                "App::PropertyBool", "Compass", "Compass",
                QT_TRANSLATE_NOOP("App::Property", "Show compass or not"))
        if not "CompassRotation" in pl:
            vobj.addProperty(
                "App::PropertyAngle", "CompassRotation", "Compass",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The rotation of the Compass relative to the Site"))
        if not "CompassPosition" in pl:
            vobj.addProperty(
                "App::PropertyVector", "CompassPosition", "Compass",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "The position of the Compass relative to the Site placement"
                ))
        if not "UpdateDeclination" in pl:
            vobj.addProperty(
                "App::PropertyBool", "UpdateDeclination", "Compass",
                QT_TRANSLATE_NOOP(
                    "App::Property",
                    "Update the Declination value based on the compass rotation"
                ))
Example #28
0
 def GetResources(self):
     return {'Pixmap': 'Arch_Schedule',
             'MenuText': QT_TRANSLATE_NOOP("Arch_Schedule","Schedule"),
             'ToolTip': QT_TRANSLATE_NOOP("Arch_Schedule","Creates a schedule to collect data from the model")}
Example #29
0
    def GetResources(self):

        return {'Pixmap'  : 'Arch_BuildingPart',
                'MenuText': QT_TRANSLATE_NOOP("Arch_BuildingPart","BuildingPart"),
                'Accel': "B, P",
                'ToolTip': QT_TRANSLATE_NOOP("Arch_BuildingPart","Creates a BuildingPart object including selected objects")}
Example #30
0
    def __init__(self, obj):
        self.obj = obj
        obj.addProperty(
            "App::PropertyLink",
            "Base",
            "Path",
            QT_TRANSLATE_NOOP("App::Property", "The base path to modify"),
        )
        obj.addProperty(
            "App::PropertyAngle",
            "Angle",
            "Path",
            QT_TRANSLATE_NOOP("App::Property", "Angle of ramp."),
        )
        obj.addProperty(
            "App::PropertyEnumeration",
            "Method",
            "Path",
            QT_TRANSLATE_NOOP("App::Property", "Ramping Method"),
        )
        obj.addProperty(
            "App::PropertyEnumeration",
            "RampFeedRate",
            "FeedRate",
            QT_TRANSLATE_NOOP("App::Property", "Which feed rate to use for ramping"),
        )
        obj.addProperty(
            "App::PropertySpeed",
            "CustomFeedRate",
            "FeedRate",
            QT_TRANSLATE_NOOP("App::Property", "Custom feed rate"),
        )
        obj.addProperty(
            "App::PropertyBool",
            "UseStartDepth",
            "StartDepth",
            QT_TRANSLATE_NOOP(
                "App::Property",
                "Should the dressup ignore motion commands above DressupStartDepth",
            ),
        )
        obj.addProperty(
            "App::PropertyDistance",
            "DressupStartDepth",
            "StartDepth",
            QT_TRANSLATE_NOOP(
                "App::Property",
                "The depth where the ramp dressup is enabled. Above this ramps are not generated, but motion commands are passed through as is.",
            ),
        )

        # populate the enumerations
        for n in self.propertyEnumerations():
            setattr(obj, n[0], n[1])

        obj.Proxy = self
        self.setEditorProperties(obj)

        # initialized later
        self.wire = None
        self.angle = None
        self.rapids = None
        self.method = None
        self.outedges = None
        self.ignoreAboveEnabled = None
        self.ignoreAbove = None