Duplicate "edit component" with api methods.
-
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?
![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.")
-
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
-
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 -
@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.
-
OK, Does Ruby, or the api have a method that returns control to the user for a number of user actions thereafter proceeding?
-
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?
-
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.
-
OK, how about with
the_entities = a_component.explode
, if I reverse a face of one ofthe_entities
, won't the revised entity remain inthe_entities
? Or, not?Hmm...I also have to be careful not to
the_entities.each
while I edit an entity inthe_entities
. -
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.
-
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 thegroup.entities
...
No clashes - no mess -
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.
Advertisement