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


Python FreeCAD.activeDocument方法代码示例

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


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

示例1: clear

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import activeDocument [as 别名]
def clear(self):
        if self.selectedObject:
            if "Flat Lines" in self.selectedObject.ViewObject.listDisplayModes():
                self.selectedObject.ViewObject.DisplayMode = "Flat Lines"
            self.selectedObject.touch()
            if self.render:
                self.render.setRenderMode(self.render.AS_IS)
            #if self.CoinSurf:
                #self.sg.removeChild(self.CoinSurf.surfaceNode)
            #if self.grid:
                #self.sg.removeChild(self.grid.gridSep)
            #if self.SoCoords:
                #self.sg.removeChild(self.SoCoords)
            if self.cpc:
                self.cpc.removeAllChildren()
                self.cpc.unregister()
            if self.vizSep:
                self.sg.removeChild(self.vizSep)
            FreeCAD.activeDocument().recompute() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:21,代码来源:SurfaceEdit.py

示例2: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import activeDocument [as 别名]
def Activated (self):
    import pipeCmd, frameCmd
    from Part import Plane
    selex=FreeCADGui.Selection.getSelectionEx()
    for sx in selex:
      sxFaces=[f for f in frameCmd.faces([sx]) if type(f.Surface)==Plane]
      if len(sxFaces)>0:
        refFace=sxFaces[0]
        support=sx.Object
    FreeCAD.activeDocument().openTransaction('Raise-up the support')
    for b in frameCmd.beams():
      if pipeCmd.isPipe(b):
        pipeCmd.laydownTheTube(b,refFace,support)
        break
    FreeCAD.activeDocument().recompute()
    FreeCAD.activeDocument().commitTransaction() 
开发者ID:oddtopus,项目名称:flamingo,代码行数:18,代码来源:CommandsPipe.py

示例3: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import activeDocument [as 别名]
def Activated(self):
    from PySide import QtGui as qg
    def cellAddress(sp,target):
      import xml.etree.ElementTree as et
      cells=et.fromstring(sp.cells.Content)
      for cell in cells:
        if cell.get('content')==target:
          #print "*** "+target+" is in "+cell.get('address')+" ***"
          return cell.get('address')
      #print "There are no "+target+" in this sheet."

    doc=FreeCAD.activeDocument()
    s=[x for x in doc.Objects if x.TypeId.startswith('Spread')]
    if len(s):
      #print "There is at least 1 Sheet"
      target=qg.QInputDialog.getText(None,"findFirst()","String to search for?")
      i=cellAddress(s[0],target[0])
      import spreadCmd
      #print "From spreadCmd.py: row = "+spreadCmd.cellRC(s[0],target[0])
    else:
      #print "There are no sheets in this doc"
      pass 
开发者ID:oddtopus,项目名称:flamingo,代码行数:24,代码来源:CommandsSpSh.py

示例4: addSelection

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

示例5: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import activeDocument [as 别名]
def Activated(self):
    import FreeCAD, FreeCADGui, frameCmd, frameObservers
    selex=Gui.Selection.getSelectionEx()
    faces=frameCmd.faces(selex)
    beams=[sx.Object for sx in selex]
    if len(faces)==len(beams)>1:
      FreeCAD.activeDocument().openTransaction('LevelTheBeams')
      beams.pop(0)
      fBase=faces.pop(0)
      for i in range(len(beams)):
        frameCmd.levelTheBeam(beams[i],[fBase,faces[i]])
      FreeCAD.activeDocument().commitTransaction()
    elif len(faces)!=len(beams):
      FreeCAD.Console.PrintError('Select only one face for each beam.\n')
    else:
      FreeCADGui.Selection.clearSelection()
      s=frameObservers.levelBeamObserver()
      FreeCADGui.Selection.addObserver(s) 
开发者ID:oddtopus,项目名称:flamingo,代码行数:20,代码来源:CommandsFrame.py

示例6: makeSingle

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import activeDocument [as 别名]
def makeSingle(self):
    FreeCAD.activeDocument().openTransaction('Insert Single Struct')
    if self.SType=='<by sketch>':
      profile=FreeCAD.ActiveDocument.getObjectsByLabel(self.form.listSizes.currentItem().text())[0]
    else:
      prop=self.sectDictList[self.form.listSizes.currentRow()]
      profile=newProfile(prop)
    if frameCmd.faces():
      Z=FreeCAD.Vector(0,0,1)
      for f in frameCmd.faces():
        beam=makeStructure(profile)
        beam.Placement=FreeCAD.Placement(f.CenterOfMass,FreeCAD.Rotation(Z,f.normalAt(0,0)))
        if self.form.editLength.text(): beam.Height=float(self.form.editLength.text())
    else:
      for e in frameCmd.edges():
        beam=makeStructure(profile)
        frameCmd.placeTheBeam(beam,e)
        if self.form.editLength.text(): beam.Height=float(self.form.editLength.text())
    FreeCAD.ActiveDocument.recompute() 
开发者ID:oddtopus,项目名称:flamingo,代码行数:21,代码来源:frameFeatures.py

示例7: accept

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import activeDocument [as 别名]
def accept(self):
    if FreeCAD.ActiveDocument:
      # GET BASE
      bases=[b for b in FreeCADGui.Selection.getSelection() if hasattr(b,'Shape')]
      if bases and self.form.listSizes.selectedItems():
        FreeCAD.activeDocument().openTransaction('Insert FrameBranch')
        if self.SType=='<by sketch>':
          profile=FreeCAD.ActiveDocument.getObjectsByLabel(self.form.listSizes.currentItem().text())[0]
        else:
          prop=self.sectDictList[self.form.listSizes.currentRow()]
          profile=newProfile(prop)
        # MAKE FRAMEBRANCH
        if self.form.editName.text():
          name=self.form.editName.text()
        else:
          name='Travatura'
        a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
        FrameBranch(a,bases[0],profile)
        ViewProviderFrameBranch(a.ViewObject)
        FreeCAD.activeDocument().commitTransaction()
        FreeCAD.activeDocument().recompute()
        FreeCAD.activeDocument().recompute() 
开发者ID:oddtopus,项目名称:flamingo,代码行数:24,代码来源:frameFeatures.py

示例8: __init__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import activeDocument [as 别名]
def __init__(self, obj,DN="DN50",PRating="SCH-STD",OD=60.3,thk=3,BR=None, lab=None):
    # initialize the parent class
    super(PypeLine2,self).__init__(obj)
    # define common properties
    obj.PType="PypeLine"
    obj.PSize=DN
    obj.PRating=PRating
    if lab:
      obj.Label=lab
    # define specific properties
    if not BR:
      BR=0.75*OD
    obj.addProperty("App::PropertyLength","BendRadius","PypeLine2","the radius of bending").BendRadius=BR
    obj.addProperty("App::PropertyLength","OD","PypeLine2","Outside diameter").OD=OD
    obj.addProperty("App::PropertyLength","thk","PypeLine2","Wall thickness").thk=thk
    obj.addProperty("App::PropertyString","Group","PypeLine2","The group.").Group=obj.Label+"_pieces"
    group=FreeCAD.activeDocument().addObject("App::DocumentObjectGroup",obj.Group)
    group.addObject(obj)
    FreeCAD.Console.PrintWarning("Created group "+obj.Group+"\n")
    obj.addProperty("App::PropertyLink","Base","PypeLine2","the edges") 
开发者ID:oddtopus,项目名称:flamingo,代码行数:22,代码来源:pipeFeatures.py

示例9: updatePLColor

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import activeDocument [as 别名]
def updatePLColor(sel=None, color=None):
  if not sel:
    sel=FreeCADGui.Selection.getSelection()
  if sel:
    pl=sel[0]
    if hasattr(pl,'PType') and pl.PType=='PypeLine':
      if not color:
        color=pl.ViewObject.ShapeColor
      group=FreeCAD.activeDocument().getObjectsByLabel(pl.Group)[0]
      for o in group.OutList:
        if hasattr(o,'PType'):
          if o.PType in objToPaint: 
            o.ViewObject.ShapeColor=color
          elif o.PType == 'PypeBranch':
            for e in [FreeCAD.ActiveDocument.getObject(name) for name in o.Tubes+o.Curves]: 
              e.ViewObject.ShapeColor=color
  else:
    FreeCAD.Console.PrintError('Select first one pype line\n') 
开发者ID:oddtopus,项目名称:flamingo,代码行数:20,代码来源:pipeCmd.py

示例10: breakTheTubes

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

示例11: makeRoute

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

示例12: apply

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

示例13: breakPipe

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

示例14: pickAction

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import activeDocument [as 别名]
def pickAction(self,path=None,event=None,arg=None):
    FreeCAD.activeDocument().openTransaction('Quick move')
    if event.wasCtrlDown(): k=-1*float(self.edit.text())
    else: k=1*float(self.edit.text())
    sel=FreeCADGui.Selection.getSelection()
    if sel: self.objs=[o for o in sel if hasattr(o,'Shape')]
    if event.wasCtrlDown() and event.wasAltDown():
      if frameCmd.edges(): 
        self.edge=frameCmd.edges()[0]
        for o in self.objs: frameCmd.rotateTheBeamAround(o, self.edge, 90)
      elif self.edge:
        for o in self.objs: frameCmd.rotateTheBeamAround(o, self.edge, 90)
    else:
      for o in self.objs: o.Placement.move(self.direct*k)
      self.Placement.move(self.direct*k)
      pl,direct,M=[self.Placement,self.direct,self.scale]
      self.closeArrow()
      self.__init__(self.edit, pl,direct,M,self.objs)
    FreeCAD.activeDocument().commitTransaction() 
开发者ID:oddtopus,项目名称:flamingo,代码行数:21,代码来源:polarUtilsCmd.py

示例15: accept

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


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