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


Python Part.makeCompound方法代码示例

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


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

示例1: execute

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def execute(self, fp):
    O=FreeCAD.Vector(0,0,0)
    vectL=FreeCAD.Vector(fp.L,0,0)
    vectW=FreeCAD.Vector(0,fp.W,0)
    vectH=FreeCAD.Vector(0,0,fp.H)
    base=[vectL,vectW,vectH]
    outline=[]
    for i in range(3):
      f1=Part.Face(Part.makePolygon([O,base[0],base[0]+base[1],base[1],O]))
      outline.append(f1)
      f2=f1.copy()
      f2.translate(base[2])
      outline.append(f2)
      base.append(base.pop(0))
    box=Part.Solid(Part.Shell(outline))
    tank=box.makeThickness([box.Faces[0],box.Faces[2]],-fp.thk1,1.e-3)
    top=Part.makeBox(fp.L-2*fp.thk1,fp.W-2*fp.thk1,fp.thk2,FreeCAD.Vector(fp.thk1,fp.thk1,fp.H-2*fp.thk2))
    fp.Shape=Part.makeCompound([tank,top]) 
开发者ID:oddtopus,项目名称:flamingo,代码行数:20,代码来源:pipeFeatures.py

示例2: _makeCompound

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def _makeCompound(self,obj,name,label=None,fit_arcs=False,
            fuse=False,add_feature=False,force=False):

        obj = unpack(obj)
        if not isinstance(obj,(list,tuple)):
            if not force and (
               not fuse or obj.TypeId=='Path::FeatureArea'):
                return obj
            obj = [obj]

        if fuse:
            return self._makeArea(obj,name,label=label,fit_arcs=fit_arcs)

        if add_feature or self.add_feature:
            return self._makeObject('Part::Compound',
                    '{}_combo'.format(name),label,'Links',obj)

        return Part.makeCompound(obj) 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:20,代码来源:kicad.py

示例3: _makeCustomPad

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def _makeCustomPad(self, params):
        wires = []
        for key in params.primitives:
            wire,width = makePrimitve(key, getattr(params.primitives, key))
            if not width:
                if isinstance(wire, Part.Edge):
                    wire = Part.Wire(wire)
                wires.append(wire)
            else:
                wire = Path.Area(Accuracy=self.arc_fit_accuracy,Thicken=wire.isClosed(),
                            Offset=width*0.5).add(wire).getShape()
                wires += wire.Wires
        if not wires:
            return
        if len(wires) == 1:
            return wires[0]
        return Part.makeCompound(wires) 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:19,代码来源:kicad.py

示例4: PathToShape

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def PathToShape(point_list):
    # creates a compound of faces from a NiCr point list to representate the wire
    # trajectory
    comp = []
    for i in range(len(point_list[0])-1):
        pa_0 = FreeCAD.Vector(tuple(point_list[0][i]))
        pa_1 = FreeCAD.Vector(tuple(point_list[0][i+1]))
        pb_0 = FreeCAD.Vector(tuple(point_list[1][i]))
        pb_1 = FreeCAD.Vector(tuple(point_list[1][i+1]))
        l0 = Part.Line(pa_0, pa_1).toShape()
        l1 = Part.Line(pb_0, pb_1).toShape()
        f = Part.makeLoft([l0, l1])
        comp.append(f)

    return Part.makeCompound(comp)




# routing between WirePaths (wirepath path link) 
开发者ID:JMG1,项目名称:NiCr,代码行数:22,代码来源:NiCrPath.py

示例5: updateTrajectoryLines

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def updateTrajectoryLines():
    EAFolder = FreeCAD.ActiveDocument.ExplodedAssembly.Group
    # remove all the previous trajectory lines
    for traj in EAFolder:
        for lines in traj.Group:
            FreeCAD.ActiveDocument.removeObject(lines.Name)

    # re-draw all trajectories
    for traj in EAFolder:
        lines_compound = []
        objects = []
        for name in traj.names:
            objects.append(FreeCAD.ActiveDocument.getObject(name))

        inc_D = traj.Distance
        dir_vectors = []
        rot_centers = []
        for s in range(len(objects)):
            dir_vectors.append(FreeCAD.Vector(tuple(traj.dir_vectors[s])))
            rot_centers.append(FreeCAD.Vector(tuple(traj.rot_centers[s])))

        for n in range(len(objects)):
            pa = rot_centers[n]# objects[n].Placement.Base
            pb = rot_centers[n] + dir_vectors[n]*inc_D
            lines_compound.append(Part.makeLine(pa, pb))

        l_obj = FreeCAD.ActiveDocument.addObject('Part::Feature','trajectory_line')
        l_obj.Shape = Part.makeCompound(lines_compound)
        l_obj.ViewObject.DrawStyle = "Dashed"
        l_obj.ViewObject.LineWidth = 1.0
        traj.addObject(l_obj)

    FreeCAD.Gui.updateGui() 
开发者ID:JMG1,项目名称:ExplodedAssembly,代码行数:35,代码来源:ExplodedAssembly.py

示例6: updatePlacement

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def updatePlacement(self,pla=None,shape=None):
        obj = self.Object
        if not shape:
            # If the shape is not given, we simply obtain the shape inside our
            # own "Shape" property
            shape = obj.Shape
            if not shape or shape.isNull():
                return
            # De-compound to obtain the original shape in our coordinate system
            shape = shape.SubShapes[0]

            # Call getElementInfo() to obtain part's placement only. We don't
            # need the shape here, in order to handle missing down-stream
            # element
            info = self.getInfo()
            pla = info.Placement

        if obj.Offset.isIdentity():
            objPla = FreeCAD.Placement()
        else:
            if hasProperty(obj,'Radius'):
                s = shape.SubShapes[0]
            else:
                s = shape
            # obj.Offset is in the element shape's coordinate system, we need to
            # transform it to the assembly coordinate system
            mat = pla.multiply(utils.getElementPlacement(s)).toMatrix()
            objPla = FreeCAD.Placement(mat*obj.Offset.toMatrix()*mat.inverse())

        # Update the shape with its owner Part's current placement
        shape.Placement = pla

        # Make a compound to contain the part's placement. There may be
        # additional placement for this element which is updated below
        shape = Part.makeCompound(shape)
        obj.Shape = shape
        obj.Placement = objPla

        # unfortunately, we can't easily check two shapes are the same
        self.version.value += 1 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:42,代码来源:assembly.py

示例7: make_gr_circle

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def make_gr_circle(params, width=0):
    center = makeVect(params.center)
    end = makeVect(params.end)
    r = center.distanceToPoint(end)
    if not width or r <= width*0.5:
        return Part.makeCircle(r+width*0.5, center)
    return Part.makeCompound([Part.Wire(Part.makeCircle(r+width*0.5,center)),
                              Part.Wire(Part.makeCircle(r-width*0.5,center,Vector(0,0,-1)))]) 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:10,代码来源:kicad.py

示例8: getFaceCompound

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def getFaceCompound(shape,wire=False):
    objs = []
    for f in shape.Faces:
        selected = True
        for v in f.Vertexes:
            if not isZero(v.Z):
                selected = False
                break
        if not selected:
            continue

        ################################################################
        ## TODO: FreeCAD curve.normalAt is not implemented
        ################################################################
        # for e in f.Edges:
            # if isinstance(e.Curve,(Part.LineSegment,Part.Line)): continue
            # if not isZero(e.normalAt(Vector()).dot(Vector(0,0,1))):
                # selected = False
                # break
        # if not selected: continue

        if not wire:
            objs.append(f)
            continue
        for w in f.Wires:
            objs.append(w)
    if not objs:
        raise ValueError('null shape')
    return Part.makeCompound(objs) 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:31,代码来源:kicad.py

示例9: _makeWires

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def _makeWires(self,obj,name,offset=0,fill=False,label=None,
            fit_arcs=False,workplane=False):

        if self.add_feature:
            if self.make_sketch:
                obj = self._makeSketch(obj,name,label)
            elif isinstance(obj,Part.Shape):
                obj = self._makeObject('Part::Feature', '{}_wire'.format(name),
                        label,'Shape',obj)
            elif isinstance(obj,(list,tuple)):
                objs = []
                comp = []
                for o in obj:
                    if isinstance(o,Part.Shape):
                        comp.append(o)
                    else:
                        objs.append(o)
                if comp:
                    comp = Part.makeCompound(comp)
                    objs.append(self._makeObject('Part::Feature',
                            '{}_wire'.format(name),label,'Shape',comp))
                obj = objs

        if fill or offset:
            return self._makeArea(obj,name,offset=offset,fill=fill,
                    fit_arcs=fit_arcs,label=label,workplane=workplane)
        else:
            return self._makeCompound(obj,name,label=label) 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:30,代码来源:kicad.py

示例10: generateSketch

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def generateSketch(self, edges, name, color):
        docG = FreeCADGui.ActiveDocument
        p = Part.makeCompound(edges)
        try:
            sk = Draft.makeSketch(p.Edges, autoconstraints = True,addTo=None,delete=False,name=name)
            sk.Label = name
        except:
            doc = FreeCAD.ActiveDocument
            skb = doc.ActiveObject
            doc.removeObject(skb.Name)
            SMWarning("discretizing Sketch")
            sk = SMmakeSketchfromEdges(p.Edges,name)
        docG.getObject(sk.Name).LineColor = color
        docG.getObject(sk.Name).PointColor = color 
开发者ID:shaise,项目名称:FreeCAD_SheetMetal,代码行数:16,代码来源:SheetMetalUnfolder.py

示例11: assemble_list_element_fast

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def assemble_list_element_fast(el_list):
    if len(el_list) == 0:
        return None
    return Part.makeCompound(el_list) 
开发者ID:execuc,项目名称:LCInterlocking,代码行数:6,代码来源:helper.py

示例12: execute

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makeCompound [as 别名]
def execute(self,obj):
        if not obj.isDerivedFrom('Part::FeaturePython'):
            self.version.value += 1
            return False

        if obj.Detach:
            self.updatePlacement()
            return True

        info = None
        try:
            info = self.getInfo(False)
        except Exception:
            self.updatePlacement()

            if not gui.AsmCmdManager.AutoFixElement:
                raise

            self.fix()
            info = self.getInfo(False)

        if not getattr(obj,'Radius',None):
            shape = Part.Shape(info.Shape).copy()
        else:
            if isinstance(info.Part,tuple):
                parentShape = Part.getShape(info.Part[2], info.Subname,
                        transform=info.Part[3], needSubElement=False)
            else:
                parentShape = Part.getShape(info.Part, info.Subname,
                        transform=False, needSubElement=False)
            found = False
            shapes = [info.Shape]
            pla = info.Shape.Placement
            for edge in parentShape.Edges:
                if not info.Shape.isCoplanar(edge) or \
                    not utils.isSameValue(
                        utils.getElementCircular(edge,True),obj.Radius):
                    continue
                edge = edge.copy()
                if not found and utils.isSamePlacement(pla,edge.Placement):
                    found = True
                    # make sure the direct referenced edge is the first one
                    shapes[0] = edge
                else:
                    shapes.append(edge)
            shape = shapes

        # Make a compound to contain shape's part-local-placement. A second
        # level compound will be made inside updatePlacement() to contain the
        # part's placement.
        shape = Part.makeCompound(shape)
        try:
            shape.ElementMap = info.Shape.ElementMap
        except Exception:
            pass
        self.updatePlacement(info.Placement,shape)
        return True 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:59,代码来源:assembly.py


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