示例#1
0
def store_sharedparam_def(shared_params):
    # Reads the shared parameters into a txt file
    sparam_file = HOST_APP.app.OpenSharedParameterFile()
    exported_sparams_grp = sparam_file.Groups.Create("Exported Parameters")
    for sparam in shared_params:
        sparamdef_create_options = \
            DB.ExternalDefinitionCreationOptions(
                sparam.Definition.Name,
                sparam.Definition.ParameterType,
                GUID=sparam.GUID
            )

        try:
            exported_sparams_grp.Definitions.Create(sparamdef_create_options)
        except Exceptions.ArgumentException:
            forms.alert("A parameter with the same GUID already exists. "
                        "Parameter: %s will be ignored." %
                        sparam.Definition.Name)
示例#2
0
selection = DB.FilteredElementCollector(doc)\
                    .OfCategory(target_category)\
                    .WhereElementIsNotElementType() \
                    .ToElements()

try:
    myGroup = myGroups.Create("pystructure")
except Exception as e:
    if len(str(e)):
        forms.alert(str(e), title="Error", ok=True, yes=False, no=False)
    else:
        pass  # Parameter group already exists
        # forms.alert("Parameter group already exists",title="Error",ok = True,yes = False,no = False)
else:
    option_1 = DB.ExternalDefinitionCreationOptions("North_Coord",
                                                    DB.ParameterType.Text)
    option_2 = DB.ExternalDefinitionCreationOptions("East_Coord",
                                                    DB.ParameterType.Text)

    option_1.UserModifiable = False
    option_1.Description = "Coordinates of piles/column"

    option_2.UserModifiable = False
    option_2.Description = "Coordinates of piles/column"

    myDefinition_ProductDate = myGroup.Definitions.Create(option_1)
    myDefinition_ProductDate = myGroup.Definitions.Create(option_2)

#get the category and build a category set.
builtInCategory = DB.BuiltInCategory.OST_StructuralFoundation
# create a categroy set incase you need to add to multiple Categories