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


Python Part.Solid方法代码示例

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


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

示例1: ancestors

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

示例2: execute

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

示例3: execute

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

示例4: geomType

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

示例5: sweep

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Solid [as 别名]
def sweep(cls, outerWire, innerWires, path, makeSolid=True, isFrenet=False):
        """
        Attempt to sweep the list of wires  into a prismatic solid along the provided path

        :param outerWire: the outermost wire
        :param innerWires: a list of inner wires
        :param path: The wire to sweep the face resulting from the wires over
        :return: a Solid object
        """

        # FreeCAD allows this in one operation, but others might not
        freeCADWires = [outerWire.wrapped]
        for w in innerWires:
            freeCADWires.append(w.wrapped)

        # f = FreeCADPart.Face(freeCADWires)
        wire = FreeCADPart.Wire([path.wrapped])
        result = wire.makePipeShell(freeCADWires, makeSolid, isFrenet)

        return Shape.cast(result) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:22,代码来源:shapes.py

示例6: sew_Shape

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Solid [as 别名]
def sew_Shape():
    """checking Shape"""

    doc=FreeCAD.ActiveDocument
    docG = FreeCADGui.ActiveDocument

    sel=FreeCADGui.Selection.getSelection()
    if len (sel) == 1:
        o = sel[0]
        if hasattr(o,'Shape'):
            sh = o.Shape.copy()
            sh.sewShape()
            sl = Part.Solid(sh)
            docG.getObject(o.Name).Visibility = False
            Part.show(sl)
            ao = FreeCAD.ActiveDocument.ActiveObject
            ao.Label = 'Solid'
            docG.ActiveObject.ShapeColor=docG.getObject(o.Name).ShapeColor
            docG.ActiveObject.LineColor=docG.getObject(o.Name).LineColor
            docG.ActiveObject.PointColor=docG.getObject(o.Name).PointColor
            docG.ActiveObject.DiffuseColor=docG.getObject(o.Name).DiffuseColor
            docG.ActiveObject.Transparency=docG.getObject(o.Name).Transparency
    else:
        FreeCAD.Console.PrintError('select only one object') 
开发者ID:shaise,项目名称:FreeCAD_SheetMetal,代码行数:26,代码来源:SheetMetalUnfolder.py

示例7: smExtrude

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Solid [as 别名]
def smExtrude(extLength = 10.0, selFaceNames = '', selObject = ''):
  
#  selFace = Gui.Selection.getSelectionEx()[0].SubObjects[0]
#  selObjectName = Gui.Selection.getSelection()[0].Name
  AAD = FreeCAD.ActiveDocument
  for selFaceName in selFaceNames:
    selFace = selObject.getElement(selFaceName)

    # extrusion direction
    V_extDir = selFace.normalAt( 0,0 )

    # extrusion
    wallFace = selFace.extrude( V_extDir*extLength )
    finalShape = selObject.fuse( wallFace )
  
  #finalShape = finalShape.removeSplitter()
  #finalShape = Part.Solid(finalShape.childShapes()[0])  
  #Gui.ActiveDocument.getObject( selObjectName ).Visibility = False
  return finalShape 
开发者ID:shaise,项目名称:FreeCAD_SheetMetal,代码行数:21,代码来源:SheetMetalCmd.py

示例8: __init__

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Solid [as 别名]
def __init__(self, obj):
        obj.addProperty("App::PropertyLinkSubList", "Faces", "Solid", "List of faces to build the solid")
        obj.Proxy = self 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:5,代码来源:parametricSolid.py

示例9: execute

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

示例10: makeSolidFeature

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Solid [as 别名]
def makeSolidFeature(self,source):
        solidFP = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Solid")
        solid(solidFP)
        solidVP(solidFP.ViewObject)
        solidFP.Faces = source
        FreeCAD.ActiveDocument.recompute()
        #solidFP.ViewObject.LineWidth = 2.0
        #solidFP.ViewObject.LineColor = (0.3,0.5,0.5) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:10,代码来源:parametricSolid.py

示例11: GetResources

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Solid [as 别名]
def GetResources(self):
        return {'Pixmap' : TOOL_ICON,
                'MenuText': 'Make Solid',
                'ToolTip': 'Make a parametric solid from selected faces'} 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:6,代码来源:parametricSolid.py

示例12: sweep_wire

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

示例13: execute

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Solid [as 别名]
def execute(self, obj):
        edges =  obj.Profile.Shape.Edges
        hs = HelicalSweep()
        hs.rational_approx = obj.Rational
        gpl = obj.Profile.getGlobalPlacement()
        hs.set_placement(gpl)
        # 3 priorities to get Lead value
        # 1 : obj.Lead property is >= 0
        # 2 : Sketch has a constraint called "Lead"
        # 3 : the longest of the DistanceY constraints
        if hasattr(obj,"Lead") and obj.Lead >= 0:
            hs.lead = obj.Lead
        else:
            dmin = 0
            for c in obj.Profile.Constraints:
                if c.Name == "Lead":
                    dmin = c.Value
                    continue
                else:
                    if c.Type == "DistanceY":
                        if c.Value > dmin:
                            dmin = c.Value
            hs.lead = dmin
        hs.nb_of_turns = obj.Turns
        obj.Shape = hs.sweep_wire(Part.Wire(edges), obj.Solid)
        
        #faces = [hs.sweep_edge(e, obj.Solid) for e in edges]
        #shell = Part.Shell(faces)
        #shell.sewShape()
        #obj.Shape = shell 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:32,代码来源:HelicalSweepFP.py

示例14: Activated

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Solid [as 别名]
def Activated(self):
    for selObj in Gui.Selection.getSelectionEx():
      obj = selObj.Object
      FreeCAD.Console.PrintLog("sel shape: " + str(obj.Shape) + "\n")
      if isinstance(obj.Shape, (Part.Solid, Part.Compound)):
        FreeCAD.Console.PrintLog("simplify shape: " + obj.Name + "\n")
        cobj = FreeCAD.ActiveDocument.addObject("Part::Feature", obj.Label + "_Copy")
        cobj.Shape = obj.Shape;
        Gui.ActiveDocument.getObject(obj.Name).Visibility = False
    FreeCAD.ActiveDocument.recompute()
    return 
开发者ID:shaise,项目名称:FreeCAD_FastenersWB,代码行数:13,代码来源:FastenerBase.py

示例15: extrude_partwb

# 需要导入模块: import Part [as 别名]
# 或者: from Part import Solid [as 别名]
def extrude_partwb(sketch, length, reverse=False, name=None):
    """Extrude via Part workbench.

    Parameters
    ----------
    sketch :

    length :

    reverse :
        (Default value = False)
    name : str
        (Default value = None)

    Returns
    -------
    FreeCAD.Part.Feature

    """
    doc = FreeCAD.ActiveDocument
    if name is None:
        f = doc.addObject("Part::Extrusion")
    else:
        f = doc.addObject("Part::Extrusion", name)
    f.Base = sketch
    f.DirMode = "Normal"
    f.DirLink = None
    f.LengthFwd = length
    f.LengthRev = 0.0
    f.Solid = True
    f.Reversed = reverse
    f.Symmetric = False
    f.TaperAngle = 0.0
    f.TaperAngleRev = 0.0
    # ~ f.Base.ViewObject.hide()
    doc.recompute()
    return f 
开发者ID:microsoft,项目名称:qmt,代码行数:39,代码来源:geomUtils.py


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