I think in general you could approach the problem with a generating function. So for your second example, you want to choose three items where you pick only one from each of six groups where the groups have 4, 2, 3, 1, 4, and 2 members. I think a generating function like this
$(4x+1)(2x+1)(3x+1)(x+1)(4x+1)(2x+1)$
would work. You would multiply it out and then look at the coefficient of $x^3$. According to an online calculator, in this case that would be $192x^6+544x^5+604x^4+340x^3+103x^2+16x+1$, so look at the coefficient of $x^3$, and the answer is $340$.
I'm not completely confident it works, but my reasoning is you want only three of the $(ax+1)$ factors to contribute to your answer, so you look at the $x^3$ coefficient, and $a$ represents the number of ways that factor can contribute to the group of three.
If we carry this reasoning further, it would generalize quite well. If you wanted one group with $a$ members and you wanted to contribute a maximum of 2 from it (you could still pick 0 or 1 from it), then you could represent that by the factor ${a \choose 2}x^2+ax +1$, because there would be $a \choose 2$ ways for that group to contribute 2 things.
Plus if you want to choose more things from any given setup, you would just look at the coefficient of a higher degree. For one last example, lets say you have five groups, with 6, 3, 2, 5, and 4 items in each. You want to choose at most 4 from the first group, at most 1 from the second and third, at most 3 from the fourth but not exactly 2 things, and either 4 things or no things from the last. You want to pick 5 things from these groups using these rules. I believe you could just look at the $x^5$ coefficient in the expanded form of the following polynomial:
$\big( {6 \choose 4}x^4 + {6 \choose 3}x^3 + {6 \choose 2}x^2 + 6x +1\big) \big(3x+1 \big) \big(2x+1 \big) \big( {5\choose4}x^4 + {5\choose3}x^3 + 5x +1 \big) \big( {4 \choose 4}x^4 +1 \big)$
If that's wrong, someone tell me, but it makes a lot of sense to me right now.