Groups
-
I was attempting to generate a model feature which I wanted to be created in two groups, part of the feature in one group and the rest in another concurrently. Although no error is generated, only one of the groups appears in the model. Is this not possible?
-
Add two groups to the model.entities with references to each - say gp1 and gp2.
Use 'add' your new stuff to gp1.entities or gp2.entities.
How are you defining groups and adding things to entities ?? -
I did it like this
step=ent.add_group; sent=step.entities; step.name="Steps" rail=ent.add_group; rent=rail.entities; rail.name="Rails" face=sent.add_face(p1,p2,p3,p4) line=rent.add_line(p4,p5)
The "Steps" appears, "Rails" do not.
-
Looks OK...
Are p4 and p5 valid [different] points ?
Any newly made group will vanish after a model.commit_operation IF it's 'empty'...
Do you get any error messages in the Ruby Console?? -
No, no error messages of any kind in the Ruby console. Yes, p4 and p5 are valid points. The adding of the groups was the last thing I was attemping to do after numerous successful runs of the plugin.
-
The face adds OK to one group, add the same face to the other using the same points.
Then you must [?] have both groups albeit that they are on top of each other afterwards...Are you sure there are no typos in the actual code ??
-
I copied the code directly from the plugin to my previous response. I add a puts statement and it did show the rail.entites variable rent was empty so I change the statements to add those entities into the step.entities variable sent and everything was there.
-
If I use rail.entities.add_line instead of rent.add_line, I get the error message
Error: #<TypeError: reference to deleted Group>
-
Make the groups in turn [i.e. not at the same time] and add new geometry to their entities immediately after you make them.
See if that helps.
I assume you aren't erasing a group in your broader code ??
-
I tried making and re-makeing the groups but didn't have any success with that either. The entities are being created in a loop which complicates things. I finally gave up on the two group idea. It seems apparent that SU doesn't like dealing with more than one group at a time.
-
Create and hold refs to the groups and their entities collection OUTSIDE the loop.
-
Dan, The groups were created outside the loop originally and the entities added inside the loop. All seemed well since there were no errors shown in the ruby console but, dispite adding entities to the second group, they weren't added to to model only the entities added to the first group. I have tested this independently and it works without a problem so was just something weird going on that particular plugin I guess.
-
You can readily make multiple groups and add stuff to any of their entities.
Even new groups inside new groups!
But if you make a new group in a sub-process and then ignore [i.e. leave it empty] it it will vanish when you leave the sub-process...
So just make these groups 'as you need them' and add stuff to their entities early on so that they then subsist... -
I renamed the groups steps and rails instead of step and rail thinking that Ruby was confused by step since that is a loop method but it wasn't until I added something to the second group,rails, first that all was right with the world at least as far as this plugin is concerned. I had copied the original loop code into the Ruby Web Console and it ran without modification. It would be interesting to know why.
-
Please don't reuse references or confuse them with methods etc - coding is complicated enough as it is
I suggest you prefix new groups with a single meaningful letter, and suffix their entities with 'ents'
So 'sgroup' > 'sents' and 'rgroup' > 'rents' etc.
Then any other reference to 'step' or 'rail' will pass without incident...
And you can easily spot the relationship of s=step and r=rail
For example, I always call my temporary group 'tgroup' and its entities 'tents'.
Advertisement