本文整理汇总了Python中FreeCAD.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Python FreeCAD.getDocument方法的具体用法?Python FreeCAD.getDocument怎么用?Python FreeCAD.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FreeCAD
的用法示例。
在下文中一共展示了FreeCAD.getDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getGeomPoint
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def getGeomPoint(self):
obj = FreeCAD.getDocument(self.snapShape[0]).getObject(self.snapShape[1])
FreeCAD.Console.PrintMessage('%s\n'%str(self.snapShape))
if 'Vertex' in self.snapShape[2]:
n = eval(self.snapShape[2].lstrip('Vertex'))
shape = obj.Shape.Vertexes[n-1]
if 'Point' in self.snapShape[2]: # Datum Point
shape = obj.Shape
elif 'Edge' in self.snapShape[2]:
n = eval(self.snapShape[2].lstrip('Edge'))
shape = obj.Shape.Edges[n-1]
elif 'Face' in self.snapShape[2]:
n = eval(self.snapShape[2].lstrip('Face'))
shape = obj.Shape.Faces[n-1]
v = Part.Vertex(self.point)
dist, pts, sols = v.distToShape(shape)
if len(pts) == 2:
self.point = pts[1]
示例2: test_AA
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [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()
示例3: addSelection
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def addSelection(self,doc,obj,sub,pnt):
lastSel=FreeCAD.getDocument(doc).getObject(obj)
subLastSel=lastSel.Shape.getElement(sub)
if lastSel.TypeId=='Part::FeaturePython' and hasattr(lastSel,"Height") and subLastSel.ShapeType=="Edge":
self.edges.append(subLastSel)
self.beams.append(lastSel)
FreeCAD.Console.PrintMessage('Edge/beam pair nr.'+str(len(self.edges))+' selected.\n')
if (len(self.edges)==len(self.beams)==2):
if frameCmd.isOrtho(*self.edges):
self.beams.reverse()
FreeCAD.ActiveDocument.openTransaction('Adjust angle')
for i in range(len(self.edges)):
frameCmd.extendTheBeam(self.beams[i],self.edges[i])
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.Console.PrintWarning("Adjustment executed.\n")
else:
FreeCAD.Console.PrintError("Edges must be orthogonal.\n")
self.edges=[]
self.beams=[]
FreeCADGui.Selection.clearSelection()
FreeCAD.activeDocument().recompute()
FreeCAD.Console.PrintWarning("Repeat selection or press [ESC]\n")
示例4: clearActiveDocument
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def clearActiveDocument():
"""Clears the currently active 3D view so that we can re-render"""
# Grab our code editor so we can interact with it
mw = FreeCADGui.getMainWindow()
mdi = mw.findChild(QtGui.QMdiArea)
currentWin = mdi.currentSubWindow()
if currentWin == None:
return
winName = currentWin.windowTitle().split(" ")[0].split('.')[0]
# Translate dashes so that they can be safetly used since theyare common
if '-' in winName:
winName= winName.replace('-', "__")
try:
doc = FreeCAD.getDocument(winName)
# Make sure we have an active document to work with
if doc is not None:
for obj in doc.Objects:
doc.removeObject(obj.Name)
except:
pass
示例5: createStyler
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def createStyler(name='MyStyler'):
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
obj.addProperty("App::PropertyInteger","start","Base","start").start=10
obj.addProperty("App::PropertyInteger","end","Base","end").end=40
obj.addProperty("App::PropertyInteger","duration","Base","end")
# obj.addProperty("App::PropertyFloat","va","intervall","va").va=0
# obj.addProperty("App::PropertyFloat","ve","intervall","ve").ve=40
obj.addProperty("App::PropertyLink","obj","Object","Objekt")
# obj.addProperty("App::PropertyInteger","nr","Object","nummer Datum").nr=1#
# obj.addProperty("App::PropertyEnumeration","unit","3D Param","einheit").unit=['deg','mm']
# FreeCADGui.getDocument("Unnamed").getObject("Box").Transparency = 2
obj.addProperty("App::PropertyBool","transparency","Transparency","start").transparency=False
obj.addProperty("App::PropertyInteger","transpaStart","Transparency","start").transpaStart=0
obj.addProperty("App::PropertyInteger","transpaEnd","Transparency","end").transpaEnd=40
obj.addProperty("App::PropertyEnumeration","DisplayStyle","Transparency","end").DisplayStyle=['Flat Lines','Shaded','Wireframe']
obj.addProperty("App::PropertyBool","visibility","Visibility","toggle visibility").visibility=False
# obj.addProperty("App::PropertyInteger","transpaStart","transparency","start").transpaStart=0
# obj.addProperty("App::PropertyInteger","transpaEnd","transparency","end").transpaEnd=40
_Styler(obj)
_ViewProviderStyler(obj.ViewObject)
return obj
示例6: setElementVisible
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def setElementVisible(self,docname,objname,subname,vis,presel=False):
if FreeCAD.isRestoring():
self.resetElementVisible()
return
if not AsmCmdManager.AutoElementVis \
or (self.viewParam and self.viewParam.GetBool('ShowSelectionOnTop',False)):
self.elements.clear()
return
doc = FreeCAD.getDocument(docname)
if not doc:
return
obj = doc.getObject(objname)
if not obj:
return
key = (docname,objname,subname)
val = None
if not vis:
val = self.elements.get(key,None)
if val is None or (presel and val):
return
if logger.catchWarn('',self._setElementVisible,
obj,subname,vis) is False and presel:
return
if not vis:
self.elements.pop(key,None)
elif not presel:
self.elements[key] = True
else:
self.elements.setdefault(key,False)
示例7: resetElementVisible
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def resetElementVisible(self):
elements = list(self.elements)
self.elements.clear()
for docname,objname,subname in elements:
doc = FreeCAD.getDocument(docname)
if not doc:
continue
obj = doc.getObject(objname)
if not obj:
continue
logger.catchWarn('',self._setElementVisible,obj,subname,False)
示例8: set_prop
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def set_prop(self,data):
docname = self.fp.Document.Name
objname = self.fp.Name
st = "FreeCAD.getDocument('"+docname+"').getObject('"+objname+"')."+self.prop+"="+str(data)
FreeCADGui.doCommand(st)
示例9: insert
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def insert(filename,docname):
"called when freecad imports a file"
global doc
groupname = os.path.splitext(os.path.basename(filename))[0]
try:
doc=FreeCAD.getDocument(docname)
except NameError:
doc=FreeCAD.newDocument(docname)
if filename.lower().endswith('.3dm'):
process3DM(doc,filename)
示例10: setPreselection
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def setPreselection(self,doc,obj,sub):
snapObj = FreeCAD.getDocument(doc).getObject(obj)
if 'Vertex' in sub:
n = eval(sub.lstrip('Vertex'))
self.snapShape = snapObj.Shape.Vertexes[n-1]
elif 'Edge' in sub:
n = eval(sub.lstrip('Edge'))
self.snapShape = snapObj.Shape.Edges[n-1]
elif 'Face' in sub:
n = eval(sub.lstrip('Face'))
self.snapShape = snapObj.Shape.Faces[n-1]
示例11: old_main
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def old_main():
doc = App.getDocument("Gordon_1")
appro = doc.getObject("Approximation_Curve")
appface = appro.Shape.Face1
ruled = doc.getObject("Ruled_Surface")
rulface = ruled.Shape.Face1
r1 = ruled.Shape.Edge1
r2 = ruled.Shape.Edge2
surf1 = appface.Surface.copy()
surf2 = rulface.Surface.copy()
matchUDegree( surf1, surf2)
matchURange( surf1, surf2)
matchVDegree( surf1, surf2)
matchVRange( surf1, surf2)
matchUknots( surf1, surf2)
matchVknots( surf1, surf2)
matchUMults( surf1, surf2)
matchVMults( surf1, surf2)
# Now, the 2 surfaces should have identical topologies (same degrees, knots, mults)
# Only their poles, weights are different
#print(surf1.getPoles()[0])
#print(surf2.getPoles()[0])
surf1.exchangeUV()
surf2.exchangeUV()
l = len(surf1.getPoles())
surf1.setPoleRow(1,surf2.getPoles()[0])
surf1.setPoleRow(l,surf2.getPoles()[-1])
Part.show(surf1.toShape())
#Part.show(surf2.toShape())
示例12: main
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def main():
doc = FreeCAD.getDocument("Gordon_1")
loft = doc.getObject("Loft")
profloft = loft.Shape.Face1
inter = doc.getObject("Shape")
interpts = inter.Shape.Face1
loft2 = doc.getObject("Ruled_Surface")
railloft = loft2.Shape.Face1
surf1 = profloft.Surface.copy()
surf2 = railloft.Surface.copy()
surf3 = interpts.Surface.copy()
surf1.exchangeUV()
matchSurfaces(surf1, surf2)
matchSurfaces(surf2, surf3)
matchSurfaces(surf3, surf1)
checkPoles([surf1,surf2,surf3])
# Now, the 3 surfaces should have identical topologies (same degrees, knots, mults)
# Only their poles, weights are different
poles1 = addPoles(surf1.getPoles(), surf2.getPoles())
poles2 = subPoles(poles1, surf3.getPoles())
gordon = surf1.copy()
for i in range(len(poles2)):
gordon.setPoleRow(i+1, poles2[i])
Part.show(surf1.toShape())
Part.show(surf2.toShape())
Part.show(surf3.toShape())
Part.show(gordon.toShape())
示例13: loadAll
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [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
示例14: __init__
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [as 别名]
def __init__(self, docName, objName, sub):
self.Document = FreeCAD.getDocument(docName)
self.ObjectName = objName
self.Object = self.Document.getObject(objName)
self.SubElementNames = [sub]
#------------------------------------------------------------------------------
示例15: close_CQ_Example
# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import getDocument [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.
###################################################################