Add an array of entities to an existing group?

Add an array of entities to an existing group?

Postby medeek » Tue Mar 06, 2018 7:48 am

Normally I add a group of entities (groups and components in an array) to my large assembly group with this single line of code:

@maingroup = Sketchup.active_model.entities.add_group(@all_trusses)

Instead I would like to add my array of entitities “@all_trusses” to an existing group that has already been created and is essentially empty except for a small place holder entity in it to prevent it from being garbage collected.
0
Nathaniel P. Wilkerson PE
Medeek Engineering Inc
design.medeek.com
User avatar
medeek 
PluginStore Author
PluginStore Author
 

Re: Add an array of entities to an existing group?

Postby sdmitch » Tue Mar 06, 2018 4:42 pm

medeek wrote:Normally I add a group of entities (groups and components in an array) to my large assembly group with this single line of code:

@maingroup = Sketchup.active_model.entities.add_group(@all_trusses)

Instead I would like to add my array of entitities “@all_trusses” to an existing group that has already been created and is essentially empty except for a small place holder entity in it to prevent it from being garbage collected.


How about
Code: Select all
@existinggroup.entities.add_group(@all_trusses)
0
Nothing is worthless, it can always be used as a bad example.

http://sdmitch.blogspot.com/
User avatar
sdmitch 
PluginStore Author
PluginStore Author
 

Re: Add an array of entities to an existing group?

Postby TIG » Tue Mar 06, 2018 9:23 pm

Unfortunately, if the model.active_entities is not the @existinggroup.entities context and/or the array of added entities is not in that same context, then a BUgSplat! awaits...
You cannot 'cross-thread' entities across contexts...
0
TIG
User avatar
TIG 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 6 guests

Visit our sponsors: