Fake family to avoid error

Hi group,

im applying an if condition as seen below. In the case the result of the if is true, I want a family to be drawn, but in the case of false I want nothing to be drawn. Everything is working correctly, the point is that when the if is false, I get an error as the output of the node is something not cosidered a Family and I am introducing it into the next node (which is asking for a Family).

Is there the option to give to the False something like a fake family for not getting this error, but also for not having anything modelled?

Thanks!

Hi :slight_smile:

Have you tried passing an Empty List ([]) rather than an Empty string ("") ?

Same problem @mellouze

Then, a way (I guess) to solve your problem is going through an Imperative block.
Try this one and place it in lieu of the FamilyInstance.ByPoint node (I don’t know the rest of your graph, so I’m hoping this will not cause some errors afterwards):

family; // The family you want to create if boole is true
points; //adaptive points
boole;
[Imperative]{
    if(boole){
       return = FamilyInstance.ByPoint(family, points);
    }
    else{
        return = [];
    }
}

No need to get imperative here but I love it.

If all you’re after is avoiding the error popping up and are concerned that going full imperative may be a bit above your skill set, I’ll give you two other options to consider. They all involve writing some code though so be ready.

The first option: Use an if statement with the family creation function in the same line, choosing to take whatever action you’d like here.

The second option: Perform the family creation effort inside another function that alters the structure somehow. In this case I used a List.Flatten function to reduce the list by 0 levels.

1 Like

Thanks @JacobSmall
this solved the problem

Thanks also @mellouze , but it was returning me the same error, as this solution is outputting the same empty list as before when if is false.

Acutally, there should not be an error with what I wrote down, as you never compute a FamilyInstance.ByPoint of an empty list. So the error caused by this particular node should be gone.

However, the rest of your code (which I do know nothing about) may not work and output an error :slight_smile:

I will try it later or post the file if the error is still showing.

We can always learn something new :wink:

1 Like

Hi @mellouze,

i had some troubles with Dynamo last week and anything was working, so I could not take a look at it till now.

As you where saying your given solution was not giving an error, but the nodes after it (a family rotation node).
So i just joined the rotation in your given node and now everything is working!

1 Like

Glad you figured this out :slight_smile:

Not sure if this is a bug but it works in a code block too:


I had to define famtype because it was still creating the family instance when I used the Family Type directly. Seems like it was running both the true and false condition but only returning one. Using a null value for the family type didn’t return any warnings though.