sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Groups

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 3 Posters 212 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sdmitchS Offline
      sdmitch
      last edited by

      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?

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        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 ??

        TIG

        1 Reply Last reply Reply Quote 0
        • sdmitchS Offline
          sdmitch
          last edited by

          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.

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            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??

            TIG

            1 Reply Last reply Reply Quote 0
            • sdmitchS Offline
              sdmitch
              last edited by

              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.

              Nothing is worthless, it can always be used as a bad example.

              http://sdmitch.blogspot.com/

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                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 ??
                πŸ˜•

                TIG

                1 Reply Last reply Reply Quote 0
                • sdmitchS Offline
                  sdmitch
                  last edited by

                  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.

                  Nothing is worthless, it can always be used as a bad example.

                  http://sdmitch.blogspot.com/

                  1 Reply Last reply Reply Quote 0
                  • sdmitchS Offline
                    sdmitch
                    last edited by

                    If I use rail.entities.add_line instead of rent.add_line, I get the error message

                    Error: #<TypeError: reference to deleted Group>

                    Nothing is worthless, it can always be used as a bad example.

                    http://sdmitch.blogspot.com/

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      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 ??

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • sdmitchS Offline
                        sdmitch
                        last edited by

                        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.

                        Nothing is worthless, it can always be used as a bad example.

                        http://sdmitch.blogspot.com/

                        1 Reply Last reply Reply Quote 0
                        • Dan RathbunD Offline
                          Dan Rathbun
                          last edited by

                          Create and hold refs to the groups and their entities collection OUTSIDE the loop.

                          I'm not here much anymore.

                          1 Reply Last reply Reply Quote 0
                          • sdmitchS Offline
                            sdmitch
                            last edited by

                            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.

                            Nothing is worthless, it can always be used as a bad example.

                            http://sdmitch.blogspot.com/

                            1 Reply Last reply Reply Quote 0
                            • TIGT Offline
                              TIG Moderator
                              last edited by

                              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...

                              πŸ˜’

                              TIG

                              1 Reply Last reply Reply Quote 0
                              • sdmitchS Offline
                                sdmitch
                                last edited by

                                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.

                                Nothing is worthless, it can always be used as a bad example.

                                http://sdmitch.blogspot.com/

                                1 Reply Last reply Reply Quote 0
                                • TIGT Offline
                                  TIG Moderator
                                  last edited by

                                  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'.

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • 1 / 1
                                  • First post
                                    Last post
                                  Buy SketchPlus
                                  Buy SUbD
                                  Buy WrapR
                                  Buy eBook
                                  Buy Modelur
                                  Buy Vertex Tools
                                  Buy SketchCuisine
                                  Buy FormFonts

                                  Advertisement