Group Name or Description


#1

I’ve been in the habit of setting both the name and description for a group but really only ohe of these parameters is being displayed as the Instance name in the Entity Info tray.

So where or how is the description field actually used or where does it appear?


#2

Because Groups and Components are implemented atop the same backend ComponentDefinition, they share some attributes that the SketchUp GUI suppresses when the Entity is actually a Group. In particular, there is nowhere that the GUI displays either the ComponentDefinition’s name or its description for a Group (a Group’s Instance name is displayed in Model Info and the Outliner).

So, although you can assign these properties via the Ruby API they are of no use except within the API. For Components, the definition name shows in both Model Info and the Outliner and the description shows in the Components browser window.


Medeek Wall Plugin
#3

On a related note concerning groups and components it became obvious to me that using the definition method on a group:

group = Sketchup.active_model.entities.add_group
group_def = group.definition

Allows one to grab the component definition of the group and then perform operations on this group as if it were a component, for example add another instance:

new_instance = Sketchup.active_model.active_entities.add_instance(group_def, new_transformation)
new_instance.name = "group name #{pos_i}"

Does anyone see any problem in doing this with a group definition?


#4

Thank-you for this point of clarification. This information should be added to the API documentation.


#5

However if you use the add_instance method on a group and then check the entity info of the groups in the SketchUp GUI each one will say only (1 in model). One would think that it would report (x in model) since you are using the same definition to create additional copies. For some reason it is making the groups unique, which is unexpected, and to be honest somewhat of an annoyance.


#6

I would be nice if I could use the component method of “add_instance” on a group and still maintain the component like attributes for the groups (ie. they are still using the same definition).


#7

If your new group contains no entities at all, then it can simply ‘evaporate’ as SketchUp ‘garbage-collects’ and tidies up after itself… especially if there are too many complex steps before you next want to use that group later.

Provided that you add an entity to the group it will survive until later.
So @temp_cpoint = group.entities.add_cpoint(ORIGIN) is a useful fix if you find it’s vanishing before you need it.
You can then use @temp_cpoint.erase! if @temp_cpoint.valid? later on, e.g. once that group has some other entities populating it…


#8

After further testing it appears that the new group (instance) is made unique when the name is set:

new_instance.name = "group name #{pos_i}"

I’m also setting the material and layer of the newly created group and this does not affect the group definition.

The odd thing about this is that if you set the name of the group in the GUI it does not make the group unique, what is going on here?


#9

Should I be using the group copy method instead?


#10

After some further testing it appears that the copy method makes the group unique from the outset. Only using the add_instance method or using the copy feature in the GUI maintains the linked definition of the groups.