Using Try in Design Script

Hi all,

Has the Try and catch function been enabled yet?
https://github.com/DynamoDS/Dynamo/issues/6218

I am trying to check if a family has been loaded into the current document. If it is loadded I do not want to load it in from the default location in case changes have been made. I tried using an if statement with design script but it still fails. I can probably figure out how to do it with python but I can not find the API call for Family.ByName

Any ideas?

Thank you,
Steven

I do not believe it has been, but others may know better.

To confirm what you’re after -

  • Get a family by name.
  • If it works great, move on.
  • If it fails load a family from an external source.

That sound about right?

I think it’s possible to use an if statement for this single depth of catching, but I need to know what package your File.LoadFamily is from to know for certain.

Simple If statement has me pretty hopeful (obviously not in imperative form and a very simple use case):

Hi @jacob.small,

Thanks for the quick turn around. File.LoadFamily is from the Orchid Package.

Copying what you have done the Code Block errors out but it does load the family. Do you know if there is a way to stop the error?

I am in Dynamo 2.0.3.8104 and Revit 2019


i think you will need to activate its symbol by using a python script.
https://www.revitapidocs.com/2016/b4e09402-f6cd-3f48-d01e-ecb87375bac5.htm

1 Like

Sadly Orchid has become a bit difficult for me to work with… I’ll try to get it reinstalled on my current package library tomorrow.

Off the top of my head you could try to suppress this warning by wrapping the function in a list and using a List.GetItemAtIndex function on the list. If it works you can file that under ‘bug as a feature’. It will likely get fixed at some point but you’ll have a few years without the warning.

1 Like

Associative IF code evaluates and runs both conditions but with an imperarive function, that’s not the case.

2 Likes

Thank you everyone for your help.

I found a good easy workaround after messing around with your suggestion Jacob.

2 Likes