How to rollback if a family can not make


I am having an issue where I am trying to pass a parameter number into a curtain wall family- for a different reason- this family fails to build.

It then tells me that the family can not build and I should delete the type and replace the family (this happens with a revit box that pops up).

Is there a way inside rhino inside (or my python script) where I can see that it fails and then tell the script- actually I do not want to change the parameter (and in turn delete it).

Ideally I would just leave the family as is and record that there was an issue passing in the new parameter.

However, I want it to operate on all the ones it can make successfully, just not the ones that it cant.



What does the error look like? Is it raising an exception? Do you know about try...except blocks in python?

Hi Graham,

So I pass in my parameter and the python script runs.

Then I get this error once the script has run:

I then press delete and replace and it just changes by default to a blank panel and loses all its infomation.

With my script:

I first find the paramter and then I try and set it, I do this within a try:

My script is below:

f Trigger:

with DB.Transaction(doc, 'test') as t:
    for count, element_ind in enumerate(Element):
        # Get the element name
        PanelName = element_ind.Name
        # Value for Element
        Current_Value = (Value[count])

        # Convert to correct revit units
        Value_Conversion = UnitConverter.InHostUnits(Current_Value, DB.ParameterType.Length)
        # Input Value
        Element_Input = element_ind.LookupParameter("Panel_AngleIntersection_Input")
        SetInput = Element_Input.Set(str(Current_Value))
        Element_Input = element_ind.LookupParameter("Panel_AngleIntersection_Error")
        SetInput = Element_Input.Set(str("Added"))
        # Find the Keys Parameter
        Element_Key_Value = element_ind.LookupParameter(Key)
        Element_Key_Value_String = Element_Key_Value.AsString()

            SetValue = Element_Key_Value.Set(Value_Conversion)
            Element_NewValue = element_ind.LookupParameter(Key)
            # Pass out some information

            # This says if it cant get this value, then it sets 1000 instead
            #SetValue = Element_Key_Value.Set(1000)
            print("An exception occurred")


Out of my arena but i believe this will get you closer… SetFailureHandlingOptions Method

This was in one of Ehsan’s scripts…

class FailureSwallower(DB.IFailuresPreprocessor):
    def PreprocessFailures(self, failuresAccessor):
        failures = failuresAccessor.GetFailureMessages()
        for failure in failures:
        return DB.FailureProcessingResult.Continue

# create and start the transaction
t = DB.Transaction(doc, 'Transaction Name')
fhndlr_opts = t.GetFailureHandlingOptions()

1 Like

Excellent I will look into this- essentially I want a way to say if one of the families fails to make- roll that back… but keep trying to do the others and then commit.

you might have to get more particular in the error handling, but honestly not sure what’s possible.

this one might do it, no?

“Loaded family curtain panels cannot be used in non-rectangular cells of the curtain host. Type-driven panels from non-rectangular cells were unlocked and left unchanged.”