• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

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.
  • H Offline
    honoluludesktop
    last edited by 30 Oct 2010, 09:52

    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 30 Oct 2010, 11:57

      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 1 Nov 2010, 16:49

        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
        • T Offline
          thomthom
          last edited by 1 Nov 2010, 18:24

          @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
          • H Offline
            honoluludesktop
            last edited by 1 Nov 2010, 18:26

            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
            • H Offline
              honoluludesktop
              last edited by 1 Nov 2010, 19:01

              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
              • C Offline
                Chris Fullmer
                last edited by 1 Nov 2010, 19:39

                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
                • H Offline
                  honoluludesktop
                  last edited by 1 Nov 2010, 20:11

                  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
                  • C Offline
                    Chris Fullmer
                    last edited by 1 Nov 2010, 20:51

                    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
                    • T Offline
                      TIG Moderator
                      last edited by 1 Nov 2010, 21:02

                      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
                      • H Offline
                        honoluludesktop
                        last edited by 1 Nov 2010, 21:56

                        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
                        1 / 1
                        • First post
                          1/11
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement