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)
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)
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.