示例#1
0
from cadquery import *
import unittest
import sys
import os

from cadquery.freecad_impl.verutil import fc_import

FreeCAD = fc_import("FreeCAD")

P = fc_import("FreeCAD.Part")
V = fc_import("FreeCAD").Base.Vector


def readFileAsString(fileName):
    f = open(fileName, "r")
    s = f.read()
    f.close()
    return s


def writeStringToFile(strToWrite, fileName):
    f = open(fileName, "w")
    f.write(strToWrite)
    f.close()


def makeUnitSquareWire():
    return Solid.cast(P.makePolygon([V(0, 0, 0), V(1, 0, 0), V(1, 1, 0), V(0, 1, 0), V(0, 0, 0)]))


def makeUnitCube():
示例#2
0
#system modules
import sys

import unittest
from tests import BaseTest

from cadquery.freecad_impl.verutil import fc_import
FreeCAD = fc_import("FreeCAD")
if not hasattr(FreeCAD, 'Part'):
    FreeCAD.Part = fc_import("FreeCAD.Part")

from cadquery import *


class TestCadObjects(BaseTest):
    def testVectorConstructors(self):
        v1 = Vector(1, 2, 3)
        v2 = Vector((1, 2, 3))
        v3 = Vector(FreeCAD.Base.Vector(1, 2, 3))

        for v in [v1, v2, v3]:
            self.assertTupleAlmostEquals((1, 2, 3), v.toTuple(), 4)

    def testVertex(self):
        """
            Tests basic vertex functions
        """
        v = Vertex(FreeCAD.Part.Vertex(1, 1, 1))
        self.assertEqual(1, v.X)
        self.assertEquals(Vector, type(v.Center()))
示例#3
0
#system modules
import sys

import unittest
from tests import BaseTest

from cadquery.freecad_impl.verutil import fc_import
FreeCAD = fc_import("FreeCAD")
if not hasattr(FreeCAD, 'Part'):
    FreeCAD.Part = fc_import("FreeCAD.Part")


from cadquery import *

class TestCadObjects(BaseTest):

    def testVectorConstructors(self):
        v1 = Vector(1,2,3)
        v2 = Vector((1,2,3))
        v3 = Vector(FreeCAD.Base.Vector(1,2,3))

        for v in [v1,v2,v3]:
            self.assertTupleAlmostEquals((1,2,3),v.toTuple(),4)

    def testVertex(self):
        """
            Tests basic vertex functions
        """
        v = Vertex( FreeCAD.Part.Vertex(1,1,1) )
        self.assertEqual(1,v.X)
        self.assertEquals(Vector,type(v.Center() ))
示例#4
0
from cadquery import *
import unittest
import sys
import os

from cadquery.freecad_impl.verutil import fc_import
FreeCAD = fc_import("FreeCAD")

P = fc_import("FreeCAD.Part")
V = fc_import("FreeCAD").Base.Vector


def readFileAsString(fileName):
    f = open(fileName, 'r')
    s = f.read()
    f.close()
    return s


def writeStringToFile(strToWrite, fileName):
    f = open(fileName, 'w')
    f.write(strToWrite)
    f.close()


def makeUnitSquareWire():
    return Solid.cast(
        P.makePolygon(
            [V(0, 0, 0),
             V(1, 0, 0),
             V(1, 1, 0),