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


Python FreeCAD.newDocument方法代码示例

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


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

示例1: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [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: __init__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [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

示例3: test_store_serial

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [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") 
开发者ID:microsoft,项目名称:qmt,代码行数:24,代码来源:test_data_data_utils.py

示例4: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [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

示例5: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [as 别名]
def Activated(cls,idx=0):
        _ = idx
        from .assembly import Assembly

        objs = []
        for obj in FreeCADGui.Selection.getSelection():
            if obj.isDerivedFrom('App::LinkGroup'):
                objs.append(obj)
            else:
                objs = None
                break

        filenames = None
        if not objs:
            filenames = QtGui.QFileDialog.getOpenFileNames(
                    QtGui.QApplication.activeWindow(), 'Please select file',
                    None, 'STEP (*.stp *.step);;All (*.*)')[0]
            if not filenames:
                return

        FreeCAD.setActiveTransaction('Assembly import')

        doc = FreeCAD.ActiveDocument
        if not doc:
            doc = FreeCAD.newDocument()

        if filenames:
            import ImportGui
            for name in filenames:
                obj = ImportGui.insert(name,doc.Name,merge=False,
                            useLinkGroup=True,mode=cls.importMode())
                if obj:
                    objs.append(obj)

        for obj in objs:
            Assembly.fromLinkGroup(obj)
        FreeCAD.closeActiveTransaction()
        return 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:40,代码来源:gui.py

示例6: __init__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [as 别名]
def __init__(self, points=[], fp = None):
        self.points = list()
        self.fp = fp
        self.curve = None
        self.root_inserted = False
        self.ctrl_keys = {"i" : [self.insert],
                          "v" : [self.text_change],
                          "q" : [self.quit],
                          "\uffff" : [self.remove_point]}
        for p in points:
            if isinstance(p,FreeCAD.Vector):
                self.points.append(manipulators.ShapeSnap(p))
            elif isinstance(p,(tuple,list)):
                self.points.append(manipulators.ShapeSnap(p[0],p[1]))
            elif isinstance(p, manipulators.ShapeSnap):
                self.points.append(p)
            elif isinstance(p, manipulators.CustomText):
                self.points.append(p)
            else:
                FreeCAD.Console.PrintError("pointEditor : bad input")
        for p in points:
            if hasattr(p, "ctrl_keys"):
                for key in p.ctrl_keys:
                    if key in self.ctrl_keys:
                        #print(key)
                        self.ctrl_keys[key].extend(p.ctrl_keys[key])
                    else:
                        self.ctrl_keys[key] = p.ctrl_keys[key]
                
        # Setup coin objects
        if self.fp:
            self.guidoc = self.fp.ViewObject.Document
        else:
            if not FreeCADGui.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() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:42,代码来源:ParametricBlendCurve.py

示例7: __init__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [as 别名]
def __init__(self, points=[], fp = None):
        self.points = list()
        self.curve = Part.BSplineCurve()
        self.fp = fp
        self.root_inserted = False
        self.periodic = False
        self.param_factor = 1.0
        #self.support = None # Not yet implemented
        for p in points:
            if isinstance(p,FreeCAD.Vector):
                self.points.append(MarkerOnShape([p]))
            elif isinstance(p,(tuple,list)):
                self.points.append(MarkerOnShape([p[0]],p[1]))
            elif isinstance(p,(MarkerOnShape, ConnectionMarker)):
                self.points.append(p)
            else:
                FreeCAD.Console.PrintError("InterpoCurveEditor : bad input")
        
        # Setup coin objects
        if self.fp:
            self.guidoc = self.fp.ViewObject.Document
        else:
            if not FreeCADGui.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,代码行数:32,代码来源:profile_editor.py

示例8: __init__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [as 别名]
def __init__(self, seg=[]):
        self.segments = list()
        #self.curve = Part.BSplineCurve()
        self.root_inserted = False
        #self.support = None # Not yet implemented
        for p in seg:
            if isinstance(p,FreeCAD.Vector):
                self.points.append(MarkerOnShape([p]))
            elif isinstance(p,(tuple,list)):
                self.points.append(MarkerOnShape([p[0]],p[1]))
            elif isinstance(p,(MarkerOnShape, ConnectionMarker)):
                self.points.append(p)
            else:
                FreeCAD.Console.PrintError("InterpoCurveEditor : bad input")
        # Setup coin objects
        if self.fp:
            self.guidoc = self.fp.ViewObject.Document
        else:
            if not FreeCADGui.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,代码行数:28,代码来源:blendsurf_editor.py

示例9: insert

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [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) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:12,代码来源:import3DM.py

示例10: getActiveDoc

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [as 别名]
def getActiveDoc():
    if FreeCAD.ActiveDocument is None:
        return FreeCAD.newDocument('kicad_fcad')
    return FreeCAD.ActiveDocument 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:6,代码来源:kicad.py

示例11: fix_FCDoc

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [as 别名]
def fix_FCDoc():
    """Set up and tear down a FreeCAD document."""
    import FreeCAD

    doc = FreeCAD.newDocument("testDoc")
    yield doc
    FreeCAD.closeDocument("testDoc")


################################################################################
# Sketches 
开发者ID:microsoft,项目名称:qmt,代码行数:13,代码来源:conftest.py

示例12: test_overlapping_parts

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [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) 
开发者ID:microsoft,项目名称:qmt,代码行数:15,代码来源:test_geo_objects.py

示例13: get_data

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [as 别名]
def get_data(self, data_name: str, scratch_dir: Optional[str] = None):
        """Get data from stored serial format.

        Parameters
        ----------
        data_name : str
            "fcdoc" freeCAD document.
        scratch_dir : str
            Optional existing temporary (fast) storage location. (Default value = None)
        mesh :
            (Default value = None)
        Returns
        -------
        data
        """
        if data_name == "fcdoc":

            def _load_fct(path):
                doc = FreeCAD.newDocument("instance")
                FreeCAD.setActiveDocument("instance")
                doc.load(path)
                return doc

            return load_serial(self.serial_fcdoc, _load_fct, scratch_dir=scratch_dir)
        else:
            raise ValueError(f"{data_name} was not a valid data_name.") 
开发者ID:microsoft,项目名称:qmt,代码行数:28,代码来源:geo_3d_data.py

示例14: test_simple_box

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [as 别名]
def test_simple_box( self ):
        Doc = FreeCAD.newDocument('doc1')
        Doc.addObject("Part::Box","Box")
        Doc.Box.Placement.Base = Base.Vector( 2, 3, 4 )
        Doc.recompute()
        d = self._test_parsing( Doc, '/tmp/test_a2import_block.fcstd' )
        self.assertTrue( d.Name == 'test_a2import_block', d.Name ) 
开发者ID:hamish2014,项目名称:FreeCAD_assembly2,代码行数:9,代码来源:tests.py

示例15: setUp

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import newDocument [as 别名]
def setUp(self):
		# setting a new document to hold the tests
		if FreeCAD.ActiveDocument:
			if FreeCAD.ActiveDocument.Name != "AnimTest":
				FreeCAD.newDocument("AnimTest")
		else:
			FreeCAD.newDocument("AnimTest")
		FreeCAD.setActiveDocument("AnimTest") 
开发者ID:microelly2,项目名称:Animation,代码行数:10,代码来源:TestAnim.py


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