当前位置: 首页>>代码示例>>Python>>正文


Python FreeCAD.ActiveDocument方法代码示例

本文整理汇总了Python中FreeCAD.ActiveDocument方法的典型用法代码示例。如果您正苦于以下问题:Python FreeCAD.ActiveDocument方法的具体用法?Python FreeCAD.ActiveDocument怎么用?Python FreeCAD.ActiveDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FreeCAD的用法示例。


在下文中一共展示了FreeCAD.ActiveDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def Activated(self):
        cb = QtGui.QApplication.clipboard()
        t=cb.text()

        if t[0:5] == '<?xml':
            h = importSVG.svgHandler()
            doc = FreeCAD.ActiveDocument
            if not doc:
                doc = FreeCAD.newDocument("SvgImport")
            h.doc = doc
            xml.sax.parseString(t,h)
            doc.recompute()
            FreeCADGui.SendMsgToActiveView("ViewFit")
        else:
            FreeCAD.Console.PrintError('Invalid clipboard content.\n')
        
    #def IsActive(self):
        #return(True) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:20,代码来源:pasteSVG.py

示例2: make_profile_sketch

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def make_profile_sketch(self):
        import Sketcher
        sk = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Profile')
        sk.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,0),FreeCAD.Rotation(0,0,0,1))
        sk.MapMode = "Deactivated"
        sk.addGeometry(Part.LineSegment(FreeCAD.Vector(100.0,0.0,0),FreeCAD.Vector(127.0,12.0,0)),False)
        sk.addConstraint(Sketcher.Constraint('PointOnObject',0,1,-1)) 
        sk.addGeometry(Part.ArcOfCircle(Part.Circle(FreeCAD.Vector(125.0,17.0,0),FreeCAD.Vector(0,0,1),5.8),-1.156090,1.050925),False)
        sk.addConstraint(Sketcher.Constraint('Tangent',0,2,1,1)) 
        sk.addGeometry(Part.LineSegment(FreeCAD.Vector(128.0,22.0,0),FreeCAD.Vector(100.0,37.0,0)),False)
        sk.addConstraint(Sketcher.Constraint('Tangent',1,2,2,1)) 
        sk.addConstraint(Sketcher.Constraint('Vertical',0,1,2,2)) 
        sk.addConstraint(Sketcher.Constraint('DistanceY',0,1,2,2,37.5)) 
        sk.setDatum(4,FreeCAD.Units.Quantity('35.000000 mm'))
        sk.renameConstraint(4, u'Lead')
        sk.setDriving(4,False)
        sk.addConstraint(Sketcher.Constraint('Equal',2,0)) 
        FreeCAD.ActiveDocument.recompute()
        return sk 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:21,代码来源:HelicalSweepFP.py

示例3: run

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def run():
    sel = Gui.Selection.getSelectionEx()
    try:
        if len(sel) != 1:
            raise Exception("Select one face only.")
        try:
            App.ActiveDocument.openTransaction("Macro IsoCurve")
            selfobj = makeIsoCurveFeature()
            so = sel[0].SubObjects[0]
            p = sel[0].PickedPoints[0]
            poe = so.distToShape(Part.Vertex(p))
            par = poe[2][0][2]
            selfobj.Face = [sel[0].Object,sel[0].SubElementNames]
            selfobj.Parameter = par[0]
            selfobj.Proxy.execute(selfobj)
        finally:
            App.ActiveDocument.commitTransaction()
    except Exception as err:
        from PySide import QtGui
        mb = QtGui.QMessageBox()
        mb.setIcon(mb.Icon.Warning)
        mb.setText("{0}".format(err))
        mb.setWindowTitle("Macro IsoCurve")
        mb.exec_() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:26,代码来源:IsoCurve2.py

示例4: set_link

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def set_link(self):
        #debug("%s.%s -> Set button pressed"%(self.obj.Label, self.link))
        subs = list()
        sel = FreeCADGui.Selection.getSelectionEx()
        if sel == []:
            FreeCAD.Console.PrintError("Nothing selected !\n")
        for selobj in sel:
            if selobj.HasSubObjects:
                subs.append(("(FreeCAD.ActiveDocument.getObject('%s'),%s)"%(selobj.Object.Name, selobj.SubElementNames)))
        if self.obj.getTypeIdOfProperty(self.link) == 'App::PropertyLinkSub':
            if not len(subs) == 1:
                FreeCAD.Console.PrintError("This property accept only 1 subobject !\n")
            else:
                #FreeCADGui.doCommand("subobj = FreeCAD.ActiveDocument.getObject('%s')"%(subs[0][0].Name))
                FreeCADGui.doCommand("FreeCAD.ActiveDocument.getObject('%s').%s = %s"%(self.obj.Name, self.link, subs[0]))
        elif self.obj.getTypeIdOfProperty(self.link) == 'App::PropertyLinkSubList':
                FreeCADGui.doCommand("FreeCAD.ActiveDocument.getObject('%s').%s = %s"%(self.obj.Name, self.link, self.concat(subs)))
        self.view_link() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:20,代码来源:sublink_edit.py

示例5: __init__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def __init__(self, points=[], fp = None):
        self.points = points
        self.curve = Part.BSplineCurve()
        self.fp = fp
        self.root_inserted = False
        #self.support = None # Not yet implemented
        if len(points) > 0:
            if isinstance(points[0],FreeCAD.Vector):
                self.points = [ConnectionMarker([p]) for p in points]
            elif isinstance(points[0],(tuple,list)):
                self.points = [MarkerOnEdge([p]) for p in points]
            else:
                FreeCAD.Console.PrintError("InterpolationPolygon : bad input")
        
        # Setup coin objects
        if not FreeCAD.ActiveDocument:
            appdoc = FreeCAD.newDocument("New")
        self.guidoc = FreeCADGui.ActiveDocument
        self.view = self.guidoc.ActiveView
        self.rm = self.view.getViewer().getSoRenderManager()
        self.sg = self.view.getSceneGraph()
        self.setup_InteractionSeparator()
        self.update_curve() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:25,代码来源:FC_interaction_example.py

示例6: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def Activated(self):
        import ExplodedAssembly as ea
        if not(FreeCAD.ActiveDocument):
            FreeCAD.newDocument()

        ea.checkDocumentStructure()
        FreeCAD.Console.PrintMessage('Exploded Assembly workbench loaded\n') 
开发者ID:JMG1,项目名称:ExplodedAssembly,代码行数:9,代码来源:InitGui.py

示例7: IsActive

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def IsActive(self):
        if not FreeCAD.ActiveDocument:
            return False
        if self._active is None:
            self._active = self.tp.checkActive()
        return self._active 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:8,代码来源:constraint.py

示例8: canAutoSolve

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def canAutoSolve(cls):
        from . import solver
        #  return gui.AsmCmdManager.WorkbenchActivated and \
        return gui.AsmCmdManager.AutoRecompute and \
               FreeCADGui.ActiveDocument and \
               not FreeCADGui.ActiveDocument.Transacting and \
               not FreeCAD.isRestoring() and \
               not solver.isBusy() and \
               not ViewProviderAssembly.isBusy() 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:11,代码来源:assembly.py

示例9: doAutoSolve

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def doAutoSolve(cls):
        if not cls._PendingSolve:
            return
        canSolve = cls.canAutoSolve()
        if cls._Busy or not canSolve:
            cls._PendingSolve = canSolve
            return

        cls.cancelAutoSolve()

        from . import solver
        logger.debug('start solving...')
        logger.catch('solver exception when auto recompute',
                solver.solve, FreeCAD.ActiveDocument.Objects, True)
        logger.debug('done solving') 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:17,代码来源:assembly.py

示例10: make

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def make(doc=None,name='Assembly',undo=True):
        if not doc:
            doc = FreeCAD.ActiveDocument
            if not doc:
                raise RuntimeError('No active document')
        if undo:
            FreeCAD.setActiveTransaction('Create assembly')
        try:
            obj = doc.addObject("Part::FeaturePython",name,Assembly(),None,True)
            obj.setPropertyStatus('Shape','Transient')
            ViewProviderAssembly(obj.ViewObject)
            obj.Visibility = True
            if gui.AsmCmdManager.AddOrigin:
                Assembly.addOrigin(obj.Proxy.getPartGroup())
            obj.purgeTouched()
            if undo:
                FreeCAD.closeActiveTransaction()
            FreeCADGui.Selection.pushSelStack()
            FreeCADGui.Selection.clearSelection()
            FreeCADGui.Selection.addSelection(obj)
            FreeCADGui.Selection.pushSelStack()
        except Exception:
            if undo:
                FreeCAD.closeActiveTransaction(True)
            raise
        return obj 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:28,代码来源:assembly.py

示例11: IsActive

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def IsActive(cls):
        if cls._id<0 or not FreeCAD.ActiveDocument:
            return False
        if cls._active is None:
            cls.checkActive()
        return cls._active 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:8,代码来源:gui.py

示例12: getPosition

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def getPosition(cls):
        if not cls._object:
            return
        try:
            if cls._object.Document != FreeCAD.ActiveDocument:
                cls._object = None
            return getElementPos((cls._object,cls._subname))
        except Exception:
            cls._object = None 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:11,代码来源:gui.py

示例13: __setstate__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def __setstate__(self,state):
        self.obj = FreeCAD.ActiveDocument.getObject(state["name"])
        if not "Algorithm" in self.obj.PropertiesList:
            self.obj.addProperty("App::PropertyEnumeration",  "Algorithm", "Method",   "Discretization Method").Algorithm=["Number","QuasiNumber","Distance","Deflection","QuasiDeflection","Angular-Curvature"]
        if not "Target" in self.obj.PropertiesList:
            self.obj.addProperty("App::PropertyEnumeration",  "Target",    "Discretization",   "Tool target").Target=["Edge","Wire"]
        self.obj.Algorithm = state["algo"]
        self.obj.Target = state["target"]
        return None 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:11,代码来源:Discretize.py

示例14: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def Activated(self):
        s = FreeCADGui.Selection.getSelectionEx()
        edges = self.parseSel(s)
        FreeCADGui.doCommand("from freecad.Curves import Discretize")
        for e in edges:
            FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Discretized_Edge")')
            FreeCADGui.doCommand('Discretize.Discretization(obj, (FreeCAD.ActiveDocument.getObject("%s"),"%s"))'%(e[0].Name,e[1][0]))
            FreeCADGui.doCommand('Discretize.ViewProviderDisc(obj.ViewObject)')
            FreeCADGui.doCommand('obj.ViewObject.PointSize = 3')
            #obj=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Discretized_Edge")
            #Discretization(obj,e)
            #ViewProviderDisc(obj.ViewObject)
            #obj.ViewObject.PointSize = 3.00000
        FreeCAD.ActiveDocument.recompute() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:16,代码来源:Discretize.py

示例15: IsActive

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import ActiveDocument [as 别名]
def IsActive(self):
        if FreeCAD.ActiveDocument:
            #f = FreeCADGui.Selection.Filter("SELECT Part::Feature SUBELEMENT Edge COUNT 1..1000")
            #return f.match()
            return True
        else:
            return False 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:9,代码来源:Discretize.py


注:本文中的FreeCAD.ActiveDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。