コード例 #1
0
def Min3DBoundingBox(objs, init_plane, count, rel_stop, im_rep):
    #for non-planar or non-coplanar object(s)
    #get initial fast bb in init plane (World XY), plus volume to compare
    curr_bb = BoundingBoxPlane(objs, init_plane, False)
    curr_vol = curr_bb.Volume

    tot_ang = math.pi * 0.5  #90 degrees for intial octant
    factor = 0.1  #angle reduction factor for each successive refinement pass
    max_passes = 20  #safety factor
    prec = sc.doc.ModelDistanceDisplayPrecision
    us = rs.UnitSystemName(abbreviate=True)

    #run intitial bb calculation
    xyz_planes = GenerateOctantPlanes(count)
    best_plane, curr_bb, curr_vol = MinBBPlane(objs, init_plane, xyz_planes,
                                               curr_bb, curr_vol)
    #report results of intial rough calculation
    if im_rep:
        print "Initial pass 0, volume: {} {}3".format(round(curr_vol, prec),
                                                      us)
    #refine with smaller angles around best fit plane, loop until...
    for i in range(max_passes):
        prev_vol = curr_vol
        #reduce angle by factor, use refinement planes to generate array
        tot_ang *= factor
        ref_planes = RotatePlaneArray3D(best_plane, tot_ang, count)
        best_plane, curr_bb, curr_vol = MinBBPlane(objs, best_plane,
                                                   ref_planes, curr_bb,
                                                   curr_vol)
        vol_diff = prev_vol - curr_vol  #vol. diff. over last pass, should be positive or 0
        #print "Volume difference from last pass: {}".format(vol_diff) #debug
        #check if difference is less than minimum "significant"
        #rel_stop==True: relative stop value <.01% difference from previous
        if rel_stop:
            if vol_diff < 0.0001 * prev_vol: break
        else:
            if vol_diff < sc.doc.ModelAbsoluteTolerance: break
        Rhino.RhinoApp.Wait()
        if im_rep:
            print "Refine pass {}, volume: {} {}3".format(
                i + 1, round(curr_vol, prec), us)
        #get out of loop if escape is pressed
        if sc.escape_test(False):
            print "Refinement aborted after {} passes.".format(i + 1)
            break

    return curr_bb, curr_vol, i + 1
コード例 #2
0
ファイル: drawing.py プロジェクト: tmwarchitecture/PCPA_TOOLS
def UpdateAreaTag():
    objs = rs.GetObjects('Select area tags to update', preselect = True)
    if objs is None: return

    successfulObjsRun = 0
    failedObjsRun = 0
    for obj in objs:
        try:
            host = rs.GetUserText(obj, 'hostGUID')
            if host is None:
                print "Could not find associated geometry"
                return None

            #Get number of dec places
            text = rs.TextObjectText(obj)
            splitText = text.Split(" ")

            numberString = splitText[0]
            units = splitText[-1]

            try:
                decPlaces = len(numberString.Split(".")[1])
            except:
                decPlaces = 0

            #Get area
            if rs.UnitSystem() == 8:
                area = rs.Area(rs.coerceguid(host))*0.0069444444444444
                areaText = utils.RoundNumber(area, decPlaces) + " " + units
            else:
                print "WARNING: Your units are not in inches"
                area = rs.Area(rs.coerceguid(host))
                areaText = area + ' ' + rs.UnitSystemName(False, True, True)

            rs.TextObjectText(obj, areaText)

            successfulObjsRun += 1
        except:
            failedObjsRun += 1
            print "Tag failed"

    utils.SaveFunctionData('Drawing-Update Area Tag', [__version__, successfulObjsRun, failedObjsRun])

    return successfulObjsRun
コード例 #3
0
def CombinedMinBBMulti():
    #user input
    #get prev settings
    if "MinBBSample" in sc.sticky: u_samp = sc.sticky["MinBBSample"]
    else: u_samp = False  #standard sampling
    if "MinBBStop" in sc.sticky: u_stop = sc.sticky["MinBBStop"]
    else: u_stop = True  #relative volume stop value
    if "MinBBReports" in sc.sticky: u_rep = sc.sticky["MinBBReports"]
    else: u_rep = True  #intermediate reports shown

    prec = sc.doc.ModelDistanceDisplayPrecision
    us = rs.UnitSystemName(abbreviate=True)

    prompt = "Select objects for minimum bounding box"
    gf = OT.Point | OT.PointSet | OT.Curve | OT.Surface | OT.Extrusion | OT.Brep | OT.Mesh
    bool_prompts = ["Sampling", "StopVal", "ReportIntermedResults"]
    bool_ini = [[u_samp, "Standard", "Fine"], [u_stop, "Absolute", "Relative"],
                [u_rep, "No", "Yes"]]
    result = GetObjectsPlus3Boolean(prompt, bool_prompts, bool_ini, gf)
    if result is None: return
    objIDs, fine_sample, rel_stop, im_rep = result

    #objIDs=rs.GetObjects(preselect=True)
    #if not objIDs: return

    #EDIT by willemderks to find bbox for each object individually
    #EDIT by HarriHumppi to copy object name for each bbox
    for objID in objIDs:

        objs = [rs.coercegeometry(objID)]
        name = rs.ObjectName(objID)  # pick name HH
        print "Checking object planarity/coplanarity..."
        st = time.time()
        plane = CheckObjCoPlanarity(objs, tol=sc.doc.ModelAbsoluteTolerance)

        if plane:
            if len(objs) == 1: msg = "Selected object is planar - "
            else: msg = "All selected objects are coplanar - "
            msg += "launching 2D planar bounding rectangle calculation."
            print msg
            #launch planar bounding box routine
            f_bb, curr_area, passes = MinBoundingRectanglePlane(
                objs, plane, im_rep)
            #add polyline, report message
            bbID = rs.AddPolyline(
                [f_bb[0], f_bb[1], f_bb[2], f_bb[3], f_bb[0]])
            fa = round(curr_area, prec)
            msg = "{} refinement stages. ".format(passes)
            msg += "Minimum bounding box area = {} sq. {}".format(fa, us)
            msg += " Elapsed time: {:.2f} sec.".format(time.time() - st)

        else:
            #standard sample count=10 --> 1000 boxes per pass
            #fine sample count=18 --> 5832 boxes per pass
            if fine_sample: count = 18
            else: count = 10
            wxy_plane = Rhino.Geometry.Plane.WorldXY
            if len(objs) == 1: cp_msg = "Selected object is not planar - "
            else: cp_msg = "Selected objects are not coplanar - "
            cp_msg += "launching 3D bounding box calculation."
            print cp_msg
            rs.Prompt("Calculating... please wait.")
            #launch 3D bounding box routine
            curr_bb, curr_vol, passes = Min3DBoundingBox(
                objs, wxy_plane, count, rel_stop, im_rep)

            #add box, report message
            if Rhino.RhinoApp.ExeVersion < 6:
                output_bbox = sc.doc.Objects.AddBrep(curr_bb.ToBrep())  #legacy
            else:
                output_bbox = sc.doc.Objects.AddBox(curr_bb)
                print name  #print name HH
                rs.ObjectName(output_bbox, name)  #give name HH
            fv = round(curr_vol, prec)
            msg = "Final volume after {} passes is {} {}3".format(
                passes, fv, us)
            msg += " | Elapsed time: {:.2f} sec.".format(time.time() - st)

        #final result reporting
        print msg
        sc.doc.Views.Redraw()
    #save user settings
    sc.sticky["MinBBSample"] = fine_sample
    sc.sticky["MinBBReports"] = im_rep
    sc.sticky["MinBBStop"] = rel_stop
コード例 #4
0
def MultiUnroll():

    msg = "Select surface/polysurface objects to unroll"
    brepIDs = rs.GetObjects(msg, 8 + 16, preselect=True)
    if not brepIDs: return

    msg = "Select curves and/or points to unroll with surfaces, or Enter to continue"
    otherIDs = rs.GetObjects(msg, 1 + 4 + 8192)

    if "MultiUR_Numbering" in sc.sticky:
        user_num = sc.sticky["MultiUR_Numbering"]
    else:
        user_num = True

    if "MultiUR_Explode" in sc.sticky: user_exp = sc.sticky["MultiUR_Explode"]
    else: user_exp = False

    if "MultiUR_Properties" in sc.sticky:
        user_prop = sc.sticky["MultiUR_Properties"]
    else:
        user_prop = False

    if "MultiUR_Spacing" in sc.sticky:
        user_space = sc.sticky["MultiUR_Spacing"]
    else:
        user_space = 1.0

    if "MultiUR_XLimit" in sc.sticky: user_xl = sc.sticky["MultiUR_XLimit"]
    else: user_xl = 0

    prompt = "Start point for unrolls - press Enter for world 0"
    msg = [
        "NumberObjects", "Explode", "KeepProperties", "LayoutSpacing",
        "XExtents"
    ]
    ini = [user_num, user_exp, user_prop, user_space, user_xl]
    limits = [["No", "Yes"], ["No", "Yes"], ["No", "Yes"], [True, 0],
              [True, 0]]
    result = CommandLineOptions(prompt, msg, ini, limits)
    if not result: return
    x_extents = result[4]
    new_sp = result[5]

    #initialize
    max_y = new_sp.Y
    x_origin = new_sp.X
    exceed_warning = False
    ur_number = 0
    no_unroll = 0
    crvs = []
    pts = []
    dots = []
    tol = sc.doc.ModelAbsoluteTolerance
    #get underlying geometry objects
    objs = [sc.doc.Objects.Find(objID).Geometry for objID in brepIDs]
    if otherIDs:
        for objID in otherIDs:
            if rs.IsCurve(objID):
                crvs.append(sc.doc.Objects.Find(objID).Geometry)
            elif rs.IsPoint(objID):
                pts.append(sc.doc.Objects.Find(objID).Geometry)
            else:
                dots.append(sc.doc.Objects.Find(objID).Geometry)

    #run the unroller
    rs.EnableRedraw(False)
    for i, obj in enumerate(objs):
        if isinstance(obj, Rhino.Geometry.Extrusion): obj = obj.ToBrep()
        ur = Rhino.Geometry.Unroller(obj)
        if result[1]: ur.ExplodeOutput = True
        if len(crvs) > 0:
            for crv in crvs:
                ur.AddFollowingGeometry(crv)
        if len(pts) > 0:
            for pt in pts:
                ur.AddFollowingGeometry(pt)
        if len(dots) > 0:
            for dot in dots:
                ur.AddFollowingGeometry(dot)
        unroll = ur.PerformUnroll()
        if unroll[0]:
            #something was unrolled
            ur_number += 1
            if result[1]: ur_objs = unroll[0]
            else: ur_objs = Rhino.Geometry.Brep.JoinBreps(unroll[0], tol)
            ur_IDs = [sc.doc.Objects.AddBrep(ur_obj) for ur_obj in ur_objs]
            bb = rs.BoundingBox(ur_IDs)
            if x_extents > 0:
                if bb[3].Y - bb[0].Y > max_y: max_y = bb[3].Y - bb[0].Y
                if bb[1].X - bb[0].X > x_extents:
                    x_extents = bb[1].X - bb[0].X
                    exceed_warning = True
                if new_sp.X + bb[1].X > (x_origin + x_extents):
                    #need to reset start point to x_origin, y_max
                    new_sp.X = x_origin
                    new_sp.Y += max_y + result[3]
            move_vec = new_sp - bb[0]

            if unroll[1]:
                ur_crv_IDs = [
                    sc.doc.Objects.AddCurve(ur_obj) for ur_obj in unroll[1]
                ]
                ur_IDs.extend(ur_crv_IDs)
            if unroll[2]:
                ur_pt_IDs = [
                    sc.doc.Objects.AddPoint(ur_obj) for ur_obj in unroll[2]
                ]
                ur_IDs.extend(ur_pt_IDs)
            if unroll[3]:
                ur_dot_IDs = [
                    sc.doc.Objects.AddTextDot(ur_obj) for ur_obj in unroll[3]
                ]
                ur_IDs.extend(ur_dot_IDs)
            if result[2]:
                #keep properties (MatchAttributes() causes problems with grouping)
                TransferColorLayer(ur_IDs, brepIDs[i])
            if result[0]:
                #number objects and group
                AddDotToObjCtr(ur_IDs, str(ur_number), result[2])
                #add number dot to original object
                AddDotToObjCtr([brepIDs[i]], ur_number, result[2])
            #move all objs into position
            rs.MoveObjects(ur_IDs, move_vec)
            new_sp = (bb[1] +
                      (move_vec + Rhino.Geometry.Vector3d(result[3], 0, 0)))
        else:
            no_unroll += 1

    #Clean up, store settings, report
    sc.sticky["MultiUR_Numbering"] = result[0]
    sc.sticky["MultiUR_Explode"] = result[1]
    sc.sticky["MultiUR_Properties"] = result[2]
    sc.sticky["MultiUR_Spacing"] = result[3]
    sc.sticky["MultiUR_XLimit"] = x_extents

    if exceed_warning:
        us = rs.UnitSystemName(abbreviate=True)
        msg = "At least one of the unrolled objects exceeded the X extents limit!\n"
        msg += "Limit has been extended to {:.2f} {} ".format(x_extents, us)
        msg += "to allow all objects to unroll."
        rs.MessageBox(msg, 48)
    msg = "Sucessfully unrolled {} objects".format(len(brepIDs) - no_unroll)
    if no_unroll > 0:
        msg += " | Unable to unroll {} objects".format(no_unroll)
    print msg
コード例 #5
0
def main(modulesLibraryFile_filePath, moduleIndex, newModuleMountType,
         moduleHeightAboveGroundRhinoUnits, moduleActiveAreaPercent):

    # find unitConversionFactor
    unitConversionFactor = lb_preparation.checkUnits()
    sc.doc = Rhino.RhinoDoc.ActiveDoc
    unitSystem = rs.UnitSystemName()
    sc.doc = ghdoc

    if (modulesLibraryFile_filePath == None):
        moduleNameL = moduleName = moduleMaterial = moduleMountType = moduleArea = nameplateDCpowerRating_m = moduleEfficiency = sourceNotes = PVmoduleSettings = None
        validInputData = False
        printMsg = "Add \"California Energy Commission (CEC) Modules\" .csv file path to \"_modulesLibraryFile\" input.\n" + \
                   "Download its newest version from the bottom of the following page:\n\n" + \
                   "https://sam.nrel.gov/libraries"
        return moduleNameL, moduleName, moduleMaterial, moduleMountType, moduleArea, nameplateDCpowerRating_m, moduleEfficiency, sourceNotes, PVmoduleSettings, validInputData, printMsg
    # testing if the "modulesLibraryFile_filePath" is valid:
    try:
        with open(modulesLibraryFile_filePath) as modulesCSVFile:
            pass
    except:
        moduleNameL = moduleName = moduleMaterial = moduleMountType = moduleArea = nameplateDCpowerRating_m = moduleEfficiency = sourceNotes = PVmoduleSettings = None
        validInputData = False
        printMsg = "The .csv file path you added to the \"_modulesLibraryFile\" input is invalid.\n" + \
                   "Download the newest version of \"California Energy Commission (CEC) Modules\" .csv file from the bottom of the following page:\n" + \
                   "https://sam.nrel.gov/libraries\n" + \
                   "And add its file path to the \"_modulesLibraryFile\" input."
        return moduleNameL, moduleName, moduleMaterial, moduleMountType, moduleArea, nameplateDCpowerRating_m, moduleEfficiency, sourceNotes, PVmoduleSettings, validInputData, printMsg

    if (newModuleMountType == None):
        pass
    elif (newModuleMountType < 0) or (newModuleMountType > 2):
        print "newModuleMountType: ", newModuleMountType
        moduleNameL = moduleName = moduleMaterial = moduleMountType = moduleArea = nameplateDCpowerRating_m = moduleEfficiency = sourceNotes = PVmoduleSettings = None
        validInputData = False
        printMsg = "\"newModuleMountType_\" input supports only the following values:\n" + \
                   "0 = Insulated back\n" + \
                   "1 = Close (flush) roof mount\n" + \
                   "2 = Open rack\n" + \
                   "Choose one of these three."
        return moduleNameL, moduleName, moduleMaterial, moduleMountType, moduleArea, nameplateDCpowerRating_m, moduleEfficiency, sourceNotes, PVmoduleSettings, validInputData, printMsg

    if (moduleHeightAboveGroundRhinoUnits
            == None) or (moduleHeightAboveGroundRhinoUnits < 0):
        moduleHeightAboveGroundM = 6  # default value: 6 meters, in meters
    else:
        moduleHeightAboveGroundM = moduleHeightAboveGroundRhinoUnits / unitConversionFactor  # in meters

    if (moduleActiveAreaPercent == None) or (moduleActiveAreaPercent <= 0) or (
            moduleActiveAreaPercent > 100):
        moduleActiveAreaPercent = 90  # default in %

    # define "ws_adjusted_factor" based on the height of module above the ground
    if (moduleHeightAboveGroundM <= 3):
        ws_adjusted_factor = 0.51  # unitless
    elif (moduleHeightAboveGroundM > 3):
        ws_adjusted_factor = 0.61  # unitless

    with open(modulesLibraryFile_filePath) as modulesCSVFile:
        moduleNameL = []
        materialL = []
        dateL = []
        versionL = []
        moduleAreaML = []
        Vmp_refL = []
        Imp_refL = []
        Voc_refL = []
        Isc_refL = []
        alpha_sc_refL = []
        beta_oc_refL = []
        IL_refL = []
        Io_refL = []
        Rs_refL = []
        Rsh_refL = []
        A_refL = []
        n_sL = []
        adjustL = []
        gamma_r_refL = []
        TnoctL = []
        mountType_libraryL = []
        nameplateDCpowerRating_mL = []
        moduleEfficiencyL = []

        lines = modulesCSVFile.readlines()
        for lineIndex, line in enumerate(lines):
            itemsPerLine = line.strip().split(",")
            if (lineIndex >= 3) and (
                (len(itemsPerLine[10]) > 0) and (len(itemsPerLine[19]) > 0)
            ):  # "Yingli Energy (China) YL310P-35b" with lineIndex = 13817 is invalid (does not contain all "PVmoduleSettings" items)
                # lineIndex = 0,1,2 are column names, units, script variables names
                moduleName = itemsPerLine[0]  # "Name" from .csv file
                material = itemsPerLine[21]  # "Technology" from .csv file
                date = itemsPerLine[2]  # "Date" from .csv file
                version = itemsPerLine[19]  # "Version" from .csv file
                moduleAreaM = float(
                    itemsPerLine[4]
                )  # "Area"("cec_area") from .csv file. The total area of the module, including spaces between cells and the frame!!
                BIPVorNot = itemsPerLine[23].strip()  # "BIPV" from .csv file
                #if material in ["c-Si", "mono-Si", "mc-Si", "multi-Si", "EFG mc-Si",   "Si-Film", "HIT Si"]:  # only use mono and multi crystalline photovoltaics
                #if True:
                if not "Concentrator" in moduleName:
                    Vmp_ref = float(
                        itemsPerLine[9])  # "cec_v_mp_ref" from .csv
                    Imp_ref = float(
                        itemsPerLine[8])  # "cec_i_mp_ref" from .csv
                    # if data is missing then use 0 as the value
                    if len(itemsPerLine[7]) != 0:
                        Voc_ref = float(
                            itemsPerLine[7])  # "cec_v_oc_ref" from .csv
                    elif len(itemsPerLine[7]) == 0:
                        Voc_ref = 0
                    # if data is missing then use 0 as the value
                    if len(itemsPerLine[6]) != 0:
                        Isc_ref = float(
                            itemsPerLine[6])  # "cec_i_sc_ref" from .csv
                    elif len(itemsPerLine[6]) == 0:
                        Isc_ref = 0
                    alpha_sc_ref = float(
                        itemsPerLine[10])  # "cec_alpha_sc" from .csv
                    beta_oc_ref = float(
                        itemsPerLine[11])  # "cec_beta_oc" from .csv
                    IL_ref = float(itemsPerLine[13])  # "cec_i_l_ref" from .csv
                    Io_ref = float(itemsPerLine[14])  # "cec_i_o_ref" from .csv
                    Rs_ref = float(itemsPerLine[15])  # "cec_r_s" from .csv
                    Rsh_ref = float(
                        itemsPerLine[16])  # "cec_r_sh_ref" from .csv
                    A_ref = float(itemsPerLine[12])  # "cec_a_ref" from .csv
                    n_s = float(itemsPerLine[5])  # "cec_n_s" from .csv
                    adjust = float(itemsPerLine[17])  # "cec_adjust" from .csv
                    gamma_r_ref = float(
                        itemsPerLine[18])  # "cec_gamma_r" from .csv
                    Tnoct = float(itemsPerLine[3])  # "cec_t_noct" from .csv

                    if (BIPVorNot == "Y"):
                        mountType_library = 0  # (insulated back)
                    elif (BIPVorNot == "N"):
                        mountType_library = 2  #(open rack)

                    nameplateDCpowerRating_m = round(
                        Imp_ref * Vmp_ref, 2
                    )  # Power at maximum-power point of a single module, in W
                    moduleEfficiency = round(
                        (Imp_ref * Vmp_ref) /
                        (1000 * moduleAreaM *
                         (moduleActiveAreaPercent / 100)) * 100,
                        2)  # in percent

                    # add to lists
                    moduleNameL.append(moduleName)
                    materialL.append(material)
                    dateL.append(date)
                    versionL.append(version)
                    moduleAreaML.append(moduleAreaM)
                    Vmp_refL.append(Vmp_ref)
                    Imp_refL.append(Imp_ref)
                    Voc_refL.append(Voc_ref)
                    Isc_refL.append(Isc_ref)
                    alpha_sc_refL.append(alpha_sc_ref)
                    beta_oc_refL.append(beta_oc_ref)
                    IL_refL.append(IL_ref)
                    Io_refL.append(Io_ref)
                    Rs_refL.append(Rs_ref)
                    Rsh_refL.append(Rsh_ref)
                    A_refL.append(A_ref)
                    n_sL.append(n_s)
                    adjustL.append(adjust)
                    gamma_r_refL.append(gamma_r_ref)
                    TnoctL.append(Tnoct)
                    mountType_libraryL.append(mountType_library)
                    nameplateDCpowerRating_mL.append(
                        nameplateDCpowerRating_m)  # in Watts
                    moduleEfficiencyL.append(moduleEfficiency)  # in percent
    modulesCSVFile.close()

    if (moduleIndex > (len(moduleNameL) - 1)):
        moduleName = moduleMaterial = moduleMountType = moduleArea = nameplateDCpowerRating_m = moduleEfficiency = sourceNotes = PVmoduleSettings = None
        validInputData = False
        printMsg = "\"moduleIndex_\" input is higher than the number of modules from the \"_modulesLibraryFile\" file.\n" + \
                   "Use \"moduleIndex_\" input from 0 to %s." % (len(moduleNameL)-1)
        return moduleNameL, moduleName, moduleMaterial, moduleMountType, moduleArea, nameplateDCpowerRating_m, moduleEfficiency, sourceNotes, PVmoduleSettings, validInputData, printMsg

    # NOCT Cell Temperature Model
    # if NOTHING added to "newModuleMountType_" input: Tnoct_adj = Tnoct value from the .csv file
    # if something added to "newModuleMountType_" input: Tnoct_adj is corrected according to "newModuleMountType_" input
    if (newModuleMountType == None):
        # NOTHING inputted to "newModuleMountType_" input
        moduleMountType_final = mountType_library
        Tnoct_adj = TnoctL[moduleIndex]
    elif (newModuleMountType != None):
        # something added to "newModuleMountType_" input
        if (newModuleMountType == 0):
            moduleMountType_final = 0
            Tnoct_adj = TnoctL[
                moduleIndex] + 18  # Insulated back/BIPV without back airflow (for standoff distance: 0.5 in)
        elif (newModuleMountType == 1):
            moduleMountType_final = 1
            Tnoct_adj = TnoctL[
                moduleIndex] + 6  # Close (flush) mount (for standoff distance: 1.5 to 2.5 in)
        elif (newModuleMountType == 2):
            moduleMountType_final = 2
            Tnoct_adj = TnoctL[
                moduleIndex] + 0  # Open rack (for standoff distance: > 3.5 in)

    PVmoduleSettings = [
        moduleNameL[moduleIndex], materialL[moduleIndex],
        moduleMountType_final, moduleAreaML[moduleIndex],
        moduleActiveAreaPercent, nameplateDCpowerRating_mL[moduleIndex],
        moduleEfficiencyL[moduleIndex], Vmp_refL[moduleIndex],
        Imp_refL[moduleIndex], Voc_refL[moduleIndex], Isc_refL[moduleIndex],
        alpha_sc_refL[moduleIndex], beta_oc_refL[moduleIndex],
        IL_refL[moduleIndex], Io_refL[moduleIndex], Rs_refL[moduleIndex],
        Rsh_refL[moduleIndex], A_refL[moduleIndex], n_sL[moduleIndex],
        adjustL[moduleIndex], gamma_r_refL[moduleIndex], ws_adjusted_factor,
        Tnoct_adj
    ]

    sourceNotes = versionL[moduleIndex] + ", " + dateL[moduleIndex]

    #print "__len(moduleNameL): ", len(moduleNameL)
    # deleting
    del modulesLibraryFile_filePath
    del modulesCSVFile
    del lines
    "del versionL"
    "del moduleAreaML"
    "del materialL"
    del Vmp_refL
    del Imp_refL
    del Voc_refL
    del Isc_refL
    del alpha_sc_refL
    del beta_oc_refL
    del IL_refL
    del Io_refL
    del Rs_refL
    del Rsh_refL
    del A_refL
    del n_sL
    del adjustL
    del gamma_r_refL
    del ws_adjusted_factor
    "del nameplateDCpowerRating_mL"
    "del moduleEfficiencyL"

    # printing
    resultsCompletedMsg = "Import CEC photovoltaics module component results successfully completed!"
    printOutputMsg = \
    """
Input data:,

Module Name:  %s,
Module Material:  %s,
Module Area (m2):  %s,
Module Active Area Percent (perc.):  %s,
Module height above ground (%s):  %s

New Module Mount type:  %s,
Default Module Mount type:  %s,

Power at Max Power (W):  %s,
Module Efficiency (perc.):  %s,
Reference Max Power Voltage (V):  %s,
Reference Max Power Current (A):  %s,
Reference Open Circuit Voltage (V):  %s,
Reference Short Circuit Current (A):  %s,

Short circuit current temperature coefficient (A/C deg.):  %s,
Open circuit voltage temperature coefficient (V/C deg.):  %s,

Reference light current:  %s,
Reference diode saturation current:  %s,
Reference series resistance:  %s,
Reference shunt resistance:  %s,

Reference ideality factor:  %s,
Diode factor:  %s,

Temperature coefficient adjustment factor:  %s,
Temperature coefficient of Power (perc./C deg.):  %s,
Wind speed adjustment factor:  %s,
Normal operating cell temperature:  %s,
    """ % (PVmoduleSettings[0], PVmoduleSettings[1], PVmoduleSettings[3], PVmoduleSettings[4], unitSystem, moduleHeightAboveGroundM/unitConversionFactor,
    newModuleMountType, mountType_libraryL[moduleIndex],
    PVmoduleSettings[5], PVmoduleSettings[6], PVmoduleSettings[7], PVmoduleSettings[8], PVmoduleSettings[9], PVmoduleSettings[10],
    PVmoduleSettings[11], PVmoduleSettings[12],
    PVmoduleSettings[13], PVmoduleSettings[14], PVmoduleSettings[15], PVmoduleSettings[16],
    PVmoduleSettings[17], PVmoduleSettings[18],
    PVmoduleSettings[19], PVmoduleSettings[20], PVmoduleSettings[21], PVmoduleSettings[22])
    print resultsCompletedMsg
    print printOutputMsg

    validInputData = True
    printMsg = "ok"

    # testing (comment out line "300" first)
    """
    print "-------"
    print "testing"
    print " "
    print "Module Name: ", moduleNameL[moduleIndex], "_", PVmoduleSettings[0]
    print "Module Material: ", materialL[moduleIndex], "_", PVmoduleSettings[1]
    print "Default Module Mount type: ", mountType_libraryL[moduleIndex], "_"
    print "Module Area (m2): ", moduleAreaML[moduleIndex], "_", PVmoduleSettings[3]
    print "Module Active Area Percent (perc.): ", moduleActiveAreaPercent, "_", PVmoduleSettings[4]
    print " "
    print "Power at Max Power (W): ", nameplateDCpowerRating_mL[moduleIndex], "_", PVmoduleSettings[5]
    print "Module Efficiency (perc.): ", moduleEfficiencyL[moduleIndex], "_", PVmoduleSettings[6]
    print "Reference Max Power Voltage (V): ", Vmp_refL[moduleIndex], "_", PVmoduleSettings[7]
    print "Reference Max Power Current (A): ", Imp_refL[moduleIndex], "_", PVmoduleSettings[8]
    print "Reference Open Circuit Voltage (V): ", Voc_refL[moduleIndex], "_", PVmoduleSettings[9]
    print "Reference Short Circuit Current (A): ", Isc_refL[moduleIndex], "_", PVmoduleSettings[10]
    print " "
    print "Short circuit current temperature coefficient (A/C deg.): ", alpha_sc_refL[moduleIndex], "_", PVmoduleSettings[11]
    print "Open circuit voltage temperature coefficient (V/C deg.): ", beta_oc_refL[moduleIndex], "_", PVmoduleSettings[12]
    print " "
    print "Reference light current: ", IL_refL[moduleIndex], "_", PVmoduleSettings[13]
    print "Reference diode saturation current: ", Io_refL[moduleIndex], "_", PVmoduleSettings[14]
    print "Reference series resistance: ", Rs_refL[moduleIndex], "_", PVmoduleSettings[15]
    print "Reference shunt resistance: ", Rsh_refL[moduleIndex], "_", PVmoduleSettings[16]
    print " "
    print "Reference ideality factor: ", A_refL[moduleIndex], "_", PVmoduleSettings[17]
    print "Diode factor: ", n_sL[moduleIndex], "_", PVmoduleSettings[18]
    print " "
    print "Temperature coefficient adjustment factor: ", adjustL[moduleIndex], "_", PVmoduleSettings[19]
    print "Temperature coefficient of Power (perc./C deg.): ", gamma_r_refL[moduleIndex], "_", PVmoduleSettings[20]
    print "Wind speed adjustment factor: ", ws_adjusted_factor, "_", PVmoduleSettings[21]
    print "Normal operating cell temperature: ", Tnoct_adj, "_", PVmoduleSettings[22]
    """
    return moduleNameL, moduleNameL[moduleIndex], materialL[
        moduleIndex], moduleMountType_final, moduleAreaML[
            moduleIndex], nameplateDCpowerRating_mL[
                moduleIndex], moduleEfficiencyL[
                    moduleIndex], sourceNotes, PVmoduleSettings, validInputData, printMsg
コード例 #6
0
ファイル: file_IO.py プロジェクト: tmwarchitecture/PCPA_TOOLS
def exportToRenderDWG():
    try:
        fileLocations = config.GetDict()

        print "Exporting to 3ds max"
        objs = rs.GetObjects("Select objects to export", preselect=True)
        if objs is None: return

        #SAVE FILE NAME
        defaultFolder = rs.DocumentPath()
        defaultFilename = utils.GetDatePrefix() + '_OPTION_01'
        fileName = rs.SaveFileName("Export to render", "Autocad (*.dwg)|*.dwg||", defaultFolder, defaultFilename)
        if fileName is None: return
        base=os.path.basename(fileName)
        cadName = os.path.splitext(base)[0]

        #SUPER EXPLODE
        #EXPLODE SELECTED BLOCKS (CHECKLIST)
            #blockNames = rs.BlockNames(True)
            #print blockNames

            #results = rs.CheckListBox(blockNames, "Select blocks to explode", "Explode for render")
        #CHECK BACKFACES
        #CHECK GEOMETRY
        #EXPORT EACH LAYER AS SAT FILE.
        #CHECK ORIGIN
        #INSERT ORIGIN

        #CHECK SCALE (Units)
        if rs.UnitSystem() == 8:
            print "Units checked"
        else:
            print "This model is in {}, it should be in Inches".format(rs.UnitSystemName(singular=False))

        #UNIFY MESH NORMALS
        #MERGE ALL EDGES
        #MERGE ALL FACES

        #DELETE DUPS
        #rs.UnselectAllObjects()
        #rs.Command('-_Seldup ', echo=False)
        #dupObjs = rs.SelectedObjects()
        #if len(dupObjs) > 0:
        #    rs.DeleteObjects(dupObjs)
        #    print "{} duplicate objects deleted".format(len(dupObjs))

        #JOIN BY LAYER

        #PLACE UNDER A PARENT LAYER W/ DATESTAMP
        AddMasterRootLayer(cadName)

        #CHANGE LAYER NAMES?

        #IMPORT ACAD SCHEME
        standards.LoadAcadSchemes(fileLocations['ACAD Scheme Folder'])

        #SET DEFAULT FOLDER TO REFERENCE FOLDER UNDER RENDERING

        #EXPORT TO DWG
        rs.SelectObjects(objs)
        exportScheme = 'PCPA_MaxSolids'
        rs.Command('-_Export ' + '"' + fileName + '" S ' + '"' + exportScheme + '"' + ' Enter P 100 Enter', False)

        #REMOVE MASTER ROOT LAYER
        RemoveMasterRootLayer(cadName)
        return True
    except:
        return False
コード例 #7
0
ファイル: drawing.py プロジェクト: tmwarchitecture/PCPA_TOOLS
def AreaTag(obj, decPlaces):
    try:
        rhsrf = rs.coercesurface(obj)
        if rs.IsCurve(obj):
            if rs.IsCurvePlanar(obj) == False:
                return [0, False]
            if rs.IsCurveClosed(obj) == False:
                return [0, False]

        #get area
        if rs.UnitSystem() == 8:
            if rs.IsCurve(obj):
                area = rs.CurveArea(obj)[0]*0.0069444444444444
            else:
                area = rs.Area(obj)*0.0069444444444444
            areaText = utils.RoundNumber(area, decPlaces) + " SF"
        else:
            print "WARNING: Your units are not in inches"
            area = rs.CurveArea(obj)[0]
            areaText = area + ' ' + rs.UnitSystemName(False, True, True)

        #add annotation style
        dimStyle = sc.doc.DimStyles.FindName('PCPA_12')

        ###########################################################################
        #CURVES
        if rs.IsCurve(obj):
            if utils.IsRectangle(obj)[0]:
                #RECTANGLES
                srf = rs.AddPlanarSrf(obj)
                plane = HorizPlaneFromSurface(srf)
                rs.DeleteObject(srf)
            else:
                #OTHER CURVES
                srf = rs.AddPlanarSrf(obj)
                plane = HorizPlaneFromSurface(srf)
                rs.DeleteObject(srf)
        ###########################################################################
        #HATCHES
        elif rs.IsHatch(obj):
            rhobj = rs.coercegeometry(obj)
            boundaryCrvs = []
            crvs = rhobj.Get3dCurves(False)
            for crv in crvs:
                boundaryCrvs.append(crv)
            for crv in rhobj.Get3dCurves(True):
                boundaryCrvs.append(crv)
            srf = sc.doc.Objects.AddBrep(rc.Geometry.Brep.CreatePlanarBreps(boundaryCrvs)[0])
            plane = HorizPlaneFromSurface(srf)
            rs.DeleteObject(srf)
        ###########################################################################
        #SURFACES
        elif rs.IsSurface(obj):
            plane = HorizPlaneFromSurface(obj)

        ###########################################################################
        #OTHER/ERROR
        else:
            pts = rs.BoundingBox(obj)
            centerPoint = (pts[0] + pts[6]) / 2


        if dimStyle is not None:
            textHeight = dimStyle.TextHeight
            areaTag = rs.AddText(areaText, plane, height = textHeight, justification = 131074)
        else:
            areaTag = rs.AddText(areaText, plane, height = 1, justification = 131074)

        #Change layers
        hostLayer = layers.AddLayerByNumber(8103, False)
        rs.ObjectLayer(areaTag, layers.GetLayerNameByNumber(8103))
        return [area, True, areaTag]
    except:
        return [0, False]