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


Python FreeCAD.Rotation方法代码示例

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


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

示例1: doFlip

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def doFlip(obj, info, flipElement):
        if QtGui.QApplication.keyboardModifiers()==QtCore.Qt.ControlModifier:
            rot = FreeCAD.Rotation(FreeCAD.Vector(0,1,0),180)
        else:
            rot = FreeCAD.Rotation(FreeCAD.Vector(1,0,0),180)
        rot = FreeCAD.Placement(FreeCAD.Vector(), rot)

        FreeCAD.setActiveTransaction(
                'Flip element' if flipElement else 'Flip part')
        try:
            if flipElement:
                obj.Offset = rot.multiply(obj.Offset)
            else:
                offset = utils.getElementPlacement(obj.getSubObject(''))
                offset = offset.multiply(rot).multiply(offset.inverse())
                setPlacement(info.Part, offset.multiply(info.Placement))
            obj.recompute(True)
            FreeCAD.closeActiveTransaction()
        except Exception:
            FreeCAD.closeActiveTransaction(True)
            raise 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:23,代码来源:assembly.py

示例2: make_profile_sketch

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def make_profile_sketch(self):
        import Sketcher
        sk = FreeCAD.ActiveDocument.addObject('Sketcher::SketchObject','Profile')
        sk.Placement = FreeCAD.Placement(FreeCAD.Vector(0,0,0),FreeCAD.Rotation(0,0,0,1))
        sk.MapMode = "Deactivated"
        sk.addGeometry(Part.LineSegment(FreeCAD.Vector(100.0,0.0,0),FreeCAD.Vector(127.0,12.0,0)),False)
        sk.addConstraint(Sketcher.Constraint('PointOnObject',0,1,-1)) 
        sk.addGeometry(Part.ArcOfCircle(Part.Circle(FreeCAD.Vector(125.0,17.0,0),FreeCAD.Vector(0,0,1),5.8),-1.156090,1.050925),False)
        sk.addConstraint(Sketcher.Constraint('Tangent',0,2,1,1)) 
        sk.addGeometry(Part.LineSegment(FreeCAD.Vector(128.0,22.0,0),FreeCAD.Vector(100.0,37.0,0)),False)
        sk.addConstraint(Sketcher.Constraint('Tangent',1,2,2,1)) 
        sk.addConstraint(Sketcher.Constraint('Vertical',0,1,2,2)) 
        sk.addConstraint(Sketcher.Constraint('DistanceY',0,1,2,2,37.5)) 
        sk.setDatum(4,FreeCAD.Units.Quantity('35.000000 mm'))
        sk.renameConstraint(4, u'Lead')
        sk.setDriving(4,False)
        sk.addConstraint(Sketcher.Constraint('Equal',2,0)) 
        FreeCAD.ActiveDocument.recompute()
        return sk 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:21,代码来源:HelicalSweepFP.py

示例3: zipRotation

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def zipRotation(
				x=('FloatPin', [0],{PinSpecifires.ENABLED_OPTIONS: PinOptions.ArraySupported}),
				y=('FloatPin', [1],{PinSpecifires.ENABLED_OPTIONS: PinOptions.ArraySupported}),
				z=('FloatPin', [2],{PinSpecifires.ENABLED_OPTIONS: PinOptions.ArraySupported}),
				angle=('FloatPin', [2],{PinSpecifires.ENABLED_OPTIONS: PinOptions.ArraySupported})
			) :
        """combine axis(x,y,z) and angle lists to a list of rotations"""
        
        res=np.array([x,y,z]).swapaxes(0,1)
        rots=[FreeCAD.Rotation(FreeCAD.Vector(list(a)),b) for a,b in zip(res,angle)]    
        return rots

#    @staticmethod
#    @IMPLEMENT_NODE(returns=('RotationPin', [],{'constraint': '1', "enabledOptions": PinOptions.ArraySupported | PinOptions.AllowAny}), meta={'Category': 'numpy|array', 'Keywords': ['list','random']})
#    def zipPlacement(
#			Base=('FloatPin', []),Rotation=('FloatPin', [])) :
#        """combine """
#        
#        pms=[FreeCAD.Placement(base,rot) for base,rot in zip(Base,Rotation)]    
#        return pms 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:22,代码来源:Numpy.py

示例4: makeSingle

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

示例5: pivotTheBeam

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def pivotTheBeam(ang=90, edge=None, beam=None): #OBSOLETE: replaced with rotateTheBeamAround
  '''
  pivotTheBeam(ang=90)
  Rotates the selected object around the selected pivot (one of its edges)
  by ang degrees.
  '''
  #if len(edges())!=1:
  #  FreeCAD.Console.PrintError('Wrong selection\n')
  #  return None
  if not (edge and beam):
    try:
      edge=edges()[0]
      beam=FreeCADGui.Selection.getSelection()[0]
    except:
      return
  rot=FreeCAD.Rotation(edge.tangentAt(0),ang)
  beam.Placement.Rotation=rot.multiply(beam.Placement.Rotation)
  edgePost=edges()[0] #save position for revert
  dist=edge.CenterOfMass-edgePost.CenterOfMass
  beam.Placement.move(dist) 
开发者ID:oddtopus,项目名称:flamingo,代码行数:22,代码来源:frameCmd.py

示例6: shapeReferenceAxis

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def shapeReferenceAxis(obj=None, axObj=None):
  # function to get the reference axis of the shape for rotateTheTubeAx()
  # used in rotateTheTubeEdge() and pipeForms.rotateForm().getAxis()
  '''
  shapeReferenceAxis(obj, axObj)
  Returns the direction of an axis axObj
  according the original Shape orientation of the object obj
  If arguments are None axObj is the normal to one circular edge selected
  and obj is the object selected.
  '''
  if obj==None and axObj==None:
    selex=FreeCADGui.Selection.getSelectionEx()
    if len(selex)==1 and len(selex[0].SubObjects)>0:
      sub=selex[0].SubObjects[0]
      if sub.ShapeType=='Edge' and sub.curvatureAt(0)>0:  
        axObj=sub.tangentAt(0).cross(sub.normalAt(0))
        obj=selex[0].Object
  X=obj.Placement.Rotation.multVec(FreeCAD.Vector(1,0,0)).dot(axObj)
  Y=obj.Placement.Rotation.multVec(FreeCAD.Vector(0,1,0)).dot(axObj)
  Z=obj.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1)).dot(axObj)
  axShapeRef=FreeCAD.Vector(X,Y,Z)
  return axShapeRef 
开发者ID:oddtopus,项目名称:flamingo,代码行数:24,代码来源:pipeCmd.py

示例7: portsDir

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def portsDir(o):
  '''
  portsDir(o)
  Returns the orientation of Ports of the pype-object o
  '''
  dirs=list()
  two_ways=['Pipe','Reduct','Flange']
  if hasattr(o,'PType'):
    if o.PType in two_ways:
      dirs=[o.Placement.Rotation.multVec(p) for p in [FreeCAD.Vector(0,0,-1),FreeCAD.Vector(0,0,1)]]
    elif hasattr(o,'Ports') and hasattr(o,'Placement'): 
      dirs=list()
      for p in o.Ports:
        if p.Length:
          dirs.append(rounded(o.Placement.Rotation.multVec(p).normalize()))
        else:
          dirs.append(rounded(o.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1)).normalize()))
  return dirs

################## COMMANDS ######################## 
开发者ID:oddtopus,项目名称:flamingo,代码行数:22,代码来源:pipeCmd.py

示例8: placeoTherElbow

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def placeoTherElbow(c,v1=None,v2=None,P=None):
  '''
  Like placeTheElbow() but with more math.
  '''
  if not (v1 and v2):
    v1,v2=[e.tangentAt(0) for e in frameCmd.edges()]
    try:
      P=frameCmd.intersectionCLines(*frameCmd.edges())
    except: pass
  if hasattr(c,'PType') and hasattr(c,'BendAngle') and v1 and v2:
    v1.normalize()
    v2.normalize()
    ortho=rounded(frameCmd.ortho(v1,v2))
    bisect=rounded(v2-v1)
    cBisect=rounded(c.Ports[1].normalize()+c.Ports[0].normalize()) # math
    cZ=c.Ports[0].cross(c.Ports[1]) # more math
    ang=degrees(v1.getAngle(v2))
    c.BendAngle=ang
    rot1=FreeCAD.Rotation(rounded(frameCmd.beamAx(c,cZ)),ortho)
    c.Placement.Rotation=rot1.multiply(c.Placement.Rotation)
    rot2=FreeCAD.Rotation(rounded(frameCmd.beamAx(c,cBisect)),bisect)
    c.Placement.Rotation=rot2.multiply(c.Placement.Rotation)
    if not P:
      P=c.Placement.Base
    c.Placement.Base=P 
开发者ID:oddtopus,项目名称:flamingo,代码行数:27,代码来源:pipeCmd.py

示例9: join

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def join(obj1,port1,obj2,port2):
  '''
  join(obj1,port1,obj2,port2)
  \t obj1, obj2 = two "Pype" parts
  \t port1, port2 = their respective ports to join
  '''  
  if hasattr(obj1,'PType') and hasattr(obj2,'PType'):
    if port1>len(obj1.Ports)-1 or port2>len(obj2.Ports)-1:
      FreeCAD.Console.PrintError('Wrong port(s) number\n')
    else:
      v1=portsDir(obj1)[port1]
      v2=portsDir(obj2)[port2]
      rot=FreeCAD.Rotation(v2,v1.negative())
      obj2.Placement.Rotation=rot.multiply(obj2.Placement.Rotation)
      p1=portsPos(obj1)[port1]
      p2=portsPos(obj2)[port2]
      obj2.Placement.move(p1-p2)
  else:
    FreeCAD.Console.PrintError('Object(s) are not pypes\n') 
开发者ID:oddtopus,项目名称:flamingo,代码行数:21,代码来源:pipeCmd.py

示例10: getLength

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def getLength(self):
    roundDigits=3
    if len(frameCmd.edges())>0:
      edge=frameCmd.edges()[0]
      self.form.edit4.setText(str(edge.Length))
      self.form.edit5.setText('1')
      dx,dy,dz=list(edge.tangentAt(0))
      self.form.edit1.setText(str(round(dx,roundDigits)))
      self.form.edit2.setText(str(round(dy,roundDigits)))
      self.form.edit3.setText(str(round(dz,roundDigits)))
      FreeCADGui.Selection.clearSelection()
      self.deleteArrow()
      from polarUtilsCmd import arrow
      where=FreeCAD.Placement()
      where.Base=edge.valueAt(0)
      where.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),edge.tangentAt(0))
      size=[edge.Length/20.0,edge.Length/10.0,edge.Length/20.0]
      self.arrow=arrow(pl=where,scale=size,offset=edge.Length/2.0) 
开发者ID:oddtopus,项目名称:flamingo,代码行数:20,代码来源:frameForms.py

示例11: selectAction

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def selectAction(self):
    edged = [objex for objex in FreeCADGui.Selection.getSelectionEx() if frameCmd.edges([objex])]
    if edged:
      self.Axis=frameCmd.edges([edged[0]])[0]
      self.deleteArrow()
      from polarUtilsCmd import arrow
      where=FreeCAD.Placement()
      where.Base=self.Axis.valueAt(self.Axis.LastParameter)
      where.Rotation=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),self.Axis.tangentAt(self.Axis.LastParameter))
      size=[self.Axis.Length/20.0,self.Axis.Length/10.0,self.Axis.Length/20.0]
      self.arrow=arrow(pl=where,scale=size,offset=self.Axis.Length/10.0)
      if self.Axis.curvatureAt(0):
        O=self.Axis.centerOfCurvatureAt(0)
        n=self.Axis.tangentAt(0).cross(self.Axis.normalAt(0))
        from Part import Edge, Line
        self.Axis=(Edge(Line(FreeCAD.Vector(O),FreeCAD.Vector(O+n))))
      self.form.lab1.setText(edged[0].Object.Label+": edge") 
开发者ID:oddtopus,项目名称:flamingo,代码行数:19,代码来源:frameForms.py

示例12: makeThing

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def makeThing(n='Valvola', fn='ballDN15.stp', p='0:0:0', pos=None, Z=None):
  '''
  makeThing(n,fn,p,pos,Z)
    n = name
    fn = file name
    p = ports string (e.g. "0:0:0/0:0:69")
    pos = position Vector
    Z = orientation Vector
  '''
  if pos==None:
    pos=FreeCAD.Vector(0,0,0)
  if Z==None:
    Z=FreeCAD.Vector(0,0,1)
  a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython",n)
  AnyThing(a, name=n, fileName=fn, ports=p)
  a.ViewObject.Proxy=0
  a.Placement.Base=pos
  rot=FreeCAD.Rotation(FreeCAD.Vector(0,0,1),Z)
  a.Placement.Rotation=rot.multiply(a.Placement.Rotation)
  return a 
开发者ID:oddtopus,项目名称:flamingo,代码行数:22,代码来源:anyShape.py

示例13: applySolution

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def applySolution(self, doc, solver):
        if self.tempfixed or self.fixed: return

        # Update FreeCAD's placements if deltaPlacement above Tolerances
        base1 = self.placement.Base
        base2 = self.savedPlacement.Base
        absPosMove = base1.sub(base2).Length

        axis1 = self.placement.Rotation.Axis
        axis2 = self.savedPlacement.Rotation.Axis
        angle = math.degrees(axis2.getAngle(axis1))

        '''
        if absPosMove >= solver.mySOLVER_POS_ACCURACY*1e-2 or angle >= solver.mySOLVER_SPIN_ACCURACY*1e-2:
            ob1 = doc.getObject(self.objectName)
            ob1.Placement = self.placement
        '''
        ob1 = doc.getObject(self.objectName)
        ob1.Placement = self.placement 
开发者ID:kbwbe,项目名称:A2plus,代码行数:21,代码来源:a2p_rigid.py

示例14: beautyDOFPrint

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def beautyDOFPrint(self):
        '''
        pretty print output that describe the current DOF of the rigid
        '''
        Msg('\n')
        Msg(u"Current Rigid = {}\n".format(self.label) )
        if self.fixed:
            Msg(u"    is Fixed\n")
        else:
            Msg(u"    is not Fixed and has {} DegreesOfFreedom\n".format(self.currentDOF()))
        for rig in self.depsPerLinkedRigids.keys():
            Msg(u"    Depends on Rigid = {}\n".format(rig.label))
            for dep in self.depsPerLinkedRigids[rig]:
                Msg(u"        {}\n".format(dep) )
            Msg(u"        DOF Position free with this rigid = {}\n".format( len(self.dofPOSPerLinkedRigids[rig])))
            Msg(u"        DOF Rotation free with this rigid = {}\n".format( len(self.dofROTPerLinkedRigids[rig]))) 
开发者ID:kbwbe,项目名称:A2plus,代码行数:18,代码来源:a2p_rigid.py

示例15: onChanged

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Rotation [as 别名]
def onChanged(self, fp, prop):
        try:
            if prop == 'XLength' or prop == 'YLength' or prop == 'ZLength' or prop == 'FrameDiameter':
                self.addMachineToDocument( fp.FrameDiameter, fp.XLength, fp.YLength, fp.ZLength )

            if prop == 'ReturnHome' and fp.ReturnHome:
                # reset machine position
                homePlm = FreeCAD.Placement(FreeCAD.Vector(0,0,0),
                                            FreeCAD.Rotation(FreeCAD.Vector(0,0,0),0))
                FreeCAD.ActiveDocument.getObject('XA').Placement = homePlm
                FreeCAD.ActiveDocument.getObject('XB').Placement = homePlm
                FreeCAD.ActiveDocument.getObject('YA').Placement = homePlm
                FreeCAD.ActiveDocument.getObject('YB').Placement = homePlm
                fp.ReturnHome = False

            if prop == 'HideWireTrajectory':
                for obj in FreeCAD.ActiveDocument.WireTrajectory.Group:
                    obj.ViewObject.Visibility = fp.HideWireTrajectory + 1

            if prop == 'HideWire':
                FreeCAD.ActiveDocument.Wire.ViewObject.Visibility = fp.HideWire + 1

        except AttributeError:
            pass 
开发者ID:JMG1,项目名称:NiCr,代码行数:26,代码来源:NiCrSimMachine.py


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