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


Python FreeCADGui.ActiveDocument方法代码示例

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


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

示例1: build

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def build(self):
        self.active = False
        if not hasattr(self,'switch'):
            self.sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
            self.switch = coin.SoSwitch()
            if hasattr(self,'Object'):
                self.switch.setName("%s_ControlPoints"%self.Object.Name)
            self.empty = coin.SoSeparator() # Empty node
            self.node = coin.SoSeparator()
            self.coord = CoinNodes.coordinate3Node()
            self.poly = CoinNodes.polygonNode((0.5,0.5,0.5),1)
            self.marker = CoinNodes.markerSetNode((1,0,0),coin.SoMarkerSet.DIAMOND_FILLED_7_7)
            self.node.addChild(self.coord)
            self.node.addChild(self.poly)
            self.node.addChild(self.marker)
            self.switch.addChild(self.empty)
            self.switch.addChild(self.node)
            self.sg.addChild(self.switch) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:20,代码来源:ParametricBlendCurve.py

示例2: Activated

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def Activated(self):
        try:
            s = FreeCADGui.activeWorkbench().Selection
        except AttributeError:
            s = FreeCADGui.Selection.getSelectionEx()
        edges, param = self.parseSel(s)
        if len(edges) > 1:
            for j in range(int(len(edges)/2)):
                i = j*2
                obj=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Blend Curve") #add object to document
                BlendCurveFP(obj,edges[i:i+2])
                BlendCurveVP(obj.ViewObject)
                obj.Parameter1 = self.normalizedParam(edges[i], param[i], False)
                obj.Parameter2 = self.normalizedParam(edges[i+1], param[i+1], False)
                obj.Continuity1 = "G1"
                obj.Continuity2 = "G1"
                obj.Output = "Single"
                ori1, ori2 = self.getOrientation(edges[i], param[i], edges[i+1], param[i+1])
                obj.Scale1 = ori1
                obj.Scale2 = ori2
        FreeCAD.ActiveDocument.recompute() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:23,代码来源:ParametricBlendCurve.py

示例3: Activated

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def Activated(self):

        import re
        ta=False
        if ta:
            FreeCAD.ActiveDocument.openTransaction(self.name)
        if self.command != '':
            if self.modul != '':
                modul = self.modul
            else:
                modul = self.name
                
            Gui.doCommand('from importlib import reload')
            Gui.doCommand("import " + modul)
            Gui.doCommand("import " + self.lmod)
            Gui.doCommand("reload(" + self.lmod+")")
            Gui.doCommand(self.command)
        if ta:
            FreeCAD.ActiveDocument.commitTransaction()
        if FreeCAD.ActiveDocument != None:
            FreeCAD.ActiveDocument.recompute() 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:23,代码来源:InitGui.py

示例4: ConeTorusBoxandImagenode

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def ConeTorusBoxandImagenode():

    instance=pfwrap.getInstance()
    clearGraph()
    gg=pfwrap.getGraphManager().getAllGraphs()[0]

    FreeCAD.ActiveDocument.addObject("Part::Cone","Cone")
    FreeCAD.ActiveDocument.addObject("Part::Torus","Torus")
    FreeCAD.ActiveDocument.addObject("Part::Box","Box")

    t = pfwrap.createNode('PyFlowBase',"imageDisplay","ImageXX")
    t.setPosition(-100,-200)
    t.entity.setData('/home/thomas/Bilder/freeka.png')
    t.compute()
    #t.setData("shapeOnly",True)
    gg.addNode(t)

    refresh_gui() 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:20,代码来源:Commands.py

示例5: onChanged

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def onChanged(self, fp, prop):
    if prop=='Base' and hasattr(fp,'OD') and hasattr(fp,'thk') and hasattr(fp,'BendRadius'):
      self.purge(fp)
      self.redraw(fp)
    if prop=='BendRadius' and hasattr(fp,'Curves'):
      BR=fp.BendRadius
      for curve in [FreeCAD.ActiveDocument.getObject(name) for name in fp.Curves]:
        curve.BendRadius=BR
    if prop=='OD' and hasattr(fp,'Tubes') and hasattr(fp,'Curves'):
      OD=fp.OD
      for obj in [FreeCAD.ActiveDocument.getObject(name) for name in fp.Tubes+fp.Curves]:
        if obj.PType=='Elbow': obj.BendRadius=OD*.75
        obj.OD=OD
      fp.BendRadius=OD*.75
    if prop=='thk' and hasattr(fp,'Tubes') and hasattr(fp,'Curves'):
      thk=fp.thk
      for obj in [FreeCAD.ActiveDocument.getObject(name) for name in fp.Tubes+fp.Curves]:
        if hasattr(obj,'thk'): obj.thk=thk 
开发者ID:oddtopus,项目名称:flamingo,代码行数:20,代码来源:pipeFeatures.py

示例6: execute

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def execute(self, fp):
    if len(fp.Tubes)!=len(fp.Base.Shape.Edges):
      self.purge(fp)
      self.redraw(fp)
      return
    from math import tan
    for i in range(len(fp.Tubes)):
      L=fp.Base.Shape.Edges[i].Length
      R=fp.BendRadius
      # adjust the curve
      if i<len(fp.Curves):
        c=FreeCAD.ActiveDocument.getObject(fp.Curves[i])
        v1,v2=[e.tangentAt(0) for e in fp.Base.Shape.Edges[i:i+2]]
        pipeCmd.placeTheElbow(c,v1,v2) 
        alfa=float(v1.getAngle(v2))/2
        L-=float(R*tan(alfa)) 
      # adjust the pipes
      if i: 
        v1,v2=[e.tangentAt(0) for e in fp.Base.Shape.Edges[i-1:i+1]]
        alfa=float(v1.getAngle(v2))/2
        tang=float(R*tan(alfa)) 
        L-=tang
        FreeCAD.ActiveDocument.getObject(fp.Tubes[i]).AttachmentOffset.Base=FreeCAD.Vector(0,0,tang)
      FreeCAD.ActiveDocument.getObject(fp.Tubes[i]).Height=L 
开发者ID:oddtopus,项目名称:flamingo,代码行数:26,代码来源:pipeFeatures.py

示例7: Activated

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def Activated(self):
        # retrieve Selection
        selection = FreeCAD.Gui.Selection.getSelectionEx()
        for i in range(len(selection)):
            # create WirePath folder if it does not exist
            try:
                WPFolder = FreeCAD.ActiveDocument.WirePath

            except:
                WPFolder = FreeCAD.ActiveDocument.addObject('App::DocumentObjectGroupPython', 'WirePath')
                NiCrPath.WirePathFolder(WPFolder)
                NiCrPath.WirePathViewProvider(WPFolder)

            # create shapepath object
            selObj = selection[i].Object
            shapepath_name = 'ShapePath_' + selObj.Name
            shapepathobj = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', shapepath_name)
            # initialize python object
            NiCrPath.ShapePath(shapepathobj, selObj)
            NiCrPath.ShapePathViewProvider(shapepathobj.ViewObject)
            # modify color
            shapepathobj.ViewObject.ShapeColor = (1.0, 1.0, 1.0)
            shapepathobj.ViewObject.LineWidth = 1.0
            WPFolder.addObject(shapepathobj) 
开发者ID:JMG1,项目名称:NiCr,代码行数:26,代码来源:NiCrInit.py

示例8: sew_Shape

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def sew_Shape():
    """checking Shape"""

    doc=FreeCAD.ActiveDocument
    docG = FreeCADGui.ActiveDocument

    sel=FreeCADGui.Selection.getSelection()
    if len (sel) == 1:
        o = sel[0]
        if hasattr(o,'Shape'):
            sh = o.Shape.copy()
            sh.sewShape()
            sl = Part.Solid(sh)
            docG.getObject(o.Name).Visibility = False
            Part.show(sl)
            ao = FreeCAD.ActiveDocument.ActiveObject
            ao.Label = 'Solid'
            docG.ActiveObject.ShapeColor=docG.getObject(o.Name).ShapeColor
            docG.ActiveObject.LineColor=docG.getObject(o.Name).LineColor
            docG.ActiveObject.PointColor=docG.getObject(o.Name).PointColor
            docG.ActiveObject.DiffuseColor=docG.getObject(o.Name).DiffuseColor
            docG.ActiveObject.Transparency=docG.getObject(o.Name).Transparency
    else:
        FreeCAD.Console.PrintError('select only one object') 
开发者ID:shaise,项目名称:FreeCAD_SheetMetal,代码行数:26,代码来源:SheetMetalUnfolder.py

示例9: createBounder

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def createBounder(name='MyBounder'):
	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::PropertyLink","obj","Object","Objekt")

	obj.addProperty("App::PropertyBool","x","intervall","start").x=False
	obj.addProperty("App::PropertyFloat","xmin","intervall","va")
	obj.addProperty("App::PropertyFloat","xmax","intervall","ve")

	obj.addProperty("App::PropertyBool","y","intervall","start").y=False
	obj.addProperty("App::PropertyFloat","ymin","intervall","va")
	obj.addProperty("App::PropertyFloat","ymax","intervall","ve")

	obj.addProperty("App::PropertyBool","z","intervall","start").z=False
	obj.addProperty("App::PropertyFloat","zmin","intervall","va")
	obj.addProperty("App::PropertyFloat","zmax","intervall","ve")

## mod
	_Bounder(obj,'/icons/bounder.png')
	_ViewProviderActor(obj.ViewObject,'/icons/bounder.png') 
	return obj 
开发者ID:microelly2,项目名称:Animation,代码行数:27,代码来源:Animation.py

示例10: createMoviescreen

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def createMoviescreen(name='My_Moviescreen'):

	obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
	obj.addProperty("App::PropertyIntegerList","pictureStart","info","Rotationsachse Zentrum relativ").pictureStart=[0,50,100]
	obj.addProperty("App::PropertyPath","pictures","screen","text").pictures="/home/microelly2/pics/t%04.f.png"
	obj.addProperty("App::PropertyLink","rectangle","screen","moving object ")

	obj.rectangle = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","Rectangle Moviescreen")
	Draft._Rectangle(obj.rectangle)
	obj.rectangle.Length = 64
	obj.rectangle.Height = 48
	obj.rectangle.MakeFace = True
	Draft._ViewProviderRectangle(obj.rectangle.ViewObject)
	tx=FreeCADGui.activeDocument().activeView()
	rx=tx.getCameraOrientation()
	obj.rectangle.Placement.Rotation=rx
	_Moviescreen(obj)
	return obj 
开发者ID:microelly2,项目名称:Animation,代码行数:20,代码来源:Animation.py

示例11: rot

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def rot(self,angle=0):
		FreeCAD.uu=self
		#say("rotate " + str(self.obj2.Label) + " angle=" +str(angle))
		if self.obj2.ModeMotion =='Vector':
			#say(self.obj2.vectorMotion)
			
			a=FreeCAD.Placement()
			a.Base=self.obj2.vectorMotion
			zzz=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),angle)
			r=FreeCAD.Placement()
			r.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),angle)
			a2=r.multiply(a)
			
			self.obj2.vectorMotion=a2.Base
			FreeCAD.ActiveDocument.recompute()
					
			# self.obj2.vectorMotion=multiply(self.obj2.vectorMotion)
			#say(self.obj2.vectorMotion) 
开发者ID:microelly2,项目名称:Animation,代码行数:20,代码来源:Animation.py

示例12: IsActive

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def IsActive(self):
        if FreeCADGui.ActiveDocument:
            if not(FreeCAD.ActiveDocument.ExplodedAssembly.InAnimation):
                return True

        else:
            return False 
开发者ID:JMG1,项目名称:ExplodedAssembly,代码行数:9,代码来源:EAInit.py

示例13: Activated

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import ActiveDocument [as 别名]
def Activated(self):
        EA = FreeCAD.ActiveDocument.ExplodedAssembly
        if EA.CurrentTrajectory <= 0:
            # if exploded state = 0 or -1, reset and run
            ea.resetPlacement()
            ea.runAnimation()

        else:
            # if animation has been paused in the middle:
            cr_traj = EA.Group[EA.CurrentTrajectory]
            ea.runAnimation(start=EA.CurrentTrajectory+1, mode='toPoint') 
开发者ID:JMG1,项目名称:ExplodedAssembly,代码行数:13,代码来源:EAInit.py


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