當前位置: 首頁>>代碼示例>>Python>>正文


Python FreeCADGui.runCommand方法代碼示例

本文整理匯總了Python中FreeCADGui.runCommand方法的典型用法代碼示例。如果您正苦於以下問題:Python FreeCADGui.runCommand方法的具體用法?Python FreeCADGui.runCommand怎麽用?Python FreeCADGui.runCommand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FreeCADGui的用法示例。


在下文中一共展示了FreeCADGui.runCommand方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Activated

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def Activated(cls):
        moveInfo = AsmCmdMove._moveInfo
        if not moveInfo:
            return
        info = moveInfo.ElementInfo
        if info.Subname:
            subs = moveInfo.SelSubname[:-len(info.Subname)]
        else:
            subs = moveInfo.SelSubname
        subs = subs.split('.')
        if isinstance(info.Part,tuple):
            part = info.Part[0]
            vis = part.isElementVisible(str(info.Part[1]))
            part.setElementVisible(str(info.Part[1]),not vis)
        else:
            from .assembly import resolveAssembly
            partGroup = resolveAssembly(info.Parent).getPartGroup()
            vis = partGroup.isElementVisible(info.Part.Name)
            partGroup.setElementVisible(info.Part.Name,not vis)

        FreeCADGui.Selection.clearSelection()
        FreeCADGui.Selection.addSelection(moveInfo.SelObj,'.'.join(subs))
        FreeCADGui.runCommand('Std_TreeSelection')
        if vis:
            FreeCADGui.runCommand('Std_TreeCollapse') 
開發者ID:realthunder,項目名稱:FreeCAD_assembly3,代碼行數:27,代碼來源:gui.py

示例2: gotoRelationOfConstraint

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def gotoRelationOfConstraint(obj,subname):
        sobj = obj.getSubObject(subname,1)
        if not isTypeOf(sobj,AsmConstraint):
            return
        subname = flattenLastSubname(obj,subname)
        sub = Part.splitSubname(subname)[0].split('.')
        sub = sub[:-1]
        sub[-2] = '3'
        sub[-1] = ''
        sub = '.'.join(sub)
        subs = []
        relationGroup = sobj.Proxy.getAssembly().getRelationGroup(True)
        for relation in relationGroup.Proxy.getRelations().values():
            for o in relation.Group:
                if isTypeOf(o,AsmRelation):
                    found = False
                    for child in o.Group:
                        if child == sobj:
                            subs.append('{}{}.{}.{}.'.format(
                                sub,relation.Name,o.Name,child.Name))
                            found = True
                            break
                    if found:
                        continue
                elif o == sobj:
                    subs.append('{}{}.{}.'.format(sub,relation.Name,o.Name))

        if subs:
            FreeCADGui.Selection.pushSelStack()
            FreeCADGui.Selection.clearSelection()
            FreeCADGui.Selection.addSelection(obj,subs)
            FreeCADGui.Selection.pushSelStack()
            FreeCADGui.runCommand('Std_TreeSelection') 
開發者ID:realthunder,項目名稱:FreeCAD_assembly3,代碼行數:35,代碼來源:assembly.py

示例3: make

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def make(sels=None,name=None, undo=True):
        info = AsmPlainGroup.getSelection(sels)
        doc = info.Parent.Document
        if undo:
            FreeCAD.setActiveTransaction('Assembly create group')
        try:
            if not name:
                name = 'Group'
            obj = doc.addObject('App::DocumentObjectGroupPython',name)
            AsmPlainGroup(obj,info.Parent)
            ViewProviderAsmPlainGroup(obj.ViewObject)
            group = info.Group.Group
            indices = [ group.index(o) for o in info.Objects ]
            indices.sort()
            child = group[indices[0]]
            group = [ o for o in info.Group.Group
                        if o not in info.Objects ]
            group.insert(indices[0],obj)

            notouch = indices[-1] == indices[0]+len(indices)-1
            editGroup(info.Group,group,notouch)
            obj.purgeTouched()
            editGroup(obj,info.Objects,notouch)

            if undo:
                FreeCAD.closeActiveTransaction()

            FreeCADGui.Selection.clearSelection()
            FreeCADGui.Selection.addSelection(info.SelObj,'{}{}.{}.'.format(
                info.SelSubname,obj.Name,child.Name))
            FreeCADGui.runCommand('Std_TreeSelection')
            return obj
        except Exception:
            if undo:
                FreeCAD.closeActiveTransaction(True)
            raise 
開發者ID:realthunder,項目名稱:FreeCAD_assembly3,代碼行數:38,代碼來源:assembly.py

示例4: shutdown

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def shutdown():
    '''fast stop of freecad test environ'''
    try:
        FreeCAD.closeDocument("Unnamed")
    except:
        pass
    try:
        FreeCAD.closeDocument("graph")
    except:
        pass

    FreeCADGui.runCommand("Std_Quit") 
開發者ID:microelly2,項目名稱:NodeEditor,代碼行數:14,代碼來源:Commands.py

示例5: setEdit

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def setEdit(self,vobj,mode=0):
    #FreeCADGui.runCommand("Draft_Edit")
    Gui.Control.showDialog(FSTaskFilletDialog(self.Object))
    return True 
開發者ID:shaise,項目名稱:FreeCAD_FastenersWB,代碼行數:6,代碼來源:CountersunkHoles.py

示例6: execute

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def execute( self ):
        try:
            FreeCADGui.runCommand( self.Freecad_cmd )
        except:
            FreeCAD.Console.PrintError( traceback.format_exc() )


#============================================================================== 
開發者ID:kbwbe,項目名稱:A2plus,代碼行數:10,代碼來源:a2p_viewProviderProxies.py

示例7: doubleClicked

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def doubleClicked(self,vobj):
        FreeCADGui.activateWorkbench('A2plusWorkbench')
        FreeCADGui.runCommand("a2p_EditConstraintCommand")
                
#WF: next 3 methods not required 
開發者ID:kbwbe,項目名稱:A2plus,代碼行數:7,代碼來源:a2p_viewProviderProxies.py

示例8: Activated

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def Activated(self):
        # check that the Fasteners WB has been loaded before:
        if not 'FSChangeParams' in Gui.listCommands():
            Gui.activateWorkbench('FastenersWorkbench')
            Gui.activateWorkbench('Assembly4Workbench')
        # check that we have somewhere to put our stuff
        self.asmDoc = App.ActiveDocument
        part = self.getPart()
        if part :
            newFastener = App.ActiveDocument.addObject("Part::FeaturePython",self.FStype)
            newFastener.ViewObject.ShapeColor = self.FScolor
            if self.FStype == 'Screw':
                FS.FSScrewObject( newFastener, 'ISO4762', None )
            elif self.FStype == 'Nut':
                FS.FSScrewObject( newFastener, 'ISO4032', None )
            elif self.FStype == 'Washer':
                FS.FSScrewObject( newFastener, 'ISO7089', None )
            elif self.FStype == 'ThreadedRod':
                FS.FSThreadedRodObject( newFastener, None )
            # make the Proxy and stuff
            newFastener.Label = newFastener.Proxy.itemText
            FS.FSViewProviderTree(newFastener.ViewObject)
            # add Asm4 properties if necessary
            Asm4.makeAsmProperties( newFastener, reset=True )
            # add it to the Part 
            part.addObject( newFastener )
            # hide "offset" and "invert" properties to avoid confusion as they are not used in Asm4
            if hasattr( newFastener, 'offset' ):
                newFastener.setPropertyStatus('offset', 'Hidden')
            if hasattr( newFastener, 'invert' ):
                newFastener.setPropertyStatus('invert', 'Hidden')
            newFastener.recompute()
            # ... and select it
            Gui.Selection.clearSelection()
            Gui.Selection.addSelection( newFastener )
            Gui.runCommand('FSChangeParams')
            #Gui.runCommand( 'Asm4_placeFastener' ) 
開發者ID:Zolko-123,項目名稱:FreeCAD_Assembly4,代碼行數:39,代碼來源:FastenersLib.py

示例9: onCreateLink

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def onCreateLink(self):
        # parse the selected items 
        # TODO : there should only be 1
        selectedPart = []
        for selected in self.partList.selectedIndexes():
            # get the selected part
            selectedPart = self.allParts[ selected.row() ]

        # get the name of the link (as it should appear in the tree)
        linkName = self.linkNameInput.text()
        # only create link if there is a Part object and a name
        if self.asmModel and selectedPart and linkName:
            # create the App::Link with the user-provided name
            createdLink = self.activeDoc.getObject('Model').newObject( 'App::Link', linkName )
            # assign the user-selected selectedPart to it
            createdLink.LinkedObject = selectedPart
            # If the name was already chosen, and a UID was generated:
            if createdLink.Name != linkName:
                # we try to set the label to the chosen name
                createdLink.Label = linkName
            # update the link
            createdLink.recompute()
            
            # close the dialog UI...
            self.close()

            # ... and launch the placement of the inserted part
            Gui.Selection.clearSelection()
            Gui.Selection.addSelection( self.activeDoc.Name, 'Model', createdLink.Name+'.' )
            Gui.runCommand( 'Asm4_placeLink' )

        # if still open, close the dialog UI
        self.close() 
開發者ID:Zolko-123,項目名稱:FreeCAD_Assembly4,代碼行數:35,代碼來源:insertLinkCmd.py

示例10: execute

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def execute( self ):
        try:
            FreeCADGui.runCommand( self.Freecad_cmd )
        except:
            FreeCAD.Console.PrintError( traceback.format_exc() ) 
開發者ID:hamish2014,項目名稱:FreeCAD_assembly2,代碼行數:7,代碼來源:viewProviderProxy.py

示例11: run_FreeCAD_bakery

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def run_FreeCAD_bakery(self):

    workspace=self.getData("Workspace")
    name=self.getData("name")
    shape=self.getPinObject('Shape_in')
    s=shape

    l=FreeCAD.listDocuments()
    if workspace=='' or workspace=='None':
        try:
            w=l['Unnamed']
        except:
            w=FreeCAD.newDocument("Unnamed")
            FreeCADGui.runCommand("Std_TileWindows")
    else:
        if workspace in l.keys():
            w=l[workspace]
        else:
            w=FreeCAD.newDocument(workspace)

            #Std_CascadeWindows
            FreeCADGui.runCommand("Std_ViewDimetric")
            FreeCADGui.runCommand("Std_ViewFitAll")
            FreeCADGui.runCommand("Std_TileWindows")

    #s=store.store().get(shape)

    f=w.getObject(name)
    #say("AB",time.time()-timeA)
    if 1 or f == None:
        f = w.addObject('Part::Feature', name)
    if s  !=  None:
    #    say("AC",time.time()-timeA)
        f.Shape=s
    #    say("AD",time.time()-timeA)
    #say("shape",s);say("name",name)
    #say("A",time.time()-timeA)
    w.recompute()
    #say("B",time.time()-timeA)
    if 1:
        color=(random.random(),random.random(),1.)
        f.ViewObject.ShapeColor = color
        f.ViewObject.LineColor = color
        f.ViewObject.PointColor = color

    #f.ViewObject.Transparency = transparency

    #say("E",time.time()-timeA) 
開發者ID:microelly2,項目名稱:NodeEditor,代碼行數:50,代碼來源:dev.py

示例12: Activated

# 需要導入模塊: import FreeCADGui [as 別名]
# 或者: from FreeCADGui import runCommand [as 別名]
def Activated(self):
        # check that we have somewhere to put our stuff
        selectedObj = self.checkSelection()
        
        # check whether we have selected a container
        if selectedObj.TypeId in self.containers:
            parentContainer = selectedObj
        # if a datum object is selected we try to find the parent container
        elif selectedObj.TypeId in self.datumTypes:
            parent = selectedObj.getParentGeoFeatureGroup()
            if parent.TypeId in self.containers:
                parentContainer = parent
        # something went wrong
        else:
            Asm4.warningBox("I can't create a "+self.datumType+" with the current selections")
            
        # check whether there is already a similar datum, and increment the instance number 
        # instanceNum = 1
        #while App.ActiveDocument.getObject( self.datumName+'_'+str(instanceNum) ):
        #    instanceNum += 1
        #datumName = self.datumName+'_'+str(instanceNum)
        if parentContainer:
            # input dialog to ask the user the name of the Sketch:
            proposedName = Asm4.nextInstance( self.datumName, startAtOne=True )
            text,ok = QtGui.QInputDialog.getText(None,'Create new '+self.datumName,
                    'Enter '+self.datumName+' name :'+' '*40, text = proposedName)
            if ok and text:
                # App.activeDocument().getObject('Model').newObject( 'Sketcher::SketchObject', text )
                createdDatum = parentContainer.newObject( self.datumType, text )
                # automatic resizing of datum Plane sucks, so we set it to manual
                if self.datumType=='PartDesign::Plane':
                    createdDatum.ResizeMode = 'Manual'
                    createdDatum.Length = 100
                    createdDatum.Width = 100
                # if color or transparency is specified for this datum type
                if self.datumColor:
                    Gui.ActiveDocument.getObject(createdDatum.Name).ShapeColor = self.datumColor
                if self.datumAlpha:
                    Gui.ActiveDocument.getObject(createdDatum.Name).Transparency = self.datumAlpha
                # highlight the created datum object
                Gui.Selection.clearSelection()
                Gui.Selection.addSelection( App.ActiveDocument.Name, parentContainer.Name, createdDatum.Name+'.' )
                #Gui.runCommand('Part_EditAttachment') 
開發者ID:Zolko-123,項目名稱:FreeCAD_Assembly4,代碼行數:45,代碼來源:newDatumCmd.py


注:本文中的FreeCADGui.runCommand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。