• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tests.makeUnitCube函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.makeUnitCube函数的典型用法代码示例。如果您正苦于以下问题:Python makeUnitCube函数的具体用法?Python makeUnitCube怎么用?Python makeUnitCube使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: testChamfer

 def testChamfer(self):
     """
     Test chamfer API with a box shape
     """
     cube = CQ(makeUnitCube()).faces(">Z").chamfer(0.1)
     self.saveModel(cube)
     self.assertEqual(10, cube.faces().size())
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:7,代码来源:TestCadQuery.py


示例2: testTranslateSolid

    def testTranslateSolid(self):
        c = CQ(makeUnitCube())
        self.assertAlmostEqual(0.0,c.faces("<Z").vertices().item(0).val().Z, 3 )

        #TODO: it might be nice to provide a version of translate that modifies the existing geometry too
        d = c.translate(Vector(0,0,1.5))
        self.assertAlmostEqual(1.5,d.faces("<Z").vertices().item(0).val().Z, 3 )
开发者ID:moeb,项目名称:cadquery,代码行数:7,代码来源:TestCadQuery.py


示例3: testFillet

 def testFillet(self):
     """
     Tests filleting edges on a solid
     """
     c = CQ( makeUnitCube()).faces(">Z").workplane().circle(0.25).extrude(0.25,True).edges("|Z").fillet(0.2)
     self.saveModel(c)
     self.assertEqual(12,c.faces().size() )
开发者ID:moeb,项目名称:cadquery,代码行数:7,代码来源:TestCadQuery.py


示例4: testFrontReference

 def testFrontReference(self):
     s = CQ(makeUnitCube()).faces("front").workplane() #make a workplane on the top face
     r = s.circle(0.125).cutBlind(-2.0)
     self.saveModel(r)
     #the result should have 7 faces
     self.assertEqual(7,r.faces().size() )
     self.assertEqual(type(r.val()), Solid)
     self.assertEqual(type(r.first().val()),Solid)
开发者ID:moeb,项目名称:cadquery,代码行数:8,代码来源:TestCadQuery.py


示例5: testSolidReferencesCombine

    def testSolidReferencesCombine(self):
        "test that solid references are updated correctly"
        c = CQ( makeUnitCube())                                   #the cube is the context solid
        self.assertEqual(6,c.faces().size())        #cube has six faces

        r = c.faces().workplane().circle(0.125).extrude(0.5,True)     #make a boss, not updating the original
        self.assertEqual(8,r.faces().size())                  #just the boss faces
        self.assertEqual(8,c.faces().size())                  #original is modified too
开发者ID:moeb,项目名称:cadquery,代码行数:8,代码来源:TestCadQuery.py


示例6: testFaceTypesFilter

 def testFaceTypesFilter(self):
     "Filters by face type"
     c = CQ(makeUnitCube())
     self.assertEqual(c.faces().size(), c.faces('%PLANE').size())
     self.assertEqual(c.faces().size(), c.faces('%plane').size())
     self.assertEqual(0, c.faces('%sphere').size())
     self.assertEqual(0, c.faces('%cone').size())
     self.assertEqual(0, c.faces('%SPHERE').size())
开发者ID:adam-urbanczyk,项目名称:cadquery,代码行数:8,代码来源:TestCQSelectors.py


示例7: testParallelPlaneFaceFilter

    def testParallelPlaneFaceFilter(self):
        c = CQ(makeUnitCube())

        #faces parallel to Z axis
        self.assertEqual(2, c.faces("|Z").size())
        #TODO: provide short names for ParallelDirSelector
        self.assertEqual(2, c.faces(selectors.ParallelDirSelector(Vector((0,0,1)))).size()) #same thing as above
        self.assertEqual(2, c.faces(selectors.ParallelDirSelector(Vector((0,0,-1)))).size()) #same thing as above

        #just for fun, vertices on faces parallel to z
        self.assertEqual(8, c.faces("|Z").vertices().size())
开发者ID:adam-urbanczyk,项目名称:cadquery,代码行数:11,代码来源:TestCQSelectors.py


示例8: testFaceDirFilter

 def testFaceDirFilter(self):
     c = CQ(makeUnitCube())
     #a cube has one face in each direction
     self.assertEqual(1, c.faces("+Z").size())
     self.assertEqual(1, c.faces("-Z").size())
     self.assertEqual(1, c.faces("+X").size())
     self.assertEqual(1, c.faces("X").size())     #should be same as +X
     self.assertEqual(1, c.faces("-X").size())
     self.assertEqual(1, c.faces("+Y").size())
     self.assertEqual(1, c.faces("-Y").size())
     self.assertEqual(0, c.faces("XY").size())
开发者ID:adam-urbanczyk,项目名称:cadquery,代码行数:11,代码来源:TestCQSelectors.py


示例9: testMinDistance

    def testMinDistance(self):
        c = CQ(makeUnitCube())

        #should select the topmost face
        self.assertEqual(1, c.faces("<Z").size())
        self.assertEqual(4, c.faces("<Z").vertices().size())

        #vertices should all be at z=1, if this is the top face
        self.assertEqual(4, len(c.faces("<Z").vertices().vals() ))
        for v in c.faces("<Z").vertices().vals():
            self.assertAlmostEqual(0.0,v.Z,3)
开发者ID:AlexLee,项目名称:cadquery,代码行数:11,代码来源:TestCQSelectors.py


示例10: testSubtractSelector

    def testSubtractSelector(self):
        c = CQ(makeUnitCube())

        S = selectors.StringSyntaxSelector

        fl = c.faces(selectors.SubtractSelector(S("#Z"), S(">X"))).vals()
        self.assertEqual(3, len(fl))

        # test the subtract operator
        fl = c.faces(S("#Z") - S(">X")).vals()
        self.assertEqual(3, len(fl))
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:11,代码来源:TestCQSelectors.py


示例11: testAndSelector

    def testAndSelector(self):
        c = CQ(makeUnitCube())

        S = selectors.StringSyntaxSelector
        BS = selectors.BoxSelector

        el = c.edges(selectors.AndSelector(S('|X'), BS((-2,-2,0.1), (2,2,2)))).vals()
        self.assertEqual(2, len(el))

        # test 'and' (intersection) operator
        el = c.edges(S('|X') & BS((-2,-2,0.1), (2,2,2))).vals()
        self.assertEqual(2, len(el))
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:12,代码来源:TestCQSelectors.py


示例12: testSplitKeepingHalf

    def testSplitKeepingHalf(self):
        "Tests splitting a solid"

        #drill a hole in the side
        c = CQ(makeUnitCube()).faces(">Z").workplane().circle(0.25).cutThruAll()

        self.assertEqual(7,c.faces().size() )

        #now cut it in half sideways
        c.faces(">Y").workplane(-0.5).split(keepTop=True)
        self.saveModel(c)
        self.assertEqual(8,c.faces().size())
开发者ID:Geraldes,项目名称:cadquery,代码行数:12,代码来源:TestCadQuery.py


示例13: testPointList

    def testPointList(self):
        "Tests adding points and using them"
        c = CQ(makeUnitCube())

        s = c.faces(">Z").workplane().pushPoints([(-0.3,0.3),(0.3,0.3),(0,0)])
        self.assertEqual(3,s.size())
        #TODO: is the ability to iterate over points with circle really worth it?
        #maybe we should just require using all() and a loop for this. the semantics and
        #possible combinations got too hard ( ie, .circle().circle() ) was really odd
        body = s.circle(0.05).cutThruAll()
        self.saveModel(body)
        self.assertEqual(9,body.faces().size())
开发者ID:moeb,项目名称:cadquery,代码行数:12,代码来源:TestCadQuery.py


示例14: testVertexFilter

    def testVertexFilter(self):
        "test selecting vertices on a face"
        c = CQ(makeUnitCube())

        #TODO: filters work ok, but they are in global coordinates which sux. it would be nice
        #if they were available in coordinates local to the selected face

        v2 = c.faces("+Z").vertices("<XY")
        self.assertEqual(1,v2.size() ) #another way
        #make sure the vertex is the right one

        self.assertTupleAlmostEquals((0.0,0.0,1.0),v2.val().toTuple() ,3)
开发者ID:adam-urbanczyk,项目名称:cadquery,代码行数:12,代码来源:TestCQSelectors.py


示例15: testChamferAsymmetrical

    def testChamferAsymmetrical(self):
        """
        Test chamfer API with a box shape for asymmetrical lengths
        """
        cube = CQ(makeUnitCube()).faces(">Z").chamfer(0.1, 0.2)
        self.saveModel(cube)
        self.assertEqual(10, cube.faces().size())

        # test if edge lengths are different
        edge = cube.edges(">Z").vals()[0]
        self.assertAlmostEqual(0.6, edge.Length(), 3)
        edge = cube.edges("|Z").vals()[0]
        self.assertAlmostEqual(0.9, edge.Length(), 3)
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:13,代码来源:TestCadQuery.py


示例16: testSplitKeepingBottom

    def testSplitKeepingBottom(self):
        """
        Tests splitting a solid improperly
        """
        # Drill a hole in the side
        c = CQ(makeUnitCube()).faces(">Z").workplane().circle(0.25).cutThruAll()
        self.assertEqual(7, c.faces().size())

        # Now cut it in half sideways
        result = c.faces(">Y").workplane(-0.5).split(keepTop=False, keepBottom=True)

        #stack will have both halves, original will be unchanged
        self.assertEqual(1, result.solids().size())  # one solid is on the stack
        self.assertEqual(8, result.solids().item(0).faces().size())
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:14,代码来源:TestCadQuery.py


示例17: testSplitKeepingBoth

    def testSplitKeepingBoth(self):
        "Tests splitting a solid"

        #drill a hole in the side
        c = CQ(makeUnitCube()).faces(">Z").workplane().circle(0.25).cutThruAll()
        self.assertEqual(7,c.faces().size() )

        #now cut it in half sideways
        result = c.faces(">Y").workplane(-0.5).split(keepTop=True,keepBottom=True)

        #stack will have both halves, original will be unchanged
        self.assertEqual(2, result.solids().size())  #two solids are on the stack, eac
        self.assertEqual(8,result.solids().item(0).faces().size())
        self.assertEqual(8,result.solids().item(1).faces().size())
开发者ID:Geraldes,项目名称:cadquery,代码行数:14,代码来源:TestCadQuery.py


示例18: testSolid

    def testSolid(self):
        c = CQ(makeUnitCube())
        #make sure all the counts are right for a cube
        self.assertEqual(1,c.solids().size() )
        self.assertEqual(6,c.faces().size() )
        self.assertEqual(12,c.edges().size())
        self.assertEqual(8,c.vertices().size() )
        self.assertEqual(0,c.compounds().size())

        #now any particular face should result in 4 edges and four vertices
        self.assertEqual(4,c.faces().first().edges().size() )
        self.assertEqual(1,c.faces().first().size() )
        self.assertEqual(4,c.faces().first().vertices().size() )

        self.assertEqual(4,c.faces().last().edges().size() )
开发者ID:adam-urbanczyk,项目名称:cadquery,代码行数:15,代码来源:TestCQSelectors.py


示例19: testSumSelector

    def testSumSelector(self):
        c = CQ(makeUnitCube())

        S = selectors.StringSyntaxSelector

        fl = c.faces(selectors.SumSelector(S(">Z"), S("<Z"))).vals()
        self.assertEqual(2, len(fl))
        el = c.edges(selectors.SumSelector(S("|X"), S("|Y"))).vals()
        self.assertEqual(8, len(el))

        # test the sum operator
        fl = c.faces(S(">Z") + S("<Z")).vals()
        self.assertEqual(2, len(fl))
        el = c.edges(S("|X") + S("|Y")).vals()
        self.assertEqual(8, len(el))
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:15,代码来源:TestCQSelectors.py


示例20: testInverseSelector

    def testInverseSelector(self):
        c = CQ(makeUnitCube())

        S = selectors.StringSyntaxSelector

        fl = c.faces(selectors.InverseSelector(S('>Z'))).vals()
        self.assertEqual(5, len(fl))
        el = c.faces('>Z').edges(selectors.InverseSelector(S('>X'))).vals()
        self.assertEqual(3, len(el))

        # test invert operator
        fl = c.faces(-S('>Z')).vals()
        self.assertEqual(5, len(fl))
        el = c.faces('>Z').edges(-S('>X')).vals()
        self.assertEqual(3, len(el))
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:15,代码来源:TestCQSelectors.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.mkdtemp函数代码示例发布时间:2022-05-27
下一篇:
Python tests.main函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap