當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。