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


Python Part.makePolygon方法代码示例

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


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

示例1: getRails

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def getRails(self, shapes):
        nbvert = len(shapes[0].Vertexes)
        edges = []
        for i in range(nbvert):
            pts = []
            for s in shapes:
                pts.append(s.Vertexes[i].Point)
            try:
                bs = Part.BSplineCurve()
                bs.interpolate(pts)
                edges.append(bs.toShape())
                debug("Rail %d : BSpline curve"%i)
            except Part.OCCError:
                po = Part.makePolygon(pts)
                edges.append(po)
                debug("Rail %d : Polygon"%i)
        return(edges) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:19,代码来源:pipeshellFP.py

示例2: mapEdgesLines

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

示例3: cylindricprojection

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def cylindricprojection(self,*args, **kwargs):

    s=App.activeDocument().ReflectLines001.Shape

    eds=[]
    for e in s.Edges:
        pts2=[]
        pts=e.discretize(100)
        for p in pts:
            h=p.y
            arc=np.arctan2(p.x,p.z)
            r=FreeCAD.Vector(p.x,p.z).Length
            R=150
            p2=FreeCAD.Vector(np.sin(arc)*R,h,np.cos(arc)*R)
            pts2 += [p2]

        Part.show(Part.makePolygon(pts2))

 


#-------------------------- 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:24,代码来源:dev.py

示例4: makeSquareTool

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def makeSquareTool(s, m):
  # makes a cylinder with an inner square hole, used as cutting tool
  # create square face
  msq = Base.Matrix()
  msq.rotateZ(math.radians(90.0))
  polygon = []
  vsq = Base.Vector(s / 2.0, s / 2.0, -m * 0.1)
  for i in range(4):
     polygon.append(vsq)
     vsq = msq.multiply(vsq)
  polygon.append(vsq)
  square = Part.makePolygon(polygon)
  square = Part.Face(square)

  # create circle face
  circ = Part.makeCircle(s * 3.0, Base.Vector(0.0, 0.0, -m * 0.1))
  circ = Part.Face(Part.Wire(circ))

  # Create the face with the circle as outline and the square as hole
  face=circ.cut(square)
 
  # Extrude in z to create the final cutting tool
  exSquare = face.extrude(Base.Vector(0.0, 0.0, m * 1.2))
  # Part.show(exHex)
  return exSquare 
开发者ID:shaise,项目名称:FreeCAD_FastenersWB,代码行数:27,代码来源:FSNuts.py

示例5: smMakeFace

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def smMakeFace(edge, dir, extLen, gap1 = 0.0,
               gap2 = 0.0, angle1 = 0.0, angle2 = 0.0, op = ''):
    len1 = extLen * math.tan(math.radians(angle1))
    len2 = extLen * math.tan(math.radians(angle2))

    p1 = edge.valueAt(edge.LastParameter - gap2)
    p2 = edge.valueAt(edge.FirstParameter + gap1)
    p3 = edge.valueAt(edge.FirstParameter + gap1 + len1) + dir.normalize() * extLen
    p4 = edge.valueAt(edge.LastParameter - gap2 - len2) + dir.normalize() * extLen

    e2 = Part.makeLine(p2, p3)
    e4 = Part.makeLine(p4, p1)
    section = e4.section(e2)

    if section.Vertexes :
      p5 = section.Vertexes[0].Point
      w = Part.makePolygon([p1,p2,p5,p1])
    else :
      w = Part.makePolygon([p1,p2,p3,p4,p1])
    face = Part.Face(w)
    if hasattr(face, 'mapShapes'):
        face.mapShapes([(edge,face)],None,op)
    return face 
开发者ID:shaise,项目名称:FreeCAD_SheetMetal,代码行数:25,代码来源:SheetMetalCmd.py

示例6: make_front_panels

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def make_front_panels(length, height, thickness, spacing):
    half_length = length / 2.0
    down_height = -height / 2.0
    up_height = height / 2.0
    y = spacing / 2.0
    p1 = FreeCAD.Vector(-half_length, y, down_height)
    p2 = FreeCAD.Vector(-half_length, y, up_height)
    p3 = FreeCAD.Vector(half_length, y, up_height)
    p4 = FreeCAD.Vector(half_length, y, down_height)

    wire=Part.makePolygon([p1,p2,p3,p4,p1])
    face = Part.Face(wire)
    front_part = face.extrude(FreeCAD.Vector(0, thickness, 0))
    behind_part = front_part.copy()
    behind_part.translate(FreeCAD.Vector(0, -spacing - thickness, 0))

    return front_part, behind_part 
开发者ID:execuc,项目名称:LCInterlocking,代码行数:19,代码来源:makebox.py

示例7: make_twice_half_front_panel

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def make_twice_half_front_panel(length, height, thickness, spacing):
    quarter_length = length / 4.0
    down_height = -height / 2.0
    up_height = height / 2.0
    y = spacing / 2.0
    p1 = FreeCAD.Vector(-quarter_length, y, down_height)
    p2 = FreeCAD.Vector(-quarter_length, y, up_height)
    p3 = FreeCAD.Vector(quarter_length, y, up_height)
    p4 = FreeCAD.Vector(quarter_length, y, down_height)

    wire = Part.makePolygon([p1,p2,p3,p4,p1])
    face = Part.Face(wire)
    front_part_1 = face.extrude(FreeCAD.Vector(0, thickness, 0))
    front_part_2 = front_part_1.copy()
    front_part_1.translate(FreeCAD.Vector(-quarter_length, 0, 0))
    front_part_2.translate(FreeCAD.Vector(quarter_length, 0, 0))

    return front_part_1, front_part_2

# YZ plan 
开发者ID:execuc,项目名称:LCInterlocking,代码行数:22,代码来源:makebox.py

示例8: make_side_panels

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def make_side_panels(width, height, thickness, spacing):
    half_width = width / 2.0
    down_height = -height / 2.0
    up_height = height / 2.0
    x = spacing / 2.0
    p1 = FreeCAD.Vector(x, -half_width, down_height)
    p2 = FreeCAD.Vector(x, -half_width, up_height)
    p3 = FreeCAD.Vector(x, half_width, up_height)
    p4 = FreeCAD.Vector(x, half_width, down_height)

    wire = Part.makePolygon([p1,p2,p3,p4,p1])
    face = Part.Face(wire)
    left_part = face.extrude(FreeCAD.Vector(thickness, 0, 0))
    right_part = left_part.copy()
    right_part.translate(FreeCAD.Vector(-spacing - thickness, 0, 0))

    return left_part, right_part 
开发者ID:execuc,项目名称:LCInterlocking,代码行数:19,代码来源:makebox.py

示例9: shapeGrid

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

示例10: param_samples

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def param_samples(edge, samples=10):
    fp = edge.FirstParameter
    lp = edge.LastParameter
    ra = lp-fp
    return [fp+float(i)*ra/(samples-1) for i in range(samples)]

# doesn't work
#def eval_smoothness(edge, samples=10):
    #params = param_samples(edge, samples)
    ## compute length score
    #chord = edge.valueAt(edge.LastParameter) - edge.valueAt(edge.FirstParameter)
    #if chord.Length > 1e-7: 
        #length_score = (edge.Length / chord.Length) - 1.0
    #else:
        #length_score = None
    ## compute tangent and curvature scores
    #tans = list()
    #curv = list()
    #for p in params:
        #tans.append(edge.tangentAt(p))
        #curv.append(edge.curvatureAt(p))
    #poly = Part.makePolygon(tans)
    #tangent_score = poly.Length
    #m = max(curv)
    #if m > 1e-7:
        #curvature_score = (m-min(curv))/m
    #else:
        #curvature_score = 0.0
    #return length_score,tangent_score,curvature_score 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:31,代码来源:nurbs_tools.py

示例11: draw_box

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def draw_box():
    #pts = [getPoint(-0.5,-0.5), getPoint(0.5,-0.5), getPoint(0.5,0.5), getPoint(-0.5,0.5), getPoint(-0.5,-0.5)]
    pts = [getPoint(0,0), getPoint(1,0), getPoint(1,1), getPoint(0,1), getPoint(0,0)]
    poly = Part.makePolygon(pts)
    Part.show(poly) 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:7,代码来源:grid2.py

示例12: execute

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def execute(self, obj):
        debug("* Interpolate : execute *")
        pts = self.getPoints(obj)
        self.setParameters(obj)
        if obj.Polygonal:
            if obj.Periodic:
                pts.append(pts[0])
            poly = Part.makePolygon(pts)
            if obj.WireOutput:
                obj.Shape = poly
                return
            else:
                bs = poly.approximate(1e-8,obj.Tolerance,999,1)
        else:
            bs = Part.BSplineCurve()
            bs.interpolate(Points=pts, PeriodicFlag=obj.Periodic, Tolerance=obj.Tolerance, Parameters=obj.Parameters)
            if not (len(obj.Tangents) == len(pts) and len(obj.TangentFlags) == len(pts)): # or obj.DetectAligned:
                if obj.Periodic:
                    obj.Tangents = [bs.tangent(p)[0] for p in obj.Parameters[0:-1]]
                else:
                    obj.Tangents = [bs.tangent(p)[0] for p in obj.Parameters]
                obj.TangentFlags = [True]*len(pts)
            if obj.CustomTangents: # or obj.DetectAligned:
                #if obj.DetectAligned:
                    #self.detect_aligned_pts(obj, pts)
                bs.interpolate(Points=pts, PeriodicFlag=obj.Periodic, Tolerance=obj.Tolerance, Parameters=obj.Parameters, Tangents=obj.Tangents, TangentFlags=obj.TangentFlags) #, Scale=False)
        obj.Shape = bs.toShape() 
开发者ID:tomate44,项目名称:CurvesWB,代码行数:29,代码来源:interpolate.py

示例13: createShape

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def createShape(a):

    pa=FreeCAD.Vector(0,0,0)
    pb=FreeCAD.Vector(a*50,0,0)
    pc=FreeCAD.Vector(0,50,0)
    shape=Part.makePolygon([pa,pb,pc,pa])
    return shape 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:9,代码来源:FreeCAD_Placement.py

示例14: run_FreeCAD_Toy3

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def run_FreeCAD_Toy3(self):
    # testdaten fuer toponaming

    pts=[
    [0,0,0],[10,0,0],[10,5,0],[0,5,0],
    [0,0,15],[10,0,15],[10,5,15],[0,5,10]
    ]

    if 1:
        [A,B,C,D,E,F,G,H]=[FreeCAD.Vector(p) for p in pts]
        col=[Part.makePolygon(l) for l in [[A,B],[B,C],[C,D],[D,A],
                [E,F],[F,G],[G,H],[H,E],
                [A,E],[B,F],[C,G],[D,H]]]
        
        Part.show(Part.Compound(col)) 
开发者ID:microelly2,项目名称:NodeEditor,代码行数:17,代码来源:dev_Development.py

示例15: make_rect

# 需要导入模块: import Part [as 别名]
# 或者: from Part import makePolygon [as 别名]
def make_rect(size,params=None):
    _ = params 
    return Part.makePolygon([product(size,Vector(*v))
        for v in ((-0.5,-0.5),(0.5,-0.5),(0.5,0.5),(-0.5,0.5),(-0.5,-0.5))]) 
开发者ID:realthunder,项目名称:fcad_pcb,代码行数:6,代码来源:kicad.py


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