List Family Sizes Error

HI everyone, I’m trying to get a list of the Families Size, but I hasn’t been working for a while, below is the error it shows. If anyone can help me on how to solve this, I really need it for my job.

ERROR [pyrevit.revit] Error in ErrorSwallower Context. | <type ‘exceptions.Exception’>:The model could not be saved: (COleException 0x80030002)

IronPython Traceback:
Traceback (most recent call last):
File “C:\Users\ODP-10981 DC\AppData\Roaming\pyRevit-Master\extensions\pyRevitTools.extension\pyRevit.tab\Analysis.panel\Tools.stack\Inspect.pulldown\ListFamilySizeCreator.pushbutton\ListFamilySizeCreator_script.py”, line 113, in
Exception: The model could not be saved: (COleException 0x80030002)

Script Executor Traceback:
Autodesk.Revit.Exceptions.FileNotFoundException: The model could not be saved: (COleException 0x80030002)
at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.HandleException(InterpretedFrame frame, Exception exception)
at Microsoft.Scripting.Interpreter.Interpreter.HandleException(InterpretedFrame frame, Exception exception)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at PyRevitLabs.PyRevit.Runtime.IronPythonEngine.Execute(ScriptRuntime& runtime)

@Danycares92 ,

good question. i managed my code to get this:

from Autodesk.Revit.DB import *
import System
import os

import time
#import ipywidgets as widgets
#from IPython.display import display
from pyrevit import script, revit, DB, forms

# pyRevit
from pyrevit import revit, forms
from pyrevit import DB, UI
from pyrevit import PyRevitException, PyRevitIOError

# pyrevit module has global instance of the
# _HostAppPostableCommand and _ExecutorParams classes already created
# import and use them like below

from pyrevit import HOST_APP
from pyrevit import EXEC_PARAMS
from pyrevit.compat import safe_strtype
from pyrevit import framework
from pyrevit.output import linkmaker
from pyrevit.userconfig import user_config

# .NET Imports
import clr

clr.AddReference("System")

from System.Collections.Generic import List
from System.IO import FileInfo
from collections import defaultdict
# ╦  ╦╔═╗╦═╗╦╔═╗╔╗ ╦  ╔═╗╔═╗
# ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║  ║╣ ╚═╗
#  ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES
# ==================================================
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
app = __revit__.Application

mb = 1048576.0
kb = 1024.0

# get Schedules
def getSize(p, mb=mb, kb=kb, kbOnly = False):
	sb = FileInfo(p).Length
	if sb < mb or kbOnly:
		return '%.3f KB' % (sb / kb)
	else:
		return '%.3f MB' % (sb / mb)

time_start = time.time()

directory = 'C:/Users/andre/Desktop/Familien'
names = os.listdir(directory)
familyFileNames = [i for i in os.listdir(directory) if i.endswith(".rfa")]
familyPaths = [os.path.join(directory,i) for i in familyFileNames]
stats = [os.stat(i) for i in familyPaths]
sizes = [i.st_size for i in stats]
converted = [int(i) for i in sizes]
kiloBite = [(str(i/1000) + " KB") for i in converted]


OUT = zip(names,kiloBite) #converted)

for p in OUT:
	print(p)

KR

Andreas

Hi Andreas, Thanks for your answer.
I don’t have any coding knowledge, so if you can please describe what should I do with this, It would be great.

Thanks again, and sorry for my lack of knowledge.

KR,
Daniela

@Danycares92 ,

where to start :wink: ?

mb = 1048576.0
kb = 1024.0

# get Schedules
def getSize(p, mb=mb, kb=kb, kbOnly = False):
	sb = FileInfo(p).Length
	if sb < mb or kbOnly:
		return '%.3f KB' % (sb / kb)
	else:
		return '%.3f MB' % (sb / mb)

time_start = time.time()

directory = 'C:/Users/andre/Desktop/Familien'
names = os.listdir(directory)
familyFileNames = [i for i in os.listdir(directory) if i.endswith(".rfa")]
familyPaths = [os.path.join(directory,i) for i in familyFileNames]
stats = [os.stat(i) for i in familyPaths]
sizes = [i.st_size for i in stats]
converted = [int(i) for i in sizes]
kiloBite = [(str(i/1000) + " KB") for i in converted]


OUT = zip(names,kiloBite) #converted)

for p in OUT:
	print(p)

the main part happens in this area… you can paste to chatGPT and ask “please write comments to this code, what it does, do not change the code!”

i can just recomment you do a basic course in Python ( you get by 10€, online with a punch of content). Or learn here www.learnrevitAPI.com. I have only Dynamo background.

…programming is not so hard as it sounds.

KR

Andreas

@Danycares92 welcome,

taken directly from the Revit API docs

The given file, path or network location could not be found during save.

It means that the temp file save location is inaccessible or that the original family is not accessible.

you could encapsulate the line 113 of the script in a try:except: so that it can bypass the specific families not working.

  1. Open:
    C:\Users\ODP-10981 DC\AppData\Roaming\pyRevit-Master\extensions\pyRevitTools.extension\pyRevit.tab\Analysis.panel\Tools.stack\Inspect.pulldown\ListFamilySizeCreator.pushbutton\ListFamilySizeCreator_script.py

  2. @ line 113

                    try:
                        fam_doc.SaveAs(fam_path, save_as_options)
                    except Exception as e:
                        print("Family cannot be saved in this location: {}".format(fam_path))
  1. report with a screen capture the output windows with the results. If conclusive, I will commit this change.
1 Like