Help with grouping groups
-
OK, let me run with that for a while. Do you mean something like:
group = entities.add_group group.add_line . . .
Shoots its 3:30 am, I better go to bed, and get back to this tomorrow. Anything you can post to help me is appreciated. Good night:-) -
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 differentgroupX
whereX
is 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_1
be 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_group
All this is doing is setting
group1
to refer to the new group you create each time you call.add_group
-
proc_1
does nothing.def proc_1 group_1 = @entities.add_group list_of_groups.push group_1 end
You're creating a group
then adding the reference to that group to a non-existent arraylist_of_groups
list_of_groups
inmain
has no relationship withlist_of_groups
inproc_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 end
The 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.
Advertisement