Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI.Selection import *
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import TaskDialog
import random
import string
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
selection = uidoc.Selection
comments_structural_framing = IN[0]
structural_framing_family = IN[1]
# Get the selected detail item family
ref = selection.PickObject(ObjectType.Element, "Select a detail item family")
detail_item_family = doc.GetElement(ref)
# Start a transaction
TransactionManager.Instance.EnsureInTransaction(doc)
text_parameters = [p for p in detail_item_family.Parameters if p.StorageType == StorageType.String]
# Get the parameter with the specified name
parameter = None
for p in text_parameters:
if p.Definition.Name == comments_structural_framing:
parameter = p
break
if parameter is not None and parameter.StorageType == StorageType.ElementId:
family_id = parameter.AsElementId()
family = doc.GetElement(family_id)
if family.Category.Id.IntegerValue == (int) (BuiltInCategory.OST_StructuralFraming):
OUT = family.Name
else:
OUT = "The value of the specified parameter does not correspond to a structural framing family."
else:
OUT = "Parameter not found or has invalid type"
# Commit the transaction
TransactionManager.Instance.TransactionTaskDone()
# Display a message
TaskDialog.Show("Success", "The name of the structural framing family is: {}".format(OUT))#
Hello everyone,
in this script i'm trying to pick a detail item family.
if the text_parameter name of the detail item is p.Definition.Name == comments_structural_framing i need to find the type name of the corresponding structural framing family. i then need to write this type name to the value of the text parameter in the detail item family.
apparently is not finding any p.Definition.Name == comments_structural_framing so it skip to "Parameter not found or has invalid type".
I know it's a little crazy but i hope you can help!
thanks
Solved! Go to Solution.