Handling Can't make type error

Handling Can't make type error

newbieng
Contributor Contributor
1,606 Views
4 Replies
Message 1 of 5

Handling Can't make type error

newbieng
Contributor
Contributor

Hi everybody,

 

I don't know if what I'm asking is possible through te REVIT API, or it's simply a wish...anyway:

I've got a revit family that crashes whenever I try to change a parameter to some specific values. I can't find out the complete list of values that cause the crash: it happens whenever a void cuts a solid (sweep of a curve profile, something like a sinous profile) in different points along the profile. I can't figure out any geometric problem (it's a cut on an extrusion), the problem may be caused by curve approx or some internal conditions.

 

That said, I don't figure out a way to apply formulas in the family to avoid the crash-value and I'm inserting instances using an external command...I'm wondering if there's a way to retrieve the exception through the API and then assign a different value to the "wrong" parameter.

I've tryed to use the try/catch block but it doesn't encounter any exception when running, so Revit shows me the error message "can't make type" and than deletes my instance. I would like to stop the instance in the default configuration and simply don't set any parameter.

 

How can I retrieve the "can't make type" error message and avoid to delete the istance?

 

Thanks!

 

0 Likes
Accepted solutions (1)
1,607 Views
4 Replies
Replies (4)
Message 2 of 5

RPTHOMAS108
Mentor
Mentor

There is a built-in failure:

 

BuiltInFailures.FamilyFailures.CannotMakeType

 

You can use the Failures framework to respond to this but I doubt it will be detailed enough to tell you what parameters is causing such an issue. However if you are setting the parameter values by IExternalCommand then you may be able to review the values you have set in a granular way and establish the guilty party that way.

 

I don't think the API is yet a good substitute for knowing how your family is working and therefore what will cause it to fail. Can't make type is usually related to things becoming too small or dimensional changes that try to make geometry edges invert.

0 Likes
Message 3 of 5

newbieng
Contributor
Contributor

Hi @RPTHOMAS108, first of all thanks for your help!

Looking deeply at my family I've found out two parameters that cause the error, so at least I know their names! Trying to manually change the configuration I found out a possible range of values that I would avoid in order not to crash the instance. It migth not be complete but...I'm ready to retrieve the error message and then change a little bit the value to avoid the problem!

 

A question about the built-in failure you suggested me: I didn't use them before, so I'd like to know if my process is linear... can I use it in the same method that I use to insert my instance? Can you give me an example to set the structure of the code (the only post I've found is http://spiderinnet.typepad.com/blog/2011/02/implement-a-revit-failuresprocessing-event-handler-with-...)? ).

 

Many thanks!!

 

 

0 Likes
Message 4 of 5

RPTHOMAS108
Mentor
Mentor
Accepted solution

For what you want you should probably review the IFailuresPreprocessor rather than the Event, since IFailuresPreprocessor is related to the transaction within your IExternalCommand.

 

I don't know how your command functions to place the element and then change parameter values but since failures processing only starts after a transaction is called to commit you would have to create a loop with a transaction for every parameter change you try (on reflection this doesn't seem like a good design pattern).

 

If you know the value ranges that cause the issue you should instead check for them directly in your code and show a Taskdialog prompting the user. You could also post a custom failure prompting the user with possible resolutions.

Message 5 of 5

newbieng
Contributor
Contributor

@RPTHOMAS108 thanks for your ideas!

For what I can see, this may be the right instrument to avoid to show the type error... I'll have a try, it seems interesting! Sure, I will have to pay attention to what happens into the transaction, but Failure is the way 🙂

 

Just to help who isn't familiar with the IFailurePreprocessor, here is another similar post, with a bit of sample code: https://forums.autodesk.com/t5/revit-api-forum/return-failure-information-to-command/td-p/7695676

 

Cheers

 

 

 

0 Likes