Help with grouping groups
-
Yes, like that.
-
I think I get my problem. I am trying to use one procedure
group1 = @entities.add_group(@selection)to create all my groups, and maybe I can't. If I can't, how do I create a differentgroupXwhereXis the times I come back to make a new group. -
You lost me a bit..
there should be no limit to how many entities you can add to a group. -
No that's not what I meant. How can the following
proc_1be called multiple times to create a different group each time its called? The following doesn't work, yes?def main aFile.each do |e| proc_1 proc_1 end end def proc_1 group1 = @entities.add_group end -
That will create a different group.
This will also create new groups
group1 = @entities.add_group group1 = @entities.add_group group1 = @entities.add_groupAll this is doing is setting
group1to refer to the new group you create each time you call.add_group -
proc_1does nothing.def proc_1 group_1 = @entities.add_group list_of_groups.push group_1 endYou're creating a group
then adding the reference to that group to a non-existent arraylist_of_groupslist_of_groupsinmainhas no relationship withlist_of_groupsinproc_1.Have you looked up in Ruby how arguments and return values work? And variable scope? It's some fundamental concepts to programming.
I was a about post an example of what you can do, but I'm not sure what you intend with the code.
You are reading a file, and for each line you want to add a group to a bigger group?def main big_group = @entities.add_group aFile.each do |e| sub_group = big_group.add_group() # now you can add entities to the sub-group sub_group.entities.add_face(...) sub_group.entities.add_line(...) end end?
-
Ok, so how are the different groups placed in a
big_group? My attempt fails at the 6th lines.def main big_group = @entities.add_group #do I need? aFile.each do |e| proc_1 proc_1 big_group.add_group(list_of_groups)#fails? end end def proc_1 group_1 = @entities.add_group list_of_groups.push group_1 endThe following works with all Sketchup::Entity except for Sketchup::Group
def main aFile.each do |e| proc_1 proc_1 #following works except for adding groups @entities.add_group(list_of_groups) end end def proc_1 group_1 = @entities.add_group list_of_groups.push group_1 end -
I am reading a Cad file of entities, making SU entities from that list. Some of the entities are Cad blocks (a bunch of Cad entities), that I am trying to turn into SU
Group(s)

I can insert and group, edges and faces, but not groups. -
Well, I made it work in the web console, now back to the program.
` model = Sketchup.active_model
entities = model.active_entitiesmaster_group = []
point1 = Geom::Point3d.new(0,0,0)
point2 = Geom::Point3d.new(20,20,0)
point3 = Geom::Point3d.new(10,10,0)
point4 = Geom::Point3d.new(30,30,0)
point5 = Geom::Point3d.new(10,30,0)line1 = entities.add_line point1,point2
group1 = entities.add_group line1
master_group.push group1line2 = entities.add_line point3,point4
group2 = entities.add_group line2
master_group.push group2line3 = entities.add_line point3,point5
master_group.push line3entities.add_group(master_group)`

-
When you model you draw face/line - then group.
But when you build geometry with the API, make the group first and then add the geometry directly inside the group - instead of moving it afterwards which is prone to crashes.` model = Sketchup.active_model
entities = model.active_entitiesmaster_group = entities.add_group
point1 = Geom::Point3d.new(0,0,0)
point2 = Geom::Point3d.new(20,20,0)
point3 = Geom::Point3d.new(10,10,0)
point4 = Geom::Point3d.new(30,30,0)
point5 = Geom::Point3d.new(10,30,0)group1 = master_group.entities.add_group
line1 = group1.entities.add_line(point1,point2)group2 = master_group.entities.add_group
line2 = group1.entities.add_line(point3,point4)group3 = master_group.entities.add_group
line3 = group3.entities.add_line(point3,point5)` -
Yes, I read something about that in the API, but I thought that was a problem for SU versions prior to 8.0. Anyway, I wouldn't have been able to do it without your help, thanks.
-
It is safer in any case - as you don't risk your edges/faces merging with stuff it should not merge with.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement