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?
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 = [];
}
}
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.
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
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!
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.