Esempio n. 1
0
def RunCommand(is_interactive):
    # Get existing props
    name_Exg = getAttrs(rs.SelectedObjects(), 'Object Name')
    act_Exg = getAttrs(rs.SelectedObjects(), 'Object Activ_Disc')

    dialog = Dialog_WindowProperties(name_Exg, act_Exg)
    rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
    name_New, act_New = dialog.GetUserInput()

    try:
        update = dialog.GetUpdateStatus()
    except:
        update = False

    if update == True:
        for eachObj in rs.SelectedObjects():

            rs.SetUserText(eachObj, 'Object Name',
                           '%<ObjectName("{}")>%'.format(str(eachObj)))
            if 'varies' not in str(name_New): rs.ObjectName(eachObj, name_New)

            if 'varies' not in str(act_New):
                rs.SetUserText(eachObj, 'Object Activ_Disc', str(act_New))

    return 0
Esempio n. 2
0
    def setObjAttrs(self, _dialogVals):
        for eachObj in self.selectedObjects:
            rs.SetUserText(
                eachObj, 'Object Name', '%<ObjectName("{}")>%'.format(
                    str(eachObj)))  # Formula to auto-set the obj's name

            if _dialogVals.get('frame') != '<varies>':
                rs.SetUserText(eachObj, 'FrameType', _dialogVals.get('frame'))
            if _dialogVals.get('glass') != '<varies>':
                rs.SetUserText(eachObj, 'GlazingType',
                               _dialogVals.get('glass'))
            if _dialogVals.get('variant') != '<varies>':
                rs.SetUserText(eachObj, 'VariantType',
                               _dialogVals.get('variant'))
            if _dialogVals.get('psiInst') != '<varies>':
                rs.SetUserText(eachObj, 'PsiInstallType',
                               _dialogVals.get('psiInst'))
            if _dialogVals.get('instDepth') != '<varies>':
                rs.SetUserText(eachObj, 'InstallDepth',
                               _dialogVals.get('instDepth'))

            if str(_dialogVals.get('Left')) != 'None':
                rs.SetUserText(eachObj, 'InstallLeft',
                               str(_dialogVals.get('Left')))
            if str(_dialogVals.get('Right')) != 'None':
                rs.SetUserText(eachObj, 'InstallRight',
                               str(_dialogVals.get('Right')))
            if str(_dialogVals.get('Bottom')) != 'None':
                rs.SetUserText(eachObj, 'InstallBottom',
                               str(_dialogVals.get('Bottom')))
            if str(_dialogVals.get('Top')) != 'None':
                rs.SetUserText(eachObj, 'InstallTop',
                               str(_dialogVals.get('Top')))
Esempio n. 3
0
 def refresh(self):
     for attr in ATTRS:
         name = attr.name
         rs.SetUserText(str(self.id), name, getattr(self, name))
     self.setDims()
     for attr in ATTRS:
         name = attr.name
         rs.SetUserText(str(self.id), name, getattr(self, name))
Esempio n. 4
0
def makeDetail(keys, objs):
    if not objs: return
    for obj in objs:
        for key in keys:
            cur_keys = rs.GetUserText(obj)
            if key not in cur_keys:
                rs.SetUserText(obj, key, "0", False)
            else:
                val = rs.GetUserText(obj, key)
                if len(val) < 1 or val == " ":
                    rs.SetUserText(obj, key, "0", False)
Esempio n. 5
0
def setObjDict(obj):
    rs.SetUserText(obj, 'objdict')
    objkeys = [ x for x in rs.GetUserText(obj) if "BakeName" not in x ]
    # objkeys = rs.GetUserText()
    # keys = 'level grade elevation'
    # keys = keys.split()
    objvals = map(lambda x: rs.GetUserText(obj, x), objkeys)
    # vals = [idx, grade, str(x[1])]
    # objdict = dict(zip(objkeys, objvals))
    # rs.SetUserText(obj, 'objdict')
    rs.SetUserText(obj, 'objdict', dict(zip(objkeys, objvals)))
Esempio n. 6
0
def RunCommand(is_interactive):
    # First, get any properties of the existing object(s)
    tfa_Exg = getAttrs(rs.SelectedObjects(), 'TFA_Factor', _defaultVal=1)
    name_Exg = getAttrs(rs.SelectedObjects(), 'Object Name', _defaultVal=None)
    number_Exg = getAttrs(rs.SelectedObjects(),
                          'Room_Number',
                          _defaultVal=None)
    v_sup_Exg = getAttrs(rs.SelectedObjects(), 'V_sup', _defaultVal=0)
    v_eta_Exg = getAttrs(rs.SelectedObjects(), 'V_eta', _defaultVal=0)
    v_trans_Exg = getAttrs(rs.SelectedObjects(), 'V_trans', _defaultVal=0)
    use_Exg = getAttrs(rs.SelectedObjects(), 'useType', _defaultVal='-')
    lighting_Exg = getAttrs(rs.SelectedObjects(), 'lighting', _defaultVal='-')
    motion_Exg = getAttrs(rs.SelectedObjects(), 'motion', _defaultVal='-')

    # Call the Dialog Window
    dialog = Dialog_WindowProperties(tfa_Exg, name_Exg, number_Exg, v_sup_Exg,
                                     v_eta_Exg, v_trans_Exg, use_Exg,
                                     lighting_Exg, motion_Exg)
    rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
    number_New, name_New, tfa_New, vSup, vEta, vTrans, use, lighting, motion = dialog.GetUserInput(
    )

    try:
        update = dialog.GetUpdateStatus()  #True if 'OK', False if 'Cancel'
    except:
        update = False  # on any error with the user input

    # Apply the User Inputs to the Object's Attributes if Update==True
    if update == True:
        for eachObj in rs.SelectedObjects():
            # Sort out the name
            rs.SetUserText(
                eachObj, 'Object Name',
                '%<ObjectName("{}")>%'.format(str(eachObj))
            )  # Formula to auto-set the obj's name in Attribute Inspector
            if 'varies' not in str(name_New): rs.ObjectName(eachObj, name_New)

            # Set the rest of the Surface Attributes
            if use != '<varies>': rs.SetUserText(eachObj, 'useType', use)
            if lighting != '<varies>':
                rs.SetUserText(eachObj, 'lighting', lighting)
            if motion != '<varies>': rs.SetUserText(eachObj, 'motion', motion)
            if number_New != '<varies>':
                rs.SetUserText(eachObj, 'Room_Number', number_New)
            if str(tfa_New) != '<varies>':
                rs.SetUserText(eachObj, 'TFA_Factor', str(tfa_New))
            if str(vSup) != '<varies>':
                rs.SetUserText(eachObj, 'V_sup', str(vSup))
            if str(vEta) != '<varies>':
                rs.SetUserText(eachObj, 'V_eta', str(vEta))
            if str(vTrans) != '<varies>':
                rs.SetUserText(eachObj, 'V_trans', str(vTrans))

    return 0


# temp for debuggin in editor
#RunCommand(True)
Esempio n. 7
0
def save_hatch_options(obj, defaults):
    curve_id = rs.GetUserText(obj, KEY_ORIGIN)
    curve_id = rs.coerceguid(curve_id)
    curve_obj = sc.doc.Objects.FindId(curve_id)
    hatch = obj.Geometry

    rotation = math.degrees(hatch.PatternRotation)
    default_rotation = defaults.get(KEY_ROT)
    if rotation != default_rotation:
        rs.SetUserText(curve_id, KEY_ROT, rotation)

    basepoint = hatch.BasePoint
    default_basepoint = rs.coerce3dpoint(defaults.get(KEY_BASEPOINT))
    if basepoint != default_basepoint:
        rs.SetUserText(curve_id, KEY_BASEPOINT, basepoint.ToString())
Esempio n. 8
0
def createSphere():
    sphereRadius = rs.GetReal(message='Of what radius? ', minimum=0.1)
    x, y, z = [float(n) for n in raw_input('where?: "x y z"').split()]
    id = rs.AddSphere((x, y, z), sphereRadius)
    spheres.append(id)
    rs.SetUserText(id, key="Sphere", value=str(len(spheres)))
    print('Done.')
Esempio n. 9
0
def AddAreaTag():
    objs = rs.GetObjects("Select curves, hatches, or surfaces to add area tag", 65548, preselect = True)
    if objs is None: return

    decPlaces = rs.GetInteger("Number of decimal places", 0, maximum = 8)
    if decPlaces is None: return

    #Load Anno style if it doesnt exist already
    if sc.doc.DimStyles.FindName('PCPA_12') is None:
        standards.LoadStyles()

    rs.EnableRedraw(False)
    total = 0
    for obj in objs:
        try:
            currentArea,result, tag = AreaTag(obj, decPlaces)
            utils.SaveFunctionData('Drawing-Add Area Tag', [rs.DocumentName(), rs.ObjectLayer(obj), rs.ObjectDescription(obj), rs.CurrentDimStyle(), currentArea, decPlaces, result])
            total += currentArea
            rs.SetUserText(tag, 'hostGUID', str(obj))
        except:
            pass
    print 'Cumulative Area = ' + str(total)



    rs.EnableRedraw(True)
Esempio n. 10
0
def createBox():
    l, b, h = [float(n) for n in raw_input('Of what dimensions?: "length breadth height"').split()]
    x, y, z = [float(n) for n in raw_input('where?: "x y z"').split()]
    id = rs.AddBox([(x,y,z),(x,y+b,z),(x+l,y+b,z),(x+l,y,z),(x,y,z+h),(x,y+b,z+h),(x+l,y+b,z+h),(x+l,y,z+h)])
    boxes.append(id)
    rs.SetUserText(id, key="Box", value=str(len(boxes)))
    print('Done.')
Esempio n. 11
0
def setObjAreaValue(obj):
    if rs.IsSurface(obj):
        setSrfAreaValue(obj)
    elif rs.IsPolysurface(obj) and rs.IsPolysurfaceClosed(obj):
        setBrepFA(obj)
    else:
        rs.SetUserText(obj, "area", 'na')
Esempio n. 12
0
def createCone():
    coneRadius = rs.GetReal(message='Of what radius? ', minimum=0.1)
    x1, y1, z1 = [float(n) for n in raw_input('From where?: "x y z"').split()]
    x2, y2, z2 = [float(n) for n in raw_input('To where?: "x y z"').split()]
    id = rs.AddCone((x1, y1, z1), (x2, y2, z2), coneRadius, cap=True)
    cones.append(id)
    rs.SetUserText(id, key="Cone", value=str(len(cones)))
    print('Done.')
Esempio n. 13
0
def setClass(obj):
    classKeys = 'units public'
    func = rs.GetUserText(obj, "func")
    if func in classKeys:
        classValue = func
    else:
        classValue = "na"
    rs.SetUserText(obj, "class", classValue)
Esempio n. 14
0
def AddTag(obj, text, color):
    box = rs.BoundingBox(obj)
    mid = (box[0] + box[-2])/2
    tag = rs.AddTextDot(text, mid)
    rs.SetUserText(obj, 'tag', text)
    rs.ObjectColor(obj, color)
    group = rs.AddGroup()
    rs.AddObjectsToGroup([obj, tag], group)
Esempio n. 15
0
def AddBlockName(obj):
    name = rs.BlockInstanceName(obj)
    pt = rs.BlockInstanceInsertPoint(obj)
    bb = rs.BoundingBox(obj)
    text = rs.AddText(name, (bb[0] + bb[6]) / 2)
    rs.SetUserText(text, 'tag', 'label')
    group = rs.AddGroup()
    rs.AddObjectsToGroup([obj, text], group)
Esempio n. 16
0
def createKVByVal(obj, skeys, svals, classkey, classvals):
    objsval = rs.GetUserText(obj, skeys)
    svals = svals.split()
    classvals = classvals.split()
    if objsval not in svals:
        objclass = classvals[1]
    else:
        objclass = classvals[0]
    rs.SetUserText(obj, classkey, objclass)
Esempio n. 17
0
def rSet(val):
    objs = rs.GetObjects("Select objs")
    if objs:
        [rs.SetUserText(obj, key, str(val)) for obj in objs]
        group = rs.AddGroup()
        rs.AddObjectsToGroup(objs, group)
        # objs = None
        val = val + 1
        rSet(val)
Esempio n. 18
0
def groupByBB(objs):
    pairs = map(objBBPtPair, objs)

    for bb in groupbb:
        lvl = rs.GetUserText(bb, 'level')
        for pair in pairs:
            result = rs.PointInPlanarClosedCurve(pair[1], bb)
            if result == 1:
                rs.SetUserText(pair[0], "level", lvl)
Esempio n. 19
0
def RunCommand(is_interactive):
    hatch_guid = rs.GetObject('Select Hatch', rs.filter.hatch)
    if not hatch_guid:
        return Rhino.Commands.Result.Failure

    target_guid = rs.GetObject('Select Target', rs.filter.curve)
    if not target_guid:
        return Rhino.Commands.Result.Failure

    hatch = sc.doc.Objects.Find(hatch_guid)

    rotation = hatch.HatchGeometry.PatternRotation
    rotation = str(math.degrees(rotation))
    base = hatch.HatchGeometry.BasePoint
    base = list(base)
    base = json.dumps(base)

    rs.SetUserText(target_guid, 'patternRotation', rotation)
    rs.SetUserText(target_guid, 'patternBasePoint', base)

    return Rhino.Commands.Result.Success
Esempio n. 20
0
    def setObjAttrs(self, _dialogVals):
        for eachObj in self.selectedObjects:
            # Formula to auto-set the obj's name in the User Text = '%<ObjectName("{}")>%'
            rs.SetUserText(eachObj, 'Object Name',
                           '%<ObjectName("{}")>%'.format(str(eachObj)))
            if 'varies' not in str(_dialogVals['srfcName']):
                rs.ObjectName(eachObj, str(_dialogVals['srfcName']))

            self._setAttrIfNotVaries(eachObj, 'srfType',
                                     _dialogVals['srfcType'])
            self._setAttrIfNotVaries(eachObj, 'EPBC', _dialogVals['srfcEPBC'])
            self._setAttrIfNotVaries(eachObj, 'EPConstruction',
                                     _dialogVals['srfcAssmbly'])
Esempio n. 21
0
def bake_layer(from_layer, to_layer, options):
    default_rotation = options[KEY_ROT]
    scale = options['scale']
    draw_order = options['drawOrder']
    pattern = options['pattern']
    target_layer_index = sc.doc.Layers.FindByFullPath(to_layer, True)
    pattern_index = sc.doc.HatchPatterns.Find(pattern, True)
    if pattern_index < 0:
        print('Hatch pattern %s does not exist' % pattern)
        return

    source_objects = find_layer_objects(is_match_for_hatch_source, from_layer)
    if len(source_objects) == 0:
        print('Layer %s has no objects to bake' % from_layer)
        return

    normalize_objects(source_objects)
    custom_hatch_objects = get_modified_hatches(to_layer, options)
    for h in custom_hatch_objects:
        save_hatch_options(h, options)
    rs.PurgeLayer(to_layer)

    curves = [x.Geometry for x in source_objects]
    tolerance = sc.doc.ModelAbsoluteTolerance
    hatches = Rhino.Geometry.Hatch.Create(curves, pattern_index,
                                          default_rotation, scale, tolerance)
    proxies = [HatchProxy(x) for x in hatches]

    # bind main curve to created hatch
    for obj in source_objects:
        obj_bb = obj.Geometry.GetBoundingBox(True)
        hp = find_by_bounding_box(proxies, obj_bb)
        if not hp:
            continue
        hp.set_origin(obj)

    # Add created hatches to rhino doc + set attributes
    for hp in proxies:
        hp.apply_options(defaults=options)

        hatch = hp.hatch
        hatch_guid = sc.doc.Objects.AddHatch(hatch)
        hatch_obj = sc.doc.Objects.Find(hatch_guid)

        # save origin curve in hatch user text
        if hp.has_origin():
            rs.SetUserText(hatch_obj, KEY_ORIGIN, hp.origin.Id)

        hatch_obj.Attributes.LayerIndex = target_layer_index
        hatch_obj.Attributes.DisplayOrder = draw_order
        hatch_obj.CommitChanges()
Esempio n. 22
0
def sortByAxis(objs, fn=lambda x: x[1].X, r=False, key='level', start=1):
    kv = []
    kv2 = []
    pairs = map(objPtPair, objs)
    sortedpairs = sorted(pairs, key=fn, reverse=r)
    for idx, pairs in enumerate(sortedpairs, start=start):
        rs.SetUserText(pairs[0], key, str(idx))
        kv.append((str(idx), pairs[1]))
        kv2.append((str(idx), (pairs[1].X, pairs[1].Y, pairs[1].Z)))
    planptdict = dict(kv)
    planpts = dict(kv2)
    rs.SetDocumentUserText("planpts", json.dumps(planpts))
    sc.sticky['planpts'] = json.dumps(planpts)
    sc.sticky['planptdict'] = planptdict
Esempio n. 23
0
def massFromSrf(obj, height):
    # lvl = levels[rs.GetUserText(obj, 'level')]
    # height = float(lvl['height'])
    startpt = trp.objBBPts(obj)[0]
    endpt = (startpt.X, startpt.Y, startpt.Z + height)
    curve = rs.AddLine(startpt, endpt)
    mass = rs.ExtrudeSurface(obj, curve)

    trp.copySourceLayer(mass, obj)
    rs.SetUserText(mass, str(height))
    # trp.copySourceData(mass, obj)
    swapParentLayer(mass)
    rs.DeleteObject(curve)
    return mass
Esempio n. 24
0
def CreateDesignOption():
    objs = rs.GetObjects("Select objects to create design option with",
                         preselect=True)
    if objs is None: return None
    try:
        date = utils.GetDatePrefix()
        origName = date + '_OPTION_00'
        defaultName = origName
        for i in range(100):
            defaultName = utils.UpdateString(defaultName)
            if origName == defaultName:
                break
            if rs.IsBlock(defaultName) == False:
                break

        looping = True
        while looping:
            designOptionName = rs.StringBox("Design Option Name", defaultName,
                                            "Create Design Option")
            if designOptionName is None: return None
            if rs.IsBlock(designOptionName):
                print "Block name already exists"
            elif len(designOptionName) == 0:
                print "Must specify a name"
            else:
                looping = False
        block = rs.AddBlock(objs, (0, 0, 0), designOptionName, True)
        blockInstance = rs.InsertBlock(designOptionName, (0, 0, 0))

        #Add user text
        rs.SetUserText(blockInstance, 'Design Option History',
                       designOptionName)

        #Ensure 3_DESIGN OPTIONS already exists
        layers.AddLayerByNumber(3000, False)

        #Create new layer
        parentLayer = layers.GetLayerNameByNumber(3000)
        designOptionLayer = rs.AddLayer(parentLayer + "::" + designOptionName,
                                        color=utils.GetRandomColor())
        rs.ObjectLayer(blockInstance, designOptionLayer)
        utils.SaveFunctionData('Blocks-Create Design Option',
                               [__version__, designOptionName])
        return True
    except:
        print "Failed to create design option"
        utils.SaveFunctionData('Blocks-Create Design Option',
                               [__version__, '', 'Failed'])
        return None
Esempio n. 25
0
def blkObjs(blkid):
    blockName = rs.BlockInstanceName(blkid)
    # objref = rs.coercerhinoobject(blkid)
    # idef = objref.InstanceDefinition
    # idefIndex = idef.Index
    
    lvl = levels[rs.GetUserText(blkid, 'level')]
    height = lvl['height']
    xform = rs.BlockInstanceXform(blkid)
    objects = [x for x in rs.BlockObjects(blockName) if rs.IsPolysurfaceClosed(x)]

    objects = map(lambda x: rs.SetUserText(x, 'level', lvl), objects)
    # map(lambda x: rs.SetUserText(x, 'height', lvl))

    blockInstanceObjects = rs.TransformObjects(objects, xform, True)
Esempio n. 26
0
def Iterate():
    block = rs.GetObject("Select Design Option Block to iterate",
                         rs.filter.instance, True)
    if block is None: return

    try:
        prevBlockName = rs.BlockInstanceName(block)
        prevBlockLayer = rs.ObjectLayer(block)
        prevBlockLayerColor = rs.LayerColor(prevBlockLayer)

        newBlock = ReplicateBlock(block)
        newBlockName = rs.BlockInstanceName(newBlock)

        #Ensure 3_DESIGN OPTIONS already exists
        parentLayer = layers.AddLayerByNumber(3000, False)[0]
        rs.LayerVisible(parentLayer, True)

        #Create new design option layer
        #newBlockLayer = rs.AddLayer(parentLayer + "::" + newBlockName, color = utils.StepColor(prevBlockLayerColor))
        newBlockLayer = rs.AddLayer(parentLayer + "::" + newBlockName,
                                    color=utils.GetRandomColor())
        rs.LayerPrintColor(newBlockLayer, (0, 0, 0))
        rs.ObjectLayer(newBlock, newBlockLayer)

        #Save user text
        try:
            parentsUserTest = rs.GetUserText(block,
                                             'Design Option History') + "<--"
        except:
            parentsUserTest = ''
        rs.SetUserText(newBlock, 'Design Option History',
                       parentsUserTest + newBlockName)

        #Turn off prev blocks layer
        if rs.CurrentLayer() != prevBlockLayer:
            rs.LayerVisible(prevBlockLayer, False)

        result = True
    except:
        result = False
        newBlockName = ''
    utils.SaveFunctionData(
        'Blocks-Iterate',
        [__version__,
         rs.BlockInstanceName(block), newBlockName, result])
    return result
Esempio n. 27
0
def UserDataInput():
    obj = rs.GetObject("Select Object")

    Keylist = rs.GetUserText(obj, )

    UserDataList = []
    for n in Keylist:
        b = rs.GetUserText(obj, n)
        UserDataList.append(b)

    newlist = []
    newlist = rs.PropertyListBox(Keylist, UserDataList, "User Data",
                                 "User Data Key List")

    if newlist:
        for c in range(len(Keylist)):
            rs.SetUserText(obj, Keylist[c], newlist[c])
Esempio n. 28
0
def add_attr_bld():
    # set current working dir
    os.chdir(working_dir_path)

    # Add attributes to plots
    with open(proc_attributes_path, "r") as input_handle:
        rdr = csv.reader(input_handle)

        # read attribure labels (first row)
        attribute_labels_list = next(rdr)

        # get x, y, z attributes indices
        x_idx, y_idx, z_idx = attribute_labels_list.index(
            "Position X"), attribute_labels_list.index(
                "Position Y"), attribute_labels_list.index("Position Z")

        # get all objects in plots layer
        building_objs = rs.ObjectsByLayer(relevant_layers_dict["buildings"])

        for attributes_row in rdr:
            x_val, y_val, z_val = float(attributes_row[x_idx]), float(
                attributes_row[y_idx]), float(attributes_row[z_idx])

            related_building_pnt = rs.CreatePoint(x_val, y_val, z_val)

            for building_obj in building_objs:
                if rs.IsCurve(building_obj) and rs.IsCurveClosed(building_obj):
                    crv = rs.coercecurve(building_obj)
                    if rs.PointInPlanarClosedCurve(related_building_pnt, crv):
                        for attr_label, attr_val in zip(
                                attribute_labels_list, attributes_row):

                            # if NUM_APTS_C already set, add to it
                            num_of_apts_label = "NUM_APTS_C"
                            if attr_label == num_of_apts_label:
                                num_of_apts_val = rs.GetUserText(
                                    building_obj, num_of_apts_label)
                                if num_of_apts_val != None:
                                    attr_val = int(attr_val)
                                    attr_val += int(num_of_apts_val)

                            rs.SetUserText(building_obj, attr_label, attr_val)
Esempio n. 29
0
def add_attr_plt():
    # get objects by layer
    building_objs = rs.ObjectsByLayer(relevant_layers_dict["buildings"])
    plot_objs = rs.ObjectsByLayer(relevant_layers_dict["plots"])

    # read attribure labels (first row)
    attribute_labels_list = []
    with open(proc_attributes_path, "r") as input_handle:
        rdr = csv.reader(input_handle)
        attribute_labels_list = next(rdr)

    for building_obj in building_objs:
        if rs.IsCurve(building_obj) and rs.IsCurveClosed(building_obj):
            crv = rs.coercecurve(building_obj)

            #building_center_pt = rs.CurveAreaCentroid(building_obj)[0]
            building_center_pt = crv.GetBoundingBox(True).Center

            for plot_obj in plot_objs:
                if rs.PointInPlanarClosedCurve(building_center_pt, plot_obj):
                    for attr_label in set(attribute_labels_list).intersection(
                            plot_attribs_list):  #todo: intersection redundant

                        # get building attribute
                        plot_attr_val = int(
                            rs.GetUserText(building_obj, attr_label))

                        # if NUM_APTS_C already set, add to it
                        num_of_apts_label = "NUM_APTS_C"
                        if attr_label == num_of_apts_label:
                            num_of_apts_val = rs.GetUserText(
                                plot_obj, num_of_apts_label)
                            if num_of_apts_val != None:
                                plot_attr_val += int(num_of_apts_val)

                        rs.SetUserText(plot_obj, attr_label, plot_attr_val)
Esempio n. 30
0
def IntersectGeos(objs, plane):
    tolerance = rs.UnitAbsoluteTolerance()
    finalGeo = []
    for obj in objs:
        intersectionCrvs = []
        brep = rs.coercebrep(obj)
        if brep is None: continue
        x = Rhino.Geometry.Intersect.Intersection.BrepPlane(
            brep, plane, tolerance)
        xCurves = x[1]
        if xCurves is None: continue
        try:
            rs.JoinCurves(xCurves)
        except:
            pass
        for curve in xCurves:
            finalCurve = sc.doc.Objects.AddCurve(curve)
            rs.SetUserText(finalCurve, 'PCPA_floorplan', 'intersect')
            intersectionCrvs.append(finalCurve)
            finalGeo.append(intersectionCrvs)

        rs.MatchObjectAttributes(intersectionCrvs, obj)

    return finalGeo