@unknownuser said:
Then, you when are ready to create your big overall group, code this:
overall_group = Sketchup.active_model.entities.add_group( left_side_group, right_side_group, bottom_group )
This works for most of my scripts except:
Some of the scripts include items which may or may not be created depending on the input.
For example the script allows for there to be none, one, two or three drawers, and the overall_group call would be:
overall_group = Sketchup.active_model.entities.add_group( left_side_group, right_side_group, bottom_group, drawer1_group, drawer2_group, drawer3_group)
This works if both drawers groups are created from the input, but if the option for the second drawer is not to have one, drawer2_group is not created so the overall_group is not created either.
My thoughts are that I need to write a couple of statements to check if the group has been created - something like this:
if drawer_group3 exists then
overall_group = Sketchup.active_model.entities.add_group( left_side_group, right_side_group, bottom_group, drawer1_group, drawer2_group, drawer3_group)
else
if drawer_group2 exists then
overall_group = Sketchup.active_model.entities.add_group( left_side_group, right_side_group, bottom_group, drawer1_group, drawer2_group)
else
if drawer_group1 exists then
overall_group = Sketchup.active_model.entities.add_group( left_side_group, right_side_group, bottom_group, drawer1_group)
else
overall_group = Sketchup.active_model.entities.add_group( left_side_group, right_side_group, bottom_group, drawer1_group)
What I am not certain about is what the statements shown in red should be for checking if the group was previously created.
Can anyone assist.
Thanks.