def Activated(self):
        print("-----------------Wing Wizard-----------------")
        selection = FreeCADGui.Selection.getSelectionEx()
        if selection :
           base = FreeCAD.ActiveDocument.getObject((selection[0].ObjectName))

        PanelTable=[]
        editor = WingEditorPanel()
        editor.setupUi()
        r = editor.form.exec_()

        if r:
          for row_number in range(editor.form.PanelTable.rowCount()):
             rowData=[]
             #create Panel
             for col_number in range(10):#int(editor.form.PanelTable.columnCount())):
                rowData.append(editor.form.PanelTable.item(row_number,col_number).text())
             PanelTable.append(rowData)
        _panelInput=PanelTable


        _ribs=[]
        _position=0
        _PanelLength=[]
        profil=[]
        b=[]
        #for i in range(0,obj.NberOfPanel) :
        for i in range(0,editor.form.PanelTable.rowCount()) :
           _row=_panelInput[i]
           profil.append(_row[2])
           _PanelLength.append(float(_row[4]))
           # Add Rib Root
           _ribs.append(FreeCAD.ActiveDocument.addObject("Part::FeaturePython","RibRoot_"+str(i)))
           #WingRibs(obj,_profil,_nacagene,_nacaNbrPoint,_chord,_x,_y,_z,_xrot,_yrot,_zrot,_thickness=0,_useSpline = True,_finite_TE = False,_splitSpline = False):
           #def     (obj,_profil,_nacagene,_nacaNbrPoint,_chord,_x,_y,_z,_xrot,_yrot,_zrot,_rot=0,_thickness=0,_useSpline = True,_finite_TE = False,_splitSpline = False):
           WingRib(_ribs[i*2],_row[2],False,0,_row[3],_row[6],_position,_row[8],0,0,0)
           #FreeCAD.ActiveDocument.recompute()
           ViewProviderWingRib(_ribs[i*2].ViewObject)
           # Add Rib tip
           _position=_position+float(_row[5])
           _ribs.append(FreeCAD.ActiveDocument.addObject("Part::FeaturePython","RibTip_"+str(i)))
           WingRib(_ribs[i*2+1],_row[2],False,0,_row[4],_row[7],_position,_row[9],0,0,0)
           #FreeCAD.ActiveDocument.recompute()
           ViewProviderWingRib(_ribs[i*2+1].ViewObject)
           # Add wing panel
           obj=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","WingPanel")
           #WingPanel(obj, _rootRib ,_tipRib ,_rootChord=200,_tipChord=100,_panelLength=100,_tipTwist=0,_dihedral=0)
           WingPanel(obj,_ribs[i*2],_ribs[i*2+1],_row[3],_row[4],_position,0,0)
           ViewProviderPanel(obj.ViewObject)
           FreeCAD.ActiveDocument.recompute()
           obj.ViewObject.hide()
           #add to Wing
           if selection : #selection==None :
              if not base.WingPanels :
                 base.WingPanels=obj
              else :
                 b=base.WingPanels
                 b.append(obj)
                 base.WingPanels=b
Ejemplo n.º 2
0
    def Activated(self):
        print("---------------------------------------")
        print("-----------------Panel-----------------")
        print("---------------------------------------")

        selection = FreeCADGui.Selection.getSelectionEx()
        if selection:
            base = FreeCAD.ActiveDocument.getObject((selection[0].ObjectName))

        #---------------------création des nervures temporaires
        _rootRib = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                                    "RibRoot_")
        WingRib(
            _rootRib,
            "/Users/fredericnivoix/Library/Preferences/FreeCAD/Mod/AirPlaneDesign/wingribprofil/naca/naca2412.dat",
            False, 0, 200, 0, 0, 0, 0, 0, 0)
        ViewProviderWingRib(_rootRib.ViewObject)

        _tipRib = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                                   "RibTip_")
        WingRib(
            _tipRib,
            "/Users/fredericnivoix/Library/Preferences/FreeCAD/Mod/AirPlaneDesign/wingribprofil/naca/naca2412.dat",
            False, 0, 200, 0, 500, 0, 0, 0, 0)
        ViewProviderWingRib(_tipRib.ViewObject)
        FreeCAD.ActiveDocument.recompute()
        #----------
        #obj=FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython","WingPanel")

        obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                               "WingPanel")
        WingPanel(obj, _rootRib, _tipRib, 200, 100, 100, 0, 0)
        ViewProviderPanel(obj.ViewObject)
        b = []
        if selection:  #selection==None :
            if not base.WingPanels:
                base.WingPanels = obj
            else:
                b = base.WingPanels
                b.append(obj)
                base.WingPanels = b

        #if selection :  #selection ==None:
        #   if not base.Group :
        #      base.Group=obj
        #   else :
        #      b=base.Group
        #      b.append(obj)
        #      base.Group=b

        FreeCAD.ActiveDocument.recompute()
        FreeCAD.Gui.activeDocument().activeView().viewAxonometric()
        FreeCAD.Gui.SendMsgToActiveView("ViewFit")
Ejemplo n.º 3
0
def scaleByBoundbox(shape, boundbox, doScaleXYZ, copy=True):
    basebbox = shape.BoundBox
    #basebbox=[1.0,1.0,1.0]
    scalevec = Vector(1, 1, 1)
    if doScaleXYZ[0] and basebbox.XLength > epsilon:
        scalevec.x = boundbox.XLength / basebbox.XLength
    if doScaleXYZ[1] and basebbox.YLength > epsilon:
        scalevec.y = boundbox.YLength / basebbox.YLength
    if doScaleXYZ[2] and basebbox.ZLength > epsilon:
        scalevec.z = boundbox.ZLength / basebbox.ZLength

    scalevec.x = boundbox.XLength
    scalevec.y = boundbox.YLength
    scalevec.z = boundbox.ZLength

    if scalevec.x < epsilon:
        if doScaleXYZ[0]:
            scalevec.x = epsilon
        else:
            scalevec.x = 1
    if scalevec.y < epsilon:
        if doScaleXYZ[1]:
            scalevec.y = epsilon
        else:
            scalevec.y = 1
    if scalevec.z < epsilon:
        if doScaleXYZ[2]:
            scalevec.z = epsilon
        else:
            scalevec.z = 1

    _rib = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Rib00")
    print("Scale in scaleByBoundbox")
    print(scalevec)
    WingRib(
        _rib,
        "/Users/fredericnivoix/Library/Preferences/FreeCAD/Mod/AirPlaneDesign/wingribprofil/naca/naca2412.dat",
        False, 0, scalevec.x, 0, 0, 0, 0, 0, 0)
    ViewProviderWingRib(_rib.ViewObject)
    _rib.Placement = shape.Placement
    #dolly = scale(shape, scalevec, basebbox.Center, copy)
    #dolly.Placement = shape.Placement

    if doScaleXYZ[0]:
        _rib.Placement.Base.x += boundbox.XMin - basebbox.XMin * scalevec.x
    if doScaleXYZ[1]:
        _rib.Placement.Base.y += boundbox.YMin - basebbox.YMin * scalevec.y
    if doScaleXYZ[2]:
        _rib.Placement.Base.z += boundbox.ZMin - basebbox.ZMin * scalevec.z

    return _rib  #dolly
Ejemplo n.º 4
0
    def createRib(self, obj, chord, posvec, direction, rotaxis, angle):
        #basebbox = obj.RootRib.Shape.BoundBox,basepl = obj.RootRib.Placement, print("Create Rib new release")

        #bbox = CurvedShapes.boundbox_from_intersect(obj.Hullcurves, posvec, direction, self.doScaleXYZ)
        FreeCAD.Console.PrintMessage("------------ createRib ------------\n")
        #if not bbox:
        #      FreeCAD.Console.PrintMessage("------------ not bbox ------------\n")
        #          return None
        _rib = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Rib")
        #calcul du facteur d'échelle de la nervure
        #x,y,z,scalex,scaley,scalez=scaleByBoundbox2(obj.Base.Shape, bbox, self.doScaleXYZsum )
        #(obj,_profil,_nacagene,_nacaNbrPoint,_chord,_x,_y,_z,_xrot,_yrot,_zrot,_thickness=0,_useSpline = True,_finite_TE = False,_splitSpline = False)
        #(self, obj,_profil,_nacagene,_nacaNbrPoint,_chord,_x,_y,_z,_xrot,_yrot,_zrot,_rot=0,_thickness=0,_useSpline = True,_finite_TE = False,_splitSpline = False)

        #FreeCAD.Console.PrintMessage("------------ createRib.posvec:"+str(posvec)+ " ------------\n")
        #FreeCAD.Console.PrintMessage("------------ createRib.rotaxis:"+str(rotaxis)+ " ------------\n")
        #FreeCAD.Console.PrintMessage("------------ createRib.angle"+str(angle)+ " ------------\n")
        #FreeCAD.Console.PrintMessage("------------ createRib.scalex"+str(scalex)+ " ------------\n")
        #FreeCAD.Console.PrintMessage("------------ createRib.scaley"+str(scaley)+ " ------------\n")
        #FreeCAD.Console.PrintMessage("------------ createRib.scalez"+str(scalez)+ " ------------\n")

        if obj.Base.NacaProfil == "":
            WingRib(
                _rib,
                obj.Base.RibProfil,
                "",
                obj.Base.NacaNbrPoint,
                chord,
                posvec.x,
                posvec.y,
                posvec.z,
                rotaxis.x,
                rotaxis.y,
                rotaxis.
                z,  #obj.Base.Placement.Rotation.Axis.x,obj.Base.Placement.Rotation.Axis.y, obj.Base.Placement.Rotation.Axis.z,
                angle,  #math.degrees(obj.Base.Placement.Rotation.Angle),
                0,
                obj.Base.useSpline,
                obj.Base.finite_TE,
                obj.Base.splitSpline)

        else:
            WingRib(
                _rib,
                obj.Base.RibProfil,
                True,
                obj.Base.NacaNbrPoint,
                chord,
                posvec.x,
                posvec.y,
                posvec.z,
                rotaxis.x,
                rotaxis.y,
                rotaxis.
                z,  #obj.Base.Placement.Rotation.Axis.x,obj.Base.Placement.Rotation.Axis.y, obj.Base.Placement.Rotation.Axis.z,
                angle,  #math.degrees(obj.Base.Placement.Rotation.Angle),
                0,
                obj.Base.useSpline,
                obj.Base.finite_TE,
                obj.Base.splitSpline)
            #obj.addProperty("App::PropertyString","NacaProfil","NacaProfil",QtCore.QT_TRANSLATE_NOOP("App::Property","Naca Profil")).NacaProfil=""

        ViewProviderWingRib(_rib.ViewObject)
        return _rib
Ejemplo n.º 5
0
    def __init__(self, obj, _NberOfPanel, _panelInput):
        '''Add some custom properties to our box feature'''
        obj.Proxy = self
        obj.addProperty("App::PropertyInteger", "NberOfPanel", "WingPanel",
                        "Number of Panel").NberOfPanel = _NberOfPanel
        obj.addProperty("App::PropertyLinkList", "Rib", "Ribs", "Ribs")
        #obj.addProperty("App::PropertyLinkList", "RibTip", "Ribs", "Tip Ribs")

        _ribs = []
        #_ribsRoot=[]
        _panel = []
        _position = 0
        _PanelLength = []
        profil = []
        #for i in range(0,obj.NberOfPanel) :
        for i in range(0, obj.NberOfPanel):
            _row = _panelInput[i]
            profil.append(_row[2])
            #_wingRibProfilDir+u"/e207.dat"
            _PanelLength.append(float(_row[4]))
            #obj.addProperty("App::PropertyFloatList","PanelDelta","WingPanel","Delta").PanelDelta=[0.0,70.0]
            #obj.addProperty("App::PropertyLinkList", "RibRoot", "Ribs", "Root Ribs")
            #obj.addProperty("App::PropertyLinkList", "RibTip", "Ribs", "Tip Ribs")

            FreeCAD.Console.PrintMessage("Panel creation : " + str(i))
            #FreeCAD.Console.PrintMessage(i)
            FreeCAD.Console.PrintMessage("\n")

            # Add Rib Root
            FreeCAD.Console.PrintMessage("Add Rib Root")
            _ribs.append(
                FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                                 "RibRoot_" + str(i)))
            #WingRib(_ribs[i*2],obj.PanelProfil,100,0,_position,0)
            #obj.RibRoot.append(
            WingRib(_ribs[i * 2], _row[2], False, 0, _row[3], _row[6],
                    _position, _row[8], 0, 0, 0)
            ViewProviderWingRib(_ribs[i * 2].ViewObject)

            # Add Rib tip
            FreeCAD.Console.PrintMessage("Add Rib tip")
            FreeCAD.Console.PrintMessage(i + 1)
            #_position=_position+obj.PanelLength[i]
            _position = _position + float(_row[5])
            _ribs.append(
                FreeCAD.ActiveDocument.addObject("Part::FeaturePython",
                                                 "RibTip_" + str(i)))
            #WingRib(_ribs[i*2+1],obj.PanelProfil,100,0,_position,0)
            WingRib(_ribs[i * 2 + 1], _row[2], False, 0, _row[4], _row[7],
                    _position, _row[9], 0, 0, 0)
            ViewProviderWingRib(_ribs[i * 2 + 1].ViewObject)
            #obj.RibTip.append(_ribs[i*2+1])

            FreeCAD.Console.PrintMessage("create the panel")
            if obj.NberOfPanel > 1:
                _panel.append(
                    FreeCAD.ActiveDocument.addObject('Part::Loft', 'panel'))
                _panel[i].Sections = [_ribs[i * 2], _ribs[i * 2 + 1]]
                _panel[i].Solid = True
                _panel[i].Ruled = False
            else:
                a = FreeCAD.ActiveDocument.addObject('Part::Loft', 'Wing')
                _panel.append(a)
                _panel[i].Sections = [_ribs[i * 2], _ribs[i * 2 + 1]]
                _panel[i].Solid = True
                _panel[i].Ruled = False
                obj.Group = a
            FreeCAD.ActiveDocument.recompute()

        obj.Rib = _ribs
        if obj.NberOfPanel > 1:
            obj.addProperty("App::PropertyFloatList", "PanelLength",
                            "WingPanel",
                            "Length of the Wing").PanelLength = _PanelLength
            obj.addProperty("App::PropertyStringList", "PanelProfil",
                            "WingPanel", "Profil type").PanelProfil = profil
            a = FreeCAD.activeDocument().addObject("Part::MultiFuse", "Wing")
            a.Shapes = _panel
            obj.Group = a