本文整理汇总了Python中FreeCAD.closeDocument方法的典型用法代码示例。如果您正苦于以下问题:Python FreeCAD.closeDocument方法的具体用法?Python FreeCAD.closeDocument怎么用?Python FreeCAD.closeDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FreeCAD
的用法示例。
在下文中一共展示了FreeCAD.closeDocument方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_AA
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def test_AA():
import FreeCAD
import FreeCADGui
App=FreeCAD
Gui=FreeCADGui
### Begin command Std_RecentFiles
try:
App.closeDocument('Unnamed')
except:
pass
App.setActiveDocument("")
App.ActiveDocument=None
Gui.ActiveDocument=None
FreeCAD.open(u"/home/thomas/Schreibtisch/move_2.FCStd")
App.setActiveDocument("move_2")
App.ActiveDocument=App.getDocument("move_2")
Gui.ActiveDocument=Gui.getDocument("move_2")
### End command Std_RecentFiles
loadGraph()
示例2: test_store_serial
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def test_store_serial(datadir, fix_FCDoc):
"""Test serialisation to memory."""
import FreeCAD
# Serialise document
obj = fix_FCDoc.addObject("App::FeaturePython", "some_content")
serial_data = store_serial(fix_FCDoc, lambda d, p: d.saveAs(p), "fcstd")
# Write to a file
file_path = os.path.join(datadir, "test.fcstd")
data = codecs.decode(serial_data.encode(), "base64")
with open(file_path, "wb") as of:
of.write(data)
# Load back and check
doc = FreeCAD.newDocument("instance")
FreeCAD.setActiveDocument("instance")
doc.load(file_path)
assert doc.getObject("some_content") is not None
FreeCAD.closeDocument("instance")
示例3: _test_file
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def _test_file( self, testFile_basename, solution = None ):
testFile = os.path.join( test_assembly_path, testFile_basename + '.fcstd' )
debugPrint(1, testFile_basename )
stats.n_attempted += 1
#if testFile == 'tests/testAssembly11-Pipe_assembly.fcstd':
# print('Skipping known fail')
# continue
doc = FreeCAD.open(testFile)
t_start_solver = time.time()
xOpt = solveConstraints( doc, solver_name = 'newton_solver_slsqp', use_cache = self.use_cache, showFailureErrorDialog=False )
if solution:
self.check_solution( xOpt, solution )
stats.t_solver += time.time() - t_start_solver
assert not self.use_cache
if not xOpt is None:
stats.n_solved += 1
FreeCAD.closeDocument( doc.Name )
debugPrint(1,'\n\n\n')
return xOpt
示例4: shutdown
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [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: Activated
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def Activated(self):
doc = FreeCAD.activeDocument()
try:
doc.save()
FreeCAD.closeDocument(doc.Name)
except:
FreeCADGui.SendMsgToActiveView("Save")
if not FreeCADGui.activeDocument().Modified: # user really saved the file
FreeCAD.closeDocument(doc.Name)
#
mw = FreeCADGui.getMainWindow()
mdi = mw.findChild(QtGui.QMdiArea)
sub = mdi.activeSubWindow()
if sub != None:
sub.showMaximized()
示例6: fix_FCDoc
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def fix_FCDoc():
"""Set up and tear down a FreeCAD document."""
import FreeCAD
doc = FreeCAD.newDocument("testDoc")
yield doc
FreeCAD.closeDocument("testDoc")
################################################################################
# Sketches
示例7: test_overlapping_parts
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def test_overlapping_parts(datadir):
"""
This tests that two parts that were generated from lithography over a wire register as intersecting. Due to
an OCC bug, FC 0.18 at one point would claim that these didn't intersect, resulting in geometry and meshing errors.
"""
path = os.path.join(datadir, "intersection_test.FCStd")
doc = FreeCAD.newDocument("instance")
FreeCAD.setActiveDocument("instance")
doc.load(path)
shape_1 = doc.Objects[0]
shape_2 = doc.Objects[1]
assert checkOverlap([shape_1, shape_2])
FreeCAD.closeDocument(doc.Name)
示例8: _test_file
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def _test_file( self, testFile_basename, solution = None ):
testFile = os.path.join( test_assembly_path, testFile_basename + '.fcstd' )
debugPrint(1, testFile_basename )
stats.n_attempted += 1
#if testFile == 'tests/testAssembly11-Pipe_assembly.fcstd':
# print('Skipping known fail')
# continue
doc = FreeCAD.open(testFile)
t_start_solver = time.time()
constraintSystem = solveConstraints( doc, solver_name = 'dof_reduction_solver', use_cache = self.use_cache, showFailureErrorDialog=False )
if solution:
self.check_solution( constraintSystem, solution )
stats.t_solver += time.time() - t_start_solver
if self.use_cache:
debugPrint(1,'\n\n')
X_org = constraintSystem.variableManager.X
t_start_cache = time.time()
#cache.debugMode = 1
constraintSystem = solveConstraints( doc, solver_name = 'dof_reduction_solver', use_cache = self.use_cache )
self.assertTrue(
numpy.allclose( X_org , constraintSystem.variableManager.X ),
'Cache solution differs from originial solution: %s != %s' % ( X_org , constraintSystem.variableManager.X )
)
#cache.debugMode = 0
stats.t_cache += time.time() - t_start_cache
constraintSystem.update()
stats.n_solved += 1
FreeCAD.closeDocument( doc.Name )
debugPrint(1,'\n\n\n')
示例9: Activated
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def Activated(self):
# So we can open the save-as dialog
mw = FreeCADGui.getMainWindow()
cqCodePane = Shared.getActiveCodePane()
if cqCodePane == None:
FreeCAD.Console.PrintError("Nothing to save.\r\n")
return
# Try to keep track of the previous path used to open as a convenience to the user
if self.previousPath is None:
self.previousPath = "/home/"
filename = QtGui.QFileDialog.getSaveFileName(mw, mw.tr("Save CadQuery Script As"), self.previousPath,
mw.tr("CadQuery Files (*.py)"))
self.previousPath = filename[0]
# Make sure the user didn't click cancel
if filename[0]:
# Close the 3D view for the original script if it's open
try:
docname = os.path.splitext(os.path.basename(cqCodePane.get_path()))[0]
FreeCAD.closeDocument(docname)
except:
# Assume that there was no 3D view to close
pass
# Change the name of our script window's tab
Shared.setActiveWindowTitle(os.path.basename(filename[0]))
# Save the file before closing the original and the re-rendering the new one
ExportCQ.save(filename[0])
CadQueryExecuteScript().Activated()
示例10: tearDown
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def tearDown(self):
FreeCAD.closeDocument("AnimTest")
pass
示例11: close_CQ_Example
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import closeDocument [as 别名]
def close_CQ_Example(App, Gui):
#close the example
App.setActiveDocument("Ex000_Introduction")
App.ActiveDocument=App.getDocument("Ex000_Introduction")
Gui.ActiveDocument=Gui.getDocument("Ex000_Introduction")
App.closeDocument("Ex000_Introduction")
FreeCAD.Console.PrintMessage('\r\nEx000 Closed\r\n')
#Getting the main window will allow us to start setting things up the way we want
mw = FreeCADGui.getMainWindow()
#Adjust the docks as usual
dockWidgets = mw.findChildren(QtGui.QDockWidget)
for widget in dockWidgets:
if (widget.objectName() == "Report view") or (widget.objectName() == "Python console") or (widget.objectName() == "Combo View"):
widget.setVisible(True)
if (widget.objectName()=="cqCodeView"):
widget.setVisible(False)
FreeCAD.Console.PrintMessage('Dock adjusted\r\n')
return 0
###################################################################
# FuseObjs_wColors() maui
# Function to fuse two objects together.
###################################################################