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


Python FreeCADGui.activeDocument方法代码示例

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


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

示例1: addSelection

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

示例2: breakTheTubes

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def breakTheTubes(point,pipes=[],gap=0):
  '''
  breakTheTube(point,pipes=[],gap=0)
  Breaks the "pipes" at "point" leaving a "gap".
  '''
  pipes2nd=list()
  if not pipes:
    pipes=[p for p in frameCmd.beams() if isPipe(p)]
  if pipes:
    for pipe in pipes:
      if point<float(pipe.Height) and gap<(float(pipe.Height)-point):
        propList=[pipe.PSize,float(pipe.OD),float(pipe.thk),float(pipe.Height)-point-gap]
        pipe.Height=point
        Z=frameCmd.beamAx(pipe)
        pos=pipe.Placement.Base+Z*(float(pipe.Height)+gap)
        pipe2nd=makePipe(propList,pos,Z)
        pipes2nd.append(pipe2nd)
    #FreeCAD.activeDocument().recompute()
  return pipes2nd 
开发者ID:oddtopus,项目名称:flamingo,代码行数:21,代码来源:pipeCmd.py

示例3: makeRoute

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def makeRoute(n=Z):
  curvedEdges=[e for e in frameCmd.edges() if e.curvatureAt(0)!=0]
  if curvedEdges:
    s=FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','pipeRoute')
    s.MapMode = "SectionOfRevolution"
    s.Support = [frameCmd.edgeName()]
  else:
    return None
  if frameCmd.faces(): 
    n=frameCmd.faces()[0].normalAt(0,0)
  x=s.Placement.Rotation.multVec(X)
  z=s.Placement.Rotation.multVec(Z)
  t=x.dot(n)*x+z.dot(n)*z
  alfa=degrees(z.getAngle(t))
  if t.Length>0.000000001:
    s.AttachmentOffset.Rotation=s.AttachmentOffset.Rotation.multiply(FreeCAD.Rotation(Y,alfa))
  FreeCAD.ActiveDocument.recompute()
  FreeCADGui.activeDocument().setEdit(s.Name) 
开发者ID:oddtopus,项目名称:flamingo,代码行数:20,代码来源:pipeCmd.py

示例4: apply

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def apply(self):
    self.lastPipe=None
    if self.edit1.text():
      self.H=float(self.edit1.text())
    else:
      self.H=200.0
    self.sli.setValue(100)
    for obj in FreeCADGui.Selection.getSelection():
      d=self.pipeDictList[self.sizeList.currentRow()]
      if hasattr(obj,'PType') and obj.PType==self.PType:
        obj.PSize=d['PSize']
        obj.OD=pq(d['OD'])
        obj.thk=pq(d['thk'])
        obj.PRating=self.PRating
        if self.edit1.text():
          obj.Height=self.H
        FreeCAD.activeDocument().recompute() 
开发者ID:oddtopus,项目名称:flamingo,代码行数:19,代码来源:pipeForms.py

示例5: getBase

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def getBase(self):
    if self.combo.currentText()!="<new>":                                           
      pl=FreeCAD.ActiveDocument.getObjectsByLabel(self.combo.currentText())[0]    
      sel=FreeCADGui.Selection.getSelection()
      if sel:
        base=sel[0]
        isWire=hasattr(base,'Shape') and base.Shape.Edges #type(base.Shape)==Part.Wire
        isSketch=hasattr(base,'TypeId') and base.TypeId=='Sketcher::SketchObject'
        if isWire or isSketch:
          FreeCAD.activeDocument().openTransaction('Assign Base')
          pl.Base=base
          if isWire:
            pipeCmd.drawAsCenterLine(pl.Base)
            pipeCmd.moveToPyLi(pl.Base,self.combo.currentText())
          FreeCAD.activeDocument().commitTransaction()
        else:
          FreeCAD.Console.PrintError('Not valid Base: select a Wire or a Sketch.\n')
      else:
        pl.Base=None
        FreeCAD.Console.PrintWarning(pl.Label+'-> deleted Base\n')
    else:
      FreeCAD.Console.PrintError('Please choose or create a PypeLine first\n') 
开发者ID:oddtopus,项目名称:flamingo,代码行数:24,代码来源:pipeForms.py

示例6: breakPipe

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def breakPipe(self):
    p2nd=None
    FreeCAD.activeDocument().openTransaction('Break pipes')
    if self.edit1.text()[-1]=='%':
      pipes=[p for p in frameCmd.beams() if pipeCmd.isPipe(p)]
      for p in pipes:
        p2nd=pipeCmd.breakTheTubes(float(p.Height)*float(self.edit1.text().rstrip('%').strip())/100,pipes=[p],gap=float(self.edit2.text()))
        if p2nd and self.combo.currentText()!='<none>':
          for p in p2nd:
            pipeCmd.moveToPyLi(p,self.combo.currentText())
    else:
      p2nd=pipeCmd.breakTheTubes(float(self.edit1.text()),gap=float(self.edit2.text()))
      if p2nd and self.combo.currentText()!='<none>':
        for p in p2nd:
          pipeCmd.moveToPyLi(p,self.combo.currentText())
    FreeCAD.activeDocument().commitTransaction()
    FreeCAD.activeDocument().recompute() 
开发者ID:oddtopus,项目名称:flamingo,代码行数:19,代码来源:pipeForms.py

示例7: accept

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def accept(self):
    if self.labTail:
      self.labTail.removeLabel()
      self.labTail=None
    self.L=frameCmd.getDistance()
    if self.form.edit1.text():
      length=float(self.form.edit1.text())
      FreeCAD.activeDocument().openTransaction('Stretch beam')
      for beam in frameCmd.beams():
        delta=float(beam.Height)-length
        frameCmd.stretchTheBeam(beam,length)
        if self.form.tail.isChecked():
          disp=frameCmd.beamAx(beam).multiply(delta)
          beam.Placement.move(disp)
        elif self.form.both.isChecked():
          disp=frameCmd.beamAx(beam).multiply(delta/2.0)
          beam.Placement.move(disp)
      FreeCAD.activeDocument().recompute()
      FreeCAD.activeDocument().commitTransaction() 
开发者ID:oddtopus,项目名称:flamingo,代码行数:21,代码来源:frameForms.py

示例8: a2p_FlipConstraintDirection

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def a2p_FlipConstraintDirection():
    ''' updating constraints, deactivated at moment'''
    constraints = [ obj for obj in FreeCAD.ActiveDocument.Objects 
                        if 'ConstraintInfo' in obj.Content ]
    if len(constraints) == 0:
        QtGui.QMessageBox.information(
            QtGui.qApp.activeWindow(),
            "Command Aborted", 
            'Flip aborted since no a2p constraints in active document.'
            )
        return
    lastConstraintAdded = constraints[-1]
    try:
        if lastConstraintAdded.directionConstraint == 'aligned':
            lastConstraintAdded.directionConstraint = 'opposed'
        else:
            lastConstraintAdded.directionConstraint = 'aligned'
        a2p_solversystem.autoSolveConstraints(FreeCAD.activeDocument(), callingFuncName="a2p_FlipConstraintDirection")
    except:
        pass 
开发者ID:kbwbe,项目名称:A2plus,代码行数:22,代码来源:a2p_importpart.py

示例9: 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

示例10: make_pics

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def make_pics():
    n = 30
    for i in range(n):
        phi = np.pi * 2 / 30 / n
        g1.Placement.Rotation.Angle += phi * 2
        g2.Placement.Rotation.Angle -= phi
        gui.activeDocument().activeView().saveImage('/home/lo/Schreibtisch/animated_gear/gear_{}.png'.format(i) ,300,300,'Current') 
开发者ID:looooo,项目名称:freecad.gears,代码行数:9,代码来源:animation.py

示例11: view3DRefandLOD

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

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

    FreeCADGui.Selection.clearSelection()
    if 10:
        FreeCADGui.Selection.addSelection(FreeCAD.ActiveDocument.Box,['Face1'])
        FreeCADGui.Selection.addSelection(FreeCAD.ActiveDocument.Box,['Face2'])
        FreeCADGui.Selection.addSelection(FreeCAD.ActiveDocument.Box,['Face3'])
        FreeCADGui.Selection.addSelection(FreeCAD.ActiveDocument.Box,['Face4'])
    else:
        FreeCADGui.Selection.addSelection(FreeCAD.ActiveDocument.Cone,['Face1'])

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

    rib5 = pfwrap.createNode('PyFlowFreeCAD',"FreeCAD_view3D","view3D")
    rib5.setPosition(100,0)
    gg.addNode(rib5)

    t2 = pfwrap.createNode('PyFlowFreeCAD',"FreeCAD_Ref","Ref_Box",b="das ist B")
    t2.compute()
    gg.addNode(t2)

    t2 = pfwrap.createNode('PyFlowFreeCAD',"FreeCAD_LOD","myLOD")
    rib5.setPosition(100,200)
    t2.compute()
    gg.addNode(t2)

    #connection = pfwrap.connect(t2,'Shape',rib5,'Shape')
    refresh_gui() 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:36,代码来源:Commands.py

示例12: createBePlane

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def createBePlane():
    '''create an environment with a BePlane and a BeTube'''

    import nurbswb
    import nurbswb.berings
    rc=nurbswb.berings.createBePlane()
    rc.noise=4.
    rc=nurbswb.berings.createBeTube()
    rc.uSize=2000
    rc.vSize=500
    rc.vSegments=5
    rc.noise=500
    FreeCAD.activeDocument().recompute() 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:15,代码来源:Commands.py

示例13: createsomeparts

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def createsomeparts():
    ''' default box,cone and sphere for testing'''

    box=FreeCAD.ActiveDocument.addObject("Part::Box","Box")
    box2=FreeCAD.ActiveDocument.addObject("Part::Cone","Cone")
    sphere=FreeCAD.ActiveDocument.addObject("Part::Sphere","Sphere")
    FreeCAD.activeDocument().recompute() 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:9,代码来源:Commands.py

示例14: __init__

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def __init__(self,msg):
      self.beam=self.edge=None
      FreeCADGui.Selection.clearSelection()
      try:
        self.av=FreeCADGui.activeDocument().activeView()
        self.stop=self.av.addEventCallback("SoKeyboardEvent",self.goOut)
        FreeCAD.Console.PrintMessage('\n'+msg+'\n')
        FreeCAD.Console.PrintWarning('*** [ESC] to exit. ***\n')
      except:
        FreeCAD.Console.PrintError('No view available\n')
        FreeCADGui.Selection.removeObserver(self) 
开发者ID:oddtopus,项目名称:flamingo,代码行数:13,代码来源:frameObservers.py

示例15: simpleSurfBend

# 需要导入模块: import FreeCADGui [as 别名]
# 或者: from FreeCADGui import activeDocument [as 别名]
def simpleSurfBend(path=None,profile=None):
  'select the centerline and the O.D. and let it sweep'
  curva=FreeCAD.activeDocument().addObject("Part::Feature","CurvaSemplice")
  if path==None or profile==None:
    curva.Shape=Part.makeSweepSurface(*frameCmd.edges()[:2])
  elif path.ShapeType==profile.ShapeType=='Edge':
    curva.Shape=Part.makeSweepSurface(path,profile) 
开发者ID:oddtopus,项目名称:flamingo,代码行数:9,代码来源:pipeCmd.py


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