When I try to use uidoc.PromptForFamilyInstancePlacement I can place the family but then once I hit escape the family disappears and this exception is shown: “Exception: The user aborted the pick operation.”
# Oneline Diagram - Pick Picture
# Import libraries
from pyrevit import DB, revit, script, forms, output, UI
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import UIDocument, PostableCommand, RevitCommandId
from System.Collections.Generic import List
# Current document
doc = __revit__.ActiveUIDocument.Document
cView = doc.ActiveView
uidoc = __revit__.ActiveUIDocument
uiapp = uidoc.Application
# ################################################################################
# Debug toggles
globalDebug = True
disabledScript = False
def dprint(*printItems):
if globalDebug:
for pI in printItems:
print(pI)
################################################################################
# Variables
output = output.get_output()
################################################################################
################################################################################
################################################################################
# image selector
################################################################################
################################################################################
path_two = 'L:/Revit/Development/PyRevit/DevTool/image'
dprint(path)
image = forms.select_image(
script.get_bundle_files(path_two))
# Name
dprint("Name Test:")
name_and_type = image.split("\\")[1].split(".")[0]
family_name = name_and_type.split("!")[0]
dprint(family_name)
family_type = name_and_type.split("!")[1]
dprint(family_type)
################################################################################
################################################################################
# Collect the elements
################################################################################
################################################################################
component_collection = (FilteredElementCollector(doc).
OfCategory(DB.BuiltInCategory.OST_DetailComponents).
WhereElementIsElementType().
ToElements())
family = None
default_type = None
dprint("---===Detail Components===---")
for cc in component_collection:
if str(cc.GetType()) == 'Autodesk.Revit.DB.FamilySymbol':
dprint(cc.FamilyName)
if cc.FamilyName == family_name:
dprint("--Family Name Matched")
family = cc
type_name = DB.Element.Name.__get__(family)
if type_name == family_type:
default_type = family
dprint("----Type Name Matched : " + str(type_name))
break
dprint(default_type)
uidoc.PromptForFamilyInstancePlacement(default_type)