当前位置: 首页>>代码示例>>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;未经允许,请勿转载。