當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。