當前位置: 首頁>>代碼示例>>Python>>正文


Python Part.Edge方法代碼示例

本文整理匯總了Python中Part.Edge方法的典型用法代碼示例。如果您正苦於以下問題:Python Part.Edge方法的具體用法?Python Part.Edge怎麽用?Python Part.Edge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Part的用法示例。


在下文中一共展示了Part.Edge方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: isCircularEdge

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def isCircularEdge(obj):
    edge = getElementShape(obj,Part.Edge)
    if not edge:
        return False
    elif not hasattr(edge, 'Curve'): #issue 39
        return False
    if hasattr( edge.Curve, 'Radius' ):
        return True
    elif isLine(edge.Curve):
        return False
    else:
        BSpline = edge.Curve.toBSpline()
        try:
            arcs = BSpline.toBiArcs(10**-6)
        except Exception:  #FreeCAD exception thrown ()
            return False
        if all( hasattr(a,'Center') for a in arcs ):
            centers = np.array([a.Center for a in arcs])
            sigma = np.std( centers, axis=0 )
            return max(sigma) < 10**-6
        return False 
開發者ID:realthunder,項目名稱:FreeCAD_assembly3,代碼行數:23,代碼來源:utils.py

示例2: isLinearEdge

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def isLinearEdge(obj):
    edge = getElementShape(obj,Part.Edge)
    if not edge:
        return False
    elif not hasattr(edge, 'Curve'): #issue 39
        return False
    if isLine(edge.Curve):
        return True
    elif hasattr( edge.Curve, 'Radius' ):
        return False
    else:
        BSpline = edge.Curve.toBSpline()
        try:
            arcs = BSpline.toBiArcs(10**-6)
        except Exception:  #FreeCAD exception thrown ()
            return False
        if all(isLine(a) for a in arcs):
            lines = arcs
            D = np.array([L.tangent(0)[0] for L in lines]) #D(irections)
            return np.std( D, axis=0 ).max() < 10**-9
        return False 
開發者ID:realthunder,項目名稱:FreeCAD_assembly3,代碼行數:23,代碼來源:utils.py

示例3: __init__

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def __init__(self, obj , edge):
        debug("Discretization class Init")
        obj.addProperty("App::PropertyLinkSub",      "Edge",      "Discretization",   "Edge").Edge = edge
        obj.addProperty("App::PropertyEnumeration",  "Target",    "Discretization",   "Tool target").Target=["Edge","Wire"]
        obj.addProperty("App::PropertyEnumeration",  "Algorithm", "Method",   "Discretization Method").Algorithm=["Number","QuasiNumber","Distance","Deflection","QuasiDeflection","Angular-Curvature"]
        obj.addProperty("App::PropertyInteger",      "Number",    "Method",   "Number of edge points").Number = 100
        obj.addProperty("App::PropertyFloat",        "Distance",  "Method",   "Distance between edge points").Distance=1.0
        obj.addProperty("App::PropertyFloat",        "Deflection","Method",   "Distance for deflection Algorithm").Deflection=1.0
        obj.addProperty("App::PropertyFloat",        "Angular",   "Method",   "Angular value for Angular-Curvature Algorithm").Angular=0.1
        obj.addProperty("App::PropertyFloat",        "Curvature", "Method",   "Curvature value for Angular-Curvature Algorithm").Curvature=0.1
        obj.addProperty("App::PropertyInteger",      "Minimum",   "Method",   "Minimum Number of points").Minimum = 2
        obj.addProperty("App::PropertyFloat",        "ParameterFirst",     "Parameters",   "Start parameter")
        obj.addProperty("App::PropertyFloat",        "ParameterLast",      "Parameters",   "End parameter")
        obj.addProperty("App::PropertyVectorList",   "Points",    "Discretization",   "Points")
        obj.Proxy = self
        self.obj = obj
        obj.Algorithm = "Number"
        obj.Target = "Edge"
        edge = self.getTarget(obj, False)
        obj.ParameterFirst = edge.FirstParameter
        obj.ParameterLast = edge.LastParameter
        self.execute(obj) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:24,代碼來源:Discretize.py

示例4: getTarget

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def getTarget( self, obj, typ):
        o = obj.Edge[0]
        e = obj.Edge[1][0]
        n = eval(e.lstrip('Edge'))
        try:
            edge = o.Shape.Edges[n-1]
            obj.setEditorMode("Target", 2)
            for w in o.Shape.Wires:
                for e in w.Edges:
                    if edge.isSame(e):
                        debug("found matching edge")
                        debug("wire has %d edges"%len(w.Edges))
                        obj.setEditorMode("Target", 0)
                        if typ:
                            return w
            return edge
        except:
            return None 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:20,代碼來源:Discretize.py

示例5: getShape

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def getShape(self, fp):
        if fp.Source is None:
            return None, None
        if fp.Source[1] == []: # No subshape given, take wire 1
            if fp.Source[0].Shape.Wires:
                w = fp.Source[0].Shape.Wire1
                e = w.approximate(1e-7, 1e-5, len(w.Edges), 7).toShape()
                #double tol2d = gp::Resolution();
                #double tol3d = 0.0001;
                #int maxseg=10, maxdeg=3;
                #static char* kwds_approx[] = {"Tol2d","Tol3d","MaxSegments","MaxDegree",NULL};
            else:
                return None, None
        else:
            e = _utils.getShape(fp, "Source", "Edge")
            w = False
        return e, w 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:19,代碼來源:splitCurves_2.py

示例6: Activated

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def Activated(self):
        edges = []
        sel = FreeCADGui.Selection.getSelectionEx()
        if sel == []:
            FreeCAD.Console.PrintError("Select the edges to split first !\n")
        for selobj in sel:
            if selobj.HasSubObjects:
                for i in range(len(selobj.SubObjects)):
                    if isinstance(selobj.SubObjects[i], Part.Edge):
                        self.makeSplitFeature((selobj.Object, selobj.SubElementNames[i]))
                        if selobj.Object.Shape:
                            if len(selobj.Object.Shape.Edges) == 1:
                                selobj.Object.ViewObject.Visibility = False
            else:
                self.makeSplitFeature((selobj.Object, []))
                if hasattr(selobj.Object,"ViewObject"):
                    selobj.Object.ViewObject.Visibility = False 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:19,代碼來源:splitCurves_2.py

示例7: __init__

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def __init__(self, obj , edges):
        debug("BlendCurve class Init")
        
        obj.addProperty("App::PropertyLinkSub",         "Edge1",      "Edge1", "Edge 1").Edge1 = edges[0]
        obj.addProperty("App::PropertyLinkSub",         "Edge2",      "Edge2", "Edge 2").Edge2 = edges[1]
        obj.addProperty("App::PropertyInteger",         "DegreeMax",  "BlendCurve", "Max degree of the Blend curve").DegreeMax = 9
        obj.addProperty("App::PropertyFloatConstraint", "Parameter1", "Edge1", "Location of blend curve")
        obj.addProperty("App::PropertyFloatConstraint", "Scale1",     "Edge1", "Scale of blend curve")
        obj.addProperty("App::PropertyEnumeration",     "Continuity1","Edge1", "Continuity").Continuity1=["C0","G1","G2","G3","G4"]
        obj.addProperty("App::PropertyFloatConstraint", "Parameter2", "Edge2", "Location of blend curve")
        obj.addProperty("App::PropertyFloatConstraint", "Scale2",     "Edge2", "Scale of blend curve")
        obj.addProperty("App::PropertyEnumeration",     "Continuity2","Edge2", "Continuity").Continuity2=["C0","G1","G2","G3","G4"]
        obj.addProperty("App::PropertyVectorList",      "CurvePts",   "BlendCurve", "CurvePts")
        obj.addProperty("App::PropertyEnumeration",     "Output",     "BlendCurve", "Output type").Output=["Wire","Joined","Single"]
        obj.Scale1 = (1.,-5.0,5.0,0.05)
        obj.Scale2 = (1.,-5.0,5.0,0.05)
        obj.Parameter1 = ( 1.0, 0.0, 1.0, 0.05 )
        obj.Parameter2 = ( 1.0, 0.0, 1.0, 0.05 )
        obj.Proxy = self 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:21,代碼來源:ParametricBlendCurve.py

示例8: update_shape

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def update_shape(self):
        e1 = _utils.getShape(self.Object, "Edge1", "Edge")
        e2 = _utils.getShape(self.Object, "Edge2", "Edge")
        if e1 and e2:
            bc = nurbs_tools.blendCurve(e1,e2)
            v = Part.Vertex(self.m1.point)
            proj = v.distToShape(self.m1.snap_shape)[1][0][1]
            bc.param1 = e1.Curve.parameter(proj)
            #bc.param1 = (pa1 - self.m1.snap_shape.FirstParameter) / (self.m1.snap_shape.LastParameter - self.m1.snap_shape.FirstParameter)
            bc.scale1 = self.t1.parameter
            bc.cont1 = self.Object.Proxy.getContinuity(self.c1.text[0])

            v = Part.Vertex(self.m2.point)
            proj = v.distToShape(self.m2.snap_shape)[1][0][1]
            bc.param2 = e2.Curve.parameter(proj)
            #bc.param2 = (pa2 - self.m2.snap_shape.FirstParameter) / (self.m2.snap_shape.LastParameter - self.m2.snap_shape.FirstParameter)
            bc.scale2 = self.t2.parameter
            bc.cont2 = self.Object.Proxy.getContinuity(self.c2.text[0])
            bc.maxDegree = self.Object.DegreeMax
            bc.compute()
            self.Object.Shape = bc.Curve.toShape()
            return bc 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:24,代碼來源:ParametricBlendCurve.py

示例9: unsetEdit

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def unsetEdit(self,vobj,mode=0):
        e1 = _utils.getShape(self.Object, "Edge1", "Edge")
        e2 = _utils.getShape(self.Object, "Edge2", "Edge")
        if isinstance(self.ip, pointEditor):
            v = Part.Vertex(self.m1.point)
            proj = v.distToShape(self.m1.snap_shape)[1][0][1]
            pa1 = e1.Curve.parameter(proj)
            self.Object.Parameter1 = (pa1 - self.m1.snap_shape.FirstParameter) / (self.m1.snap_shape.LastParameter - self.m1.snap_shape.FirstParameter)
            self.Object.Scale1 = self.t1.parameter
            self.Object.Continuity1 = self.c1.text[0]

            v = Part.Vertex(self.m2.point)
            proj = v.distToShape(self.m2.snap_shape)[1][0][1]
            pa2 = e2.Curve.parameter(proj)
            self.Object.Parameter2 = (pa2 - self.m2.snap_shape.FirstParameter) / (self.m2.snap_shape.LastParameter - self.m2.snap_shape.FirstParameter)
            self.Object.Scale2 = self.t2.parameter
            self.Object.Continuity2 = self.c2.text[0]
            
            vobj.Selectable = self.select_state
            vobj.PointSize = self.ps
            self.ip.quit()
        self.ip = None
        self.active = False
        #vobj.Visibility = True
        return True 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:27,代碼來源:ParametricBlendCurve.py

示例10: Activated

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def Activated(self):
        s = FreeCADGui.Selection.getSelectionEx()
        edges = []
        for so in s:
            for i in range(len(so.SubObjects)):
                #subshapes(su)
                if isinstance(so.SubObjects[i], Part.Edge):
                    edges.append((so.Object,(so.SubElementNames[i], )))
            if not so.HasSubObjects:
                if so.Object.Shape.Wires:
                    edges.append(so.Object)
                elif so.Object.Shape.Edges:
                    edges.append(so.Object)

        if len(edges) < 1:
            FreeCAD.Console.PrintError("Select something first !\n")
        else:
            self.makeFeature(edges) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:20,代碼來源:HQRuledSurfaceFP.py

示例11: __init__

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def __init__(self, obj , edge):
        ''' Add the properties '''
        debug("Comb class Init")
        obj.addProperty("App::PropertyLinkSubList","Edge","Comb","Edge").Edge = edge
        #obj.addProperty("App::PropertyEnumeration","Type","Comb","Comb Type").Type=["Curvature","Unit Normal"]
        obj.addProperty("App::PropertyFloat","Scale","Comb","Scale (%). 0 for AutoScale").Scale=0.0
        #obj.addProperty("App::PropertyBool","ScaleAuto","Comb","Automatic Scale").ScaleAuto = True
        obj.addProperty("App::PropertyIntegerConstraint","Samples","Comb","Number of samples").Samples = 100
        obj.addProperty("App::PropertyInteger","Number","Surface","Number of surface samples").Number = 3
        obj.addProperty("App::PropertyEnumeration","Orientation","Surface","Surface Comb Orientation").Orientation=["U","V","UV"]
        #obj.addProperty("App::PropertyFloat","TotalLength","Comb","Total length of edges")
        obj.addProperty("App::PropertyVectorList","CombPoints","Comb","CombPoints")
        obj.addProperty("Part::PropertyPartShape","Shape","Comb", "Shape of comb plot")
        obj.Proxy = self
        #obj.Samples = (20,2,1000,10)
        obj.CombPoints = []
        self.edges = []
        self.TotalLength = 0.0
        self.factor = 1.0
        #self.selectedEdgesToProperty( obj, edge)
        #self.setEdgeList( obj)
        self.execute(obj)
        obj.Scale = self.factor 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:25,代碼來源:ParametricComb.py

示例12: shape

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def shape(self):
        proj1 = self.shape1.toNurbs().extrude(self.dir1)
        proj2 = self.shape2.toNurbs().extrude(self.dir2)
        curves = list()
        for f1 in proj1.Faces:
            for f2 in proj2.Faces:
                curves += f1.Surface.intersectSS(f2.Surface)
        intersect = [c.toShape() for c in curves]
        edges = []
        for sh in intersect:
            if isinstance(sh, Part.Edge) and sh.Length > 1e-7:
                edges.append(sh)
        se = Part.sortEdges(edges)
        wires = []
        for el in se:
            wires.append(Part.Wire(el))
        return Part.Compound(wires) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:19,代碼來源:combined_curve.py

示例13: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def execute(self, obj):
        e = _utils.getShape(obj, "Edge", "Edge")
        p = obj.Value
        if   obj.Method == "Percent":
            p = self.PercentToParam(e, obj.Value)
        elif obj.Method == "Distance":
            p = self.DistanceToParam(e, obj.Value)
        if p > e.FirstParameter and p < e.LastParameter:
            w = e.split(p)
            if   obj.Output == "Start":
                obj.Shape = w.Edges[0]
            elif obj.Output == "End":
                obj.Shape = w.Edges[-1]
            else:
                obj.Shape = w
        else:
            obj.Shape = e
        obj.Placement = e.Placement 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:20,代碼來源:splitCurves.py

示例14: Activated

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def Activated(self):
        edges = []
        verts = []
        source = None
        sel = FreeCADGui.Selection.getSelectionEx()
        if sel == []:
            FreeCAD.Console.PrintError("Select at least 1 edge !\n")
        for selobj in sel:
            if selobj.HasSubObjects:
                for i in range(len(selobj.SubObjects)):
                    if isinstance(selobj.SubObjects[i], Part.Edge):
                        edges.append((selobj.Object, selobj.SubElementNames[i]))
                        selobj.Object.ViewObject.Visibility=False
                    elif isinstance(selobj.SubObjects[i], Part.Vertex):
                        verts=(selobj.Object, selobj.SubElementNames[i])
                        #selobj.Object.ViewObject.Visibility=False
            else:
                source = selobj.Object
                selobj.Object.ViewObject.Visibility=False
        if source:
            self.makeProfileFeature(source, verts)
        elif edges:
            self.makeProfileFeature(edges, verts) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:25,代碼來源:pipeshellProfileFP.py

示例15: ancestors

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Edge [as 別名]
def ancestors(shape, sub):
    '''list_of_shapes = ancestors(shape, sub)
    Returns the closest ancestors of "sub" in "shape"'''
    def cleanup(shape):
        s = str(shape)
        ss = s.split()[0]
        return ss.split('<')[1]
    shd = (Part.Vertex,
           Part.Edge,
           Part.Wire,
           Part.Face,
           Part.Shell,
           Part.Solid,
           Part.CompSolid,
           Part.Compound)
    for i in range(len(shd)-1):
        if isinstance(sub, shd[i]):
            for j in range(i+1,len(shd)):
                manc = shape.ancestorsOfType(sub, shd[j])
                if manc:
                    print("{} belongs to {} {}.".format(cleanup(sub), len(manc), cleanup(manc[0])))
                    return manc 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:24,代碼來源:_utils.py


注:本文中的Part.Edge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。