sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Duplicate "edit component" with api methods.

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 6 Posters 419 Views 6 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.
    • honoluludesktopH Offline
      honoluludesktop
      last edited by

      The first image presents a model built out of several components. The second and third images show a couple of the model's components in their "edit component" mode. Does the sketchup api provide methods that can be used to duplicate this condition?


      Model's component's bounding boxes.


      ![Roof component's bounding box in "edit component" mode.](/uploads/imported_attachments/0HWE_Temp01.jpg "Roof component's bounding box in "edit component" mode.")


      ![Wall component's bounding box in "edit component" mode.](/uploads/imported_attachments/bqvX_Temp02.jpg "Wall component's bounding box in "edit component" mode.")

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        No.

        It's usually not necessary for SketchUp to have a particular context open for editing for script use. The script can access any Entities collection independent of the current editing context.

        You can close the current editing context using model.close_active

        Hi

        1 Reply Last reply Reply Quote 0
        • K Offline
          kwalkerman
          last edited by

          Jim,

          there are some things that can't be done from Ruby without changing the work context. This includes creating a sub-group out of existing components.

          ...

          If you want to return control to the user, I think you would have your code do some stuff, then use an observer to wait for the user to complete some set of actions, OR have the user do a whole bunch of stuff, then click a button when complete, and let the code finish.

          --
          Karen

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @kwalkerman said:

            This includes creating a sub-group out of existing components.

            Create a new group, insert new instances of your existing components - ensuring transformations adjust to their parent. Then erase the old ones.

            Thomas Thomassen โ€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • honoluludesktopH Offline
              honoluludesktop
              last edited by

              OK, Does Ruby, or the api have a method that returns control to the user for a number of user actions thereafter proceeding?

              1 Reply Last reply Reply Quote 0
              • honoluludesktopH Offline
                honoluludesktop
                last edited by

                The application I am working on (reverse_backfaces) may change each definition's instance (is that how its referred to?) in a different way, so how about taking one group/component at a time, explode, run reverse_backface, then make new instance? Do you see any problems?

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  Yes! If the exploded geometry merges with existing geometry you can have problems.

                  You would need to first make sure that there is no loose geometry in the model so that upon exploding, there is nothing loose it can merge with.

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

                  1 Reply Last reply Reply Quote 0
                  • honoluludesktopH Offline
                    honoluludesktop
                    last edited by

                    OK, how about with the_entities = a_component.explode, if I reverse a face of one of the_entities, won't the revised entity remain in the_entities? Or, not?

                    Hmm...I also have to be careful not to the_entities.each while I edit an entity in the_entities.

                    1 Reply Last reply Reply Quote 0
                    • Chris FullmerC Offline
                      Chris Fullmer
                      last edited by

                      What happens is you can have an edge int he component that overlaps an edge outside the component. so you explode it and store an arraay of all entities inside of it. But that edge object might get deleted if its replaced by the one that was already loose. So then your array will contain a reference to a deleted object. Which trips it up. A single edge is easy enough to overcome. But wait until you have entire faces that get overwriteen with multiple edges. It will get ugly I think.

                      Lately you've been tan, suspicious for the winter.
                      All my Plugins I've written

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

                        Make an empty group - group=entities.add_group().
                        Get a transformation...
                        Then add an instance of the component's definition - inst=group.entities.add_instance(definition, transformation)
                        Explode the instance - inst.explode.
                        You have its contents in the group.entities...
                        No clashes - no mess ๐Ÿ˜‰

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • honoluludesktopH Offline
                          honoluludesktop
                          last edited by

                          Thanks, fellows. Sometimes it's not as simple as I think, then after I'm done, its simpler then I think:-)

                          Tig, That's neat, didn't know I could do that. The reverse face application requires the faces to be in Sketchup.active_model.entities. The faces are picked in terms of it's pixel location on the monitor.

                          Maybe I first have to group the loose entities, then process all the groups, and components one at a time.

                          Sometimes I write this stuff, just to see if I can. It doesn't take that much more work to open each component manually, and run the plugin Reverse_Backfaces each time.

                          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