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


Python FreeCAD.Vector方法代码示例

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


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

示例1: doFlip

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

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def update_text(self):
        if self._shape is None:
            return
        p = self.points[0]
        par = self._shape.Curve.parameter(FreeCAD.Vector(p[0],p[1],p[2]))
        if self._text_type == 0 :
            coords = ['{: 9.3f}'.format(par)]
        else:
            if par <= self._shape.FirstParameter:
                abscissa = 0
            else:
                c = self._shape.Curve.trim(self._shape.FirstParameter, par)
                abscissa = c.length()
            if self._text_type == 1 :
                coords = ['{: 9.3f} mm'.format(abscissa)]
            elif self._text_type == 2 :
                perc = 100 * abscissa / self._shape.Length
                coords = ['{: 9.3f} %'.format(perc)]
        self._text_translate.translation = p
        self._text.string.setValues(0,len(coords),coords) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:22,代码来源:splitCurves_2.py

示例4: set_tangents

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def set_tangents(self):
        #view_dir = FreeCAD.Vector(0,0,1)
        view_dir = FreeCADGui.ActiveDocument.ActiveView.getViewDirection()
        markers = list()
        for o in self.root.selected_objects:
            if isinstance(o,MarkerOnShape):
                markers.append(o)
            elif isinstance(o,ConnectionLine):
                markers.extend(o.markers)
        if len(markers) > 0:
            for m in markers:
                if m.tangent:
                    m.tangent = None
                else:
                    i = self.points.index(m)
                    if i == 0:
                        m.tangent = -view_dir
                    else:
                        m.tangent = view_dir
        self.update_curve() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:22,代码来源:profile_editor.py

示例5: __init__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def __init__(self, parent, dynamic=False):
        super(CustomText, self).__init__(parent.points, dynamic)
        #self._text_offset = FreeCAD.Vector(0,0,0)
        self._text_translate = coin.SoTranslation()
        self._text_font = coin.SoFont()
        self._text_font.name = "Arial:Bold"
        self._text_font.size = 13.0
        self._text = coin.SoText2()
        self._text_switch = coin.SoSwitch()
        self._text_switch.addChild(self._text_translate)
        self._text_switch.addChild(self._text_font)
        self._text_switch.addChild(self._text)
        self.addChild(self._text_switch)
        self.parent = parent
        self.parent.on_drag.append(self.translate)
        self.translate() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:18,代码来源:manipulators.py

示例6: execute

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def execute(self, obj):
        s1 = obj.Shape1.Shape
        s2 = obj.Shape2.Shape
        if obj.Direction1.Length < 1e-7:
            d1 = obj.Shape1.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1))
        else:
            d1 = obj.Direction1
        if obj.Direction2.Length < 1e-7:
            d2 = obj.Shape2.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1))
        else:
            d2 = obj.Direction2
        cc = CombinedProjectionCurve(s1,s2,d1,d2)
        if hasattr(obj,"ExtensionProxy"):
            obj.Shape = obj.ExtensionProxy.approximate(obj,cc.shape().Edges)
        else:
            obj.Shape = cc.shape() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:18,代码来源:combined_curve.py

示例7: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def Activated(self):
        vd = [FreeCAD.Vector(0,0,0), FreeCAD.Vector(0,0,0)]
        try:
            sel = FreeCADGui.activeWorkbench().Selection
            vd =  FreeCADGui.activeWorkbench().View_Directions
        except AttributeError:
            sel = FreeCADGui.Selection.getSelectionEx()
        if not len(sel) == 2:
            FreeCAD.Console.PrintError("Select 2 objects !\n")
            return
        for selobj in sel:
            selobj.Object.ViewObject.Visibility = False
        if len(vd) == 2 and vd[0].dot(vd[1]) < 0.999:
            d1, d2 = vd
        else:
            d1,d2 = [FreeCAD.Vector(0,0,0), FreeCAD.Vector(0,0,0)]
        self.makeCPCFeature(sel[0].Object,sel[1].Object,d1,d2) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:19,代码来源:combined_curve.py

示例8: execute

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def execute(self, obj):
        s1 = obj.Shape1.Shape
        s2 = obj.Shape2.Shape
        if obj.Direction1.Length < 1e-7:
            d1 = obj.Shape1.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1))
        else:
            d1 = obj.Direction1
        if obj.Direction2.Length < 1e-7:
            d2 = obj.Shape2.Placement.Rotation.multVec(FreeCAD.Vector(0,0,-1))
        else:
            d2 = obj.Direction2
        cc = MixedCurve(s1,s2,d1,d2)
        if hasattr(obj,"ExtensionProxy"):
            obj.Shape = obj.ExtensionProxy.approximate(obj,cc.shape().Edges)
        else:
            obj.Shape = cc.shape() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:18,代码来源:mixed_curve.py

示例9: subdivide

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def subdivide(self):
        # get selected lines and subdivide them
        pts = list()
        new_select = list()
        for o in self.lines:
            #FreeCAD.Console.PrintMessage("object %s\n"%str(o))
            if isinstance(o,ConnectionLine):
                pts.append(o.markers[0])
                if o in self.root.selected_objects:
                    idx = self.lines.index(o)
                    FreeCAD.Console.PrintMessage("Subdividing line #%d\n"%idx)
                    p1 = o.markers[0].points[0]
                    p2 = o.markers[1].points[0]
                    par1 = self.curve.parameter(FreeCAD.Vector(p1))
                    par2 = self.curve.parameter(FreeCAD.Vector(p2))
                    midpar = (par1+par2)/2.0
                    mark = MarkerOnShape([self.curve.value(midpar)])
                    pts.append(mark)
                    new_select.append(mark)
        pts.append(self.points[-1])
        self.points = pts
        self.setup_InteractionSeparator()
        self.root.selected_objects = new_select
        self.update_curve()
        return(True) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:27,代码来源:blendsurf_editor.py

示例10: execute

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def execute(self, obj):
        debug("* Hook : execute *\n")
        e = self.getEdge(obj)
        if e == None:
            return
        #center = FreeCAD.Vector(0,0,0)
        if obj.Method == "Fixed":
            p = FreeCAD.Vector(obj.X, obj.Y, obj.Z)
            v = Part.Vertex(p)
            obj.Center = v.distToShape(e)[1][0][1]
        elif obj.Method == "Parameter":
            obj.Center = e.valueAt(obj.Parameter)
        elif obj.Method == "Distance-From-Start":
            par = e.getParameterByLength(obj.StartDistance)
            obj.Center = e.valueAt(par)
        elif obj.Method == "Distance-From-End":
            par = e.getParameterByLength(e.Length - obj.EndDistance)
            obj.Center = e.valueAt(par)
        #radius = 1.0 * e.Length / 100.0
        #sphere = Part.Sphere()
        #sphere.Radius = radius
        #sphere.Center = obj.Center
        obj.Shape = Part.Vertex(obj.Center) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:25,代码来源:hooks.py

示例11: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def Activated(self):
        self.view = FreeCADGui.ActiveDocument.ActiveView
        self.viewer = self.view.getViewer()
        self.oldRadius = self.viewer.getPickRadius()
        self.viewer.setPickRadius(25.0)

        self.obj = FreeCAD.ActiveDocument.addObject("Part::Spline","BSplineCurve")

        self.stack = [FreeCAD.Vector(0,0,0)]
        self.markerPos = None
        self.snap = False
        self.snapShape = None
        self.point = FreeCAD.Vector(0,0,0)
        self.curve = Part.BSplineCurve()
        self.degree = 1
        self.mults = [2,2]
        self.knots = [0.]

        self.clicCB     = self.view.addEventCallbackPivy( coin.SoMouseButtonEvent.getClassTypeId(), self.clic_cb)
        self.keyboardCB = self.view.addEventCallbackPivy( coin.SoKeyboardEvent.getClassTypeId(), self.kb_cb)
        self.cursorCB   = self.view.addEventCallbackPivy( coin.SoLocation2Event.getClassTypeId(), self.cursor_cb)

        self.nodeInit()
        for st in self.info:
            FreeCAD.Console.PrintError(st+"\n") 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:27,代码来源:bezierCurve.py

示例12: join_curve

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def join_curve(c1,c2):
    c = Part.BSplineCurve()
    # poles (sequence of Base.Vector), [mults , knots, periodic, degree, weights (sequence of float), CheckRational]
    new_poles = c1.getPoles()
    new_poles.extend(c2.getPoles()[1:])
    new_weights = c1.getWeights()
    new_weights.extend(c2.getWeights()[1:])
    new_mults = c1.getMultiplicities()[:-1]
    new_mults.append(c1.Degree)
    new_mults.extend(c2.getMultiplicities()[1:])
    knots1 = c1.getKnots()
    knots2 = [knots1[-1] + k for k in c2.getKnots()]
    new_knots = knots1
    new_knots.extend(knots2[1:])
    print("poles   -> %r"%new_poles)
    print("weights -> %r"%new_weights)
    print("mults   -> %r"%new_mults)
    print("knots   -> %r"%new_knots)
    c.buildFromPolesMultsKnots(new_poles, new_mults, new_knots, False, c1.Degree, new_weights, True)
    return c 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:22,代码来源:nurbs_tools.py

示例13: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def Activated(self):
        self.view = FreeCADGui.ActiveDocument.ActiveView
        self.viewer = self.view.getViewer()
        self.oldRadius = self.viewer.getPickRadius()
        self.viewer.setPickRadius(15.0)
        self.obj = FreeCAD.ActiveDocument.addObject("Part::Feature","BezierCurve")
        self.stack = [FreeCAD.Vector(0,0,0)]
        self.markerPos = None
        self.snap = False
        self.snapShape = None
        self.point = FreeCAD.Vector(0,0,0)
        self.curve = Part.BezierCurve()
        self.clicCB     = self.view.addEventCallbackPivy( coin.SoMouseButtonEvent.getClassTypeId(), self.clic_cb)
        self.keyboardCB = self.view.addEventCallbackPivy( coin.SoKeyboardEvent.getClassTypeId(), self.kb_cb)
        self.cursorCB   = self.view.addEventCallbackPivy( coin.SoLocation2Event.getClassTypeId(), self.cursor_cb)
        FreeCADGui.Selection.clearSelection()
        FreeCADGui.Selection.addObserver(self)
        self.nodeInit() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:20,代码来源:bezierCurve-selection.py

示例14: __init__

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def __init__(self, obj, src):
        """Add the properties"""
        obj.addProperty("App::PropertyLink",   "Source",  "ReflectLines", "Source object")
        obj.addProperty("App::PropertyLinkSubList","IndivFaces","ReflectLines", "Individual faces")
        obj.addProperty("App::PropertyVector", "ViewPos", "ReflectLines", "View position")
        obj.addProperty("App::PropertyVector", "ViewDir", "ReflectLines", "View direction")
        obj.addProperty("App::PropertyVector", "UpDir",   "ReflectLines", "Up direction")
        obj.addProperty("App::PropertyBool",   "ShapeCleaning","ReflectLines", "Remove duplicate edges").ShapeCleaning = False
        obj.addProperty("App::PropertyInteger", "Samples","CleaningOptions", "Number of edge samples").Samples = 10
        obj.addProperty("App::PropertyQuantity", "Tolerance","CleaningOptions", "Tolerance for duplicate detection").Tolerance = 1e-3
        #obj.Samples = [10,3,999,1]
        obj.ViewPos = FreeCAD.Vector(0,0,0)
        obj.ViewDir = FreeCAD.Vector(0,0,1)
        obj.UpDir   = FreeCAD.Vector(0,1,0)
        obj.setEditorMode("Samples",2)
        obj.setEditorMode("Tolerance",2)
        if isinstance(src,(list,tuple)):
            obj.IndivFaces = src
        else:
            obj.Source = src
        obj.Proxy = self 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:23,代码来源:ReflectLinesFP.py

示例15: Activated

# 需要导入模块: import FreeCAD [as 别名]
# 或者: from FreeCAD import Vector [as 别名]
def Activated(self):
        self.view = FreeCADGui.ActiveDocument.ActiveView
        self.viewer = self.view.getViewer()
        self.oldRadius = self.viewer.getPickRadius()
        self.viewer.setPickRadius(15.0)
        self.obj = FreeCAD.ActiveDocument.addObject("Part::Feature","BezierCurve")
        #FreeCAD.ActiveDocument.recompute()
        #self.obj.ViewObject.Selectable = False
        self.stack = [FreeCAD.Vector(0,0,0)]
        self.markerPos = None
        self.snap = False
        self.snapShape = None
        self.point = FreeCAD.Vector(0,0,0)
        self.curve = Part.BezierCurve()
        self.clicCB     = self.view.addEventCallbackPivy( coin.SoMouseButtonEvent.getClassTypeId(), self.clic_cb)
        self.keyboardCB = self.view.addEventCallbackPivy( coin.SoKeyboardEvent.getClassTypeId(), self.kb_cb)
        self.cursorCB   = self.view.addEventCallbackPivy( coin.SoLocation2Event.getClassTypeId(), self.cursor_cb)
        #FreeCADGui.Selection.clearSelection()
        #FreeCADGui.Selection.addObserver(self)
        self.nodeInit() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:22,代码来源:bezierCurve-2.py


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