本文整理汇总了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')
示例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')
示例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
示例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")
示例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
示例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() )
#==============================================================================
示例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
示例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' )
示例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()
示例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() )
示例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)
示例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')