Exemple #1
0
 def groupParts(self):
     for j in FreeCAD.activeDocument().Objects:
         if hasattr(j, "Proxy") and hasattr(j.Proxy, "Type") and j.Proxy.Type in ["PCBpart", "PCBpart_E"]:
             aa = partsManaging()
             aa.setDatabase()
             fileData = aa.__SQL__.findPackage(j.Package, '*')
             
             if fileData[0] == True:
                 aa.addPartToGroup(True, [None, None, None, None, fileData[3]], j)
             else:
                 aa.addPartToGroup(True, [False], j)
def exportObjectToPOVRAY(fileName, objectName, projectObjects):
    if len(projectObjects) == 0:
        FreeCAD.Console.PrintWarning("No objects found!\n")

    outPutString = meshObjects(projectObjects)
    if outPutString == "":
        return

    if not fileName.lower().endswith('inc'):
        fileName = fileName + '.inc'
    #
    try:
        partsManagingC = partsManaging()
        partsManagingC.setDatabase()
        packageData = partsManagingC.__SQL__.findPackage(objectName, "*")

        if packageData[0]:
            newX = packageData[2][2]
            newY = packageData[2][3]
            newZ = packageData[2][4]
            newRX = packageData[2][5] + 90
            newRY = packageData[2][6]
            newRZ = packageData[2][7]
        else:
            newX = 0
            newY = 0
            newZ = 0
            newRX = 0
            newRY = 0
            newRZ = 0
        #
        objectNameFormat = objectName.replace('-', '')
        #
        plik = __builtin__.open(fileName, "w")
        plik.write(
            '''// ////////////////////////////////////////////////////////////
// 
// Add to file e3d_tools.inc
// #include "{0}"
// 
// ////////////////////////////////////////////////////////////

// ////////////////////////////////////////////////////////////
// 
// Add to file 3dusrpac.dat
// {1}:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:FC_obj_{2}(::
//
// ////////////////////////////////////////////////////////////

'''.format(fileName, objectName, objectNameFormat))

        plik.write('''
#macro FC_obj_%s(value)
union {
''' % objectNameFormat)

        plik.write(outPutString + "\n")
        plik.write('''}''')
        plik.write('''
    rotate<{0},{1},{2}>
    translate<{3},{5},{4}>
#end'''.format(newRX, newRY, newRZ, newX, newY, newZ))

        plik.close()
    except Exception, e:
        FreeCAD.Console.PrintWarning("{0} \n".format(e))
        return
Exemple #3
0
 def ungroupParts(self):
     for j in FreeCAD.activeDocument().Objects:
         if hasattr(j, "Proxy") and hasattr(j.Proxy, "Type") and j.Proxy.Type in ["PCBpart", "PCBpart_E"]:
             aa = partsManaging()
             aa.addPartToGroup(False, [], j)
def exportObjectToPOVRAY(fileName, objectName, projectObjects):
    if len(projectObjects) == 0:
        FreeCAD.Console.PrintWarning("No objects found!\n")

    outPutString = meshObjects(projectObjects)
    if outPutString == "":
        return
    
    if not fileName.lower().endswith('inc'):
        fileName = fileName + '.inc'
    #
    try:
        partsManagingC = partsManaging()
        partsManagingC.setDatabase()
        packageData = partsManagingC.__SQL__.findPackage(objectName, "*")

        if packageData[0]:
            newX = packageData[2][2]
            newY = packageData[2][3]
            newZ = packageData[2][4]
            newRX = packageData[2][5] + 90
            newRY = packageData[2][6]
            newRZ = packageData[2][7]
        else:
            newX = 0
            newY = 0
            newZ = 0
            newRX = 0
            newRY = 0
            newRZ = 0
        #
        objectNameFormat = objectName.replace('-', '')
        #
        plik = __builtin__.open(fileName, "w")
        plik.write('''// ////////////////////////////////////////////////////////////
// 
// Add to file e3d_tools.inc
// #include "{0}"
// 
// ////////////////////////////////////////////////////////////

// ////////////////////////////////////////////////////////////
// 
// Add to file 3dusrpac.dat
// {1}:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:FC_obj_{2}(::
//
// ////////////////////////////////////////////////////////////

'''.format(fileName, objectName, objectNameFormat))

        plik.write('''
#macro FC_obj_%s(value)
union {
''' % objectNameFormat)

        plik.write(outPutString + "\n")
        plik.write('''}''')
        plik.write('''
    rotate<{0},{1},{2}>
    translate<{3},{5},{4}>
#end'''.format(newRX, newRY, newRZ, newX, newY, newZ))

        plik.close()
    except Exception, e:
        FreeCAD.Console.PrintWarning("{0} \n".format(e))
        return