本文整理匯總了Python中FreeCAD.open方法的典型用法代碼示例。如果您正苦於以下問題:Python FreeCAD.open方法的具體用法?Python FreeCAD.open怎麽用?Python FreeCAD.open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FreeCAD
的用法示例。
在下文中一共展示了FreeCAD.open方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_AA
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [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: Activated
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [as 別名]
def Activated(self):
doc = FreeCAD.activeDocument()
if doc is None:
QtGui.QMessageBox.information( QtGui.QApplication.activeWindow(),
"No active document found!",
"You have to open an assembly file first."
)
return
assemblyPath = os.path.normpath( os.path.split( os.path.normpath(doc.FileName) )[0])
importParts = [ob for ob in doc.Objects if "mportPart" in ob.Content]
for iPart in importParts:
if (
iPart.sourceFile.startswith("./") or
iPart.sourceFile.startswith("../") or
iPart.sourceFile.startswith(".\\") or
iPart.sourceFile.startswith("..\\")
): continue # path is already relative
filePath = os.path.normpath(iPart.sourceFile)
if platform.system() == "Windows":
prefix = '.\\'
else:
prefix = './'
iPart.sourceFile = prefix + os.path.relpath(filePath, assemblyPath)
示例3: _test_file
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [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: Activated
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [as 別名]
def Activated(self):
FreeCAD.open(__dir__ + '/example.fcstd')
示例5: reset
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [as 別名]
def reset():
'''file laden und graph anzeigen testcase'''
if 'aa' not in FreeCAD.listDocuments().keys():
FreeCAD.open(u"/home/thomas/aa.FCStd")
FreeCAD.setActiveDocument("aa")
try:
pfwrap.deleteInstance()
del(FreeCAD.PF)
except:
pass
instance=pfwrap.getInstance()
clearGraph()
loadGraph()
示例6: loadFile
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [as 別名]
def loadFile():
hidePyFlow()
if 'graph' not in FreeCAD.listDocuments().keys():
FreeCAD.open(u"/home/thomas/graph.FCStd")
FreeCAD.setActiveDocument("graph")
clearGraph()
loadGraph()
示例7: loadAll
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [as 別名]
def loadAll():
showPyFlow()
try:
FreeCAD.getDocument(fn)
except:
FreeCAD.open(u"/home/thomas/{}.FCStd".format(fn))
FreeCAD.setActiveDocument(fn)
FreeCAD.ActiveDocument=FreeCAD.getDocument(fn)
FreeCADGui.ActiveDocument=FreeCADGui.getDocument(fn)
loadGraph()
pass
示例8: GetResources
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [as 別名]
def GetResources(self):
return {
'Pixmap' : a2plib.pathOfModule()+'/icons/a2p_EditPart.svg',
'MenuText': 'Edit an imported part (open linked FCStd file)',
'ToolTip': toolTip
}
示例9: _test_file
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [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')
示例10: refresh_gui
# 需要導入模塊: import FreeCAD [as 別名]
# 或者: from FreeCAD import open [as 別名]
def refresh_gui():
store=saveGraph(False)
# say(store)
loadGraph(store)
return
sayl("REFRESH---------")
hidePyFlow()
# tempd=pfwrap.getInstance().getTempDirectory()
instance=pfwrap.getInstance()
saveData = instance.graphManager.get().serialize()
gg=pfwrap.getGraphManager().getAllGraphs()[0]
say(gg)
#geaendert
# saveData = pfwrap.getGraphManager().serialize()
# saveData = pfwrap.getGraphManager().serialize()
# json.dump(saveData, f, indent=4)
#saveData = gg.serialize()
sayl("naCH SE")
import tempfile
f = tempfile.NamedTemporaryFile(delete=False)
fpath= f.name
say("HUEW")
say(saveData)
say(f)
say("---------------")
json.dump(saveData, f, indent=4)
f.close()
say("fname",fpath)
sayl("CCC")
with open(fpath, 'r') as f:
data = json.load(f)
FreeCAD.data=data
pfwrap.getInstance().loadFromData(data, fpath)
sayl("huhu")
pfwrap.getInstance().show()
clearLogger()
FreeCADGui.activeDocument().activeView().viewIsometric()
FreeCADGui.SendMsgToActiveView("ViewFit")