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


Python Part.Compound方法代碼示例

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


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

示例1: shape

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [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

示例2: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def execute(self, obj):
        sh = None
        rl = False
        if len(obj.IndivFaces) > 0:
            faces = _utils.getShape(obj, "IndivFaces", "Face")
            sh = Part.Compound(faces)
        elif hasattr(obj.Source,"Shape"):
            sh = obj.Source.Shape
        try:
            rl = sh.reflectLines(obj.ViewDir, obj.ViewPos, obj.UpDir)
        except AttributeError:
            pass
        if rl and obj.ShapeCleaning:
            edges = rl.Edges
            rl = Part.Compound(nurbs_tools.remove_subsegments(edges, num=obj.Samples, tol=obj.Tolerance))
        if rl:
            obj.Shape = rl 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:19,代碼來源:ReflectLinesFP.py

示例3: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def execute(self, obj):
        if not hasattr(obj, "Sources"):
            return
        src_shapes = []
        for o in obj.Sources:
            sh = o.Shape.copy()
            #pl = sh.Placement
            sh.Placement = o.getGlobalPlacement() #.multiply(pl)
            src_shapes.append(sh)
        solids = []
        num_faces = len(src_shapes[0].Faces)
        for i in range(num_faces):
            faces = [src_shapes[0].Faces[i], src_shapes[-1].Faces[i]]
            loft = []
            num_wires = len(faces[0].Wires)
            for j in range(num_wires):
                wires = []
                for o in src_shapes:
                    wires.append(o.Faces[i].Wires[j])
                loft = Part.makeLoft(wires, False, obj.Ruled, obj.Closed, obj.MaxDegree)
                faces.extend(loft.Faces)
            shell = Part.Shell(faces)
            solids.append(Part.Solid(shell))
        obj.Shape = Part.Compound(solids) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:26,代碼來源:multiLoftFP.py

示例4: mapEdgesLines

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def mapEdgesLines( uvedges,face):

    if face == None:
        sayW("no face")
        return Part.Shape()
    col=[]
    say("face",face)
    umin,umax,vmin,vmax=face.ParameterRange
    sf=face.Surface
    for edge in uvedges:
        ua,va,ub,vb=edge
        ua=umin+ua*(umax-umin)
        va=vmin+va*(vmax-vmin)

        ub=umin+ub*(umax-umin)
        vb=vmin+vb*(vmax-vmin)
        
        pa=sf.value(ua,va)
        pb=sf.value(ub,vb)
        say(pa)
        col += [Part.makePolygon([pa,pb])]

    shape=Part.Compound(col)
    return shape 
開發者ID:microelly2,項目名稱:NodeEditor,代碼行數:26,代碼來源:dev.py

示例5: mapEdgesCurves

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def mapEdgesCurves( edges,face):
    '''geschmiegte V<ariante'''

    col=[]
    umin,umax,vmin,vmax=face.ParameterRange
    sf=face.Surface
    for edge in edges:
        ua,va,ub,vb=edge
        ua=umin+ua*(umax-umin)
        va=vmin+va*(vmax-vmin)
        ub=umin+ub*(umax-umin)
        vb=vmin+vb*(vmax-vmin)

        a=FreeCAD.Base.Vector2d(ua,va)
        b=FreeCAD.Base.Vector2d(ub,vb)
        bs2d = Part.Geom2d.BSplineCurve2d()
        bs2d.buildFromPolesMultsKnots([a,b],[2,2],[0,1],False,1)
        ee = bs2d.toShape(sf)
        col += [ee]

    shape=Part.Compound(col)
    return shape 
開發者ID:microelly2,項目名稱:NodeEditor,代碼行數:24,代碼來源:dev.py

示例6: geomType

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def geomType(self):
        """
            Gets the underlying geometry type
            :return: a string according to the geometry type.

            Implementations can return any values desired, but the
            values the user uses in type filters should correspond to these.

            As an example, if a user does::

                CQ(object).faces("%mytype")

            The expectation is that the geomType attribute will return 'mytype'

            The return values depend on the type of the shape:

            Vertex:  always 'Vertex'
            Edge:   LINE, ARC, CIRCLE, SPLINE
            Face:   PLANE, SPHERE, CONE
            Solid:  'Solid'
            Shell:  'Shell'
            Compound: 'Compound'
            Wire:   'Wire'
        """
        return self.wrapped.ShapeType 
開發者ID:jmwright,項目名稱:cadquery-freecad-module,代碼行數:27,代碼來源:shapes.py

示例7: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def execute(self, obj):
        debug("* Discretization : execute *")
        if self.buildPoints( obj):
            obj.Shape = Part.Compound([Part.Vertex(i) for i in obj.Points]) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:6,代碼來源:Discretize.py

示例8: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def execute(self, obj):
        c1, c2 = self.get_curves(obj)
        nc1, nc2 = rp.reparametrize(c1, c2, num=obj.Samples, smooth_start=obj.SmoothingFactorStart, smooth_end=obj.SmoothingFactorEnd, method=obj.Method )
        #com = Part.Compound([nc1.toShape(), nc2.toShape()])
        rs = Part.makeRuledSurface(nc1.toShape(), nc2.toShape())
        if isinstance(rs, Part.Face) and rs.isValid():
            obj.Shape = rs 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:9,代碼來源:HQRuledSurfaceFP.py

示例9: LocalProfiles

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def LocalProfiles(self):
        el = []
        for pro in self.profiles:
            el.append(pro.localCurve1)
        return(Part.Compound(el)) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:7,代碼來源:libS2R.py

示例10: InterpoCurves

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def InterpoCurves(self):
        el = []
        for ic in self.interpoCurves:
            for c in ic:
                el.append(Part.Edge(c))
        return(Part.Compound(el)) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:8,代碼來源:libS2R.py

示例11: shapeGrid

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def shapeGrid(self):
        poly = []
        #polyV = []
        for row in self.result:
            poly.append(Part.makePolygon(row))
        for i in range(len(self.result[0])):
            row = []
            for j in range(len(self.result)):
                row.append(self.result[j][i])
            poly.append(Part.makePolygon(row))
        c = Part.Compound(poly)
        return(c) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:14,代碼來源:libS2R.py

示例12: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def execute(self, obj):
        faces = _utils.getShape(obj,"Faces","Face")
        shell = Part.Shell(faces)
        solid = Part.Solid(shell)
        if solid.isValid():
            obj.Shape = solid
        elif shell.isValid():
            obj.Shape = shell
        else:
            obj.Shape = Part.Compound(faces) 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:12,代碼來源:parametricSolid.py

示例13: sweep_wire

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def sweep_wire(self, w, solid=False):
        faces = []
        for e in w.Edges:
            faces.append(self.sweep_edge(e,solid))
        shell = Part.Shell(faces)
        shell.sewShape()
        if solid:
            cyl = Part.makeCylinder(self.max_radius*2, self.nb_of_turns*self.lead)
            cyl.Placement = self._placement.multiply(FreeCAD.Placement(FreeCAD.Vector(),FreeCAD.Vector(1,0,0),-90))
            common = cyl.common(shell)
            cut_faces = common.Faces
            new_edges = []
            for e1 in common.Edges:
                found = False
                for e2 in shell.Edges:
                    if nurbs_tools.is_same(e1.Curve, e2.Curve, tol=1e-7, full=False):
                        found = True
                        #print("found similar edges")
                        continue
                if not found:
                    new_edges.append(e1)
            #print(len(Part.sortEdges(new_edges)))
            el1, el2 = Part.sortEdges(new_edges)[0:2]
            f1 = Part.makeFace(Part.Wire(el1),'Part::FaceMakerSimple')
            f2 = Part.makeFace(Part.Wire(el2),'Part::FaceMakerSimple')
            cut_faces.extend([f1,f2])
            try:
                shell = Part.Shell(cut_faces)
                shell.sewShape()
                return Part.Solid(shell)
            except Part.OCCError:
                print("Failed to create solid")
                return Part.Compound(cut_faces)
        return shell 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:36,代碼來源:HelicalSweepFP.py

示例14: approximate

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def approximate(self, obj, input_shape):
        pts = False
        input_edges = None
        if isinstance(input_shape,(list, tuple)):
            #debug(isinstance(input_shape[0],Base.Vector))
            if isinstance(input_shape[0],Base.Vector):
                pts = input_shape
            elif isinstance(input_shape[0],Part.Edge):
                input_edges = input_shape
        else:
            input_edges = input_shape.Edges
        if not obj.Active:
            return Part.Compound(input_shape)
        edges = list()
        if input_edges:
            for e in input_edges:
                pts = e.discretize(obj.Samples)
                bs = Part.BSplineCurve()
                bs.approximate(Points = pts, DegMin = obj.DegreeMin, DegMax = obj.DegreeMax, Tolerance = obj.ApproxTolerance, Continuity = obj.Continuity, ParamType = obj.Parametrization)
                edges.append(bs.toShape())
            se = Part.sortEdges(edges)
            wires = []
            for el in se:
                if len(el) > 1:
                    wires.append(Part.Wire(el))
                else:
                    wires.append(el[0])
            if len(wires) > 1:
                return Part.Compound(wires)
            else:
                return wires[0]
        elif pts:
            bs = Part.BSplineCurve()
            bs.approximate(Points = pts, DegMin = obj.DegreeMin, DegMax = obj.DegreeMax, Tolerance = obj.ApproxTolerance, Continuity = obj.Continuity, ParamType = obj.Parametrization)
            return bs.toShape() 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:37,代碼來源:approximate_extension.py

示例15: shapeCloud

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import Compound [as 別名]
def shapeCloud(arr):
    v = []
    for row in arr:
        for pt in row:
            v.append(Part.Vertex(pt))
    c = Part.Compound(v)
    return c 
開發者ID:tomate44,項目名稱:CurvesWB,代碼行數:9,代碼來源:blendSurfaceFP.py


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