Sketchup crashes after I close the project.
Thereās something Sketchup doesnāt like it fixing on opening or saving.
It would be interesting to know which methods are executed in both cases so that I can do like Sketchup directly in my code.
Iām not sure if the code produces the same error on a newer version of SketchUp.
I also tried with SketchUp Make 2017 and the crash occurs when closing or opening a new project.
I even tried your CleanUpĀ³ extension to see if it fixes the faces error produced by my code and the error is beyond repair.
I donāt know if my code is badly written or if it is impossible to convert all the faces of a component into a component?
Iām exploring a lot of avenues because I donāt like to give up when I want to do something in ruby.
I donāt know if itās a quality or a flaw to strive to find solutions because it wastes a lot of time but ended up bringing a lot of learning.
As this is a BugSplat committed by my code, I did not submit the error because the error can come from my method.
I wrote a new method which after transforming the faces of my box into components exports the box to a plugin folder.
This method then removes the instance and the definition from the list to import the previously exported cube.
The goal is to force SketchUp to fix the bug and I get this error message:
Whatever I choose in the options offered, the cube is imported but it is invisible in the project even if it is perfectly displayed in the components and structures window.
In the end, even importing into SketchUp does not correct the error.
FYI: I opened in the latest version of SketchUp. I did notice that it was a v14 file, but as your forum profile indicates v17 I thought perhaps you might have back saved it to 14.
There have been quite a few bug fixes including fixes to the SKP file format post v17.
I just updated my information so that SketchUp 2014 appears.
For the 2014 version, I donāt have a solution:
The load method interrupts the method and sends the error message to force the face correction.
The Import method also interrupts my method because the user has to manually position the box on the Stage. (To my knowledge this method does not allow an import with defined 3D points.)
I imported your āBOX 2ā component, then exploded the extra context that import adds.
I selected the Box instance and ran your test method ā¦
def test
mod = Sketchup.active_model
sel = mod.selection
ents = mod.active_entities
mod.start_operation('Convert faces to components', true)
sel.grep(Sketchup::ComponentInstance).each do |s|
s.definition.entities.grep(Sketchup::Face).each do |f|
grp = ents.add_group(f)
inst = grp.to_component
defn = inst.definition
defn.invalidate_bounds
defn.name = "Component#1"
tr = inst.transformation
pts = tr.origin
s.definition.entities.add_instance(defn, pts)
inst.erase!
end
end
mod.commit_operation
end
And YES ā¦ I also see the funky phantom faces (left behind in the parent definitionās entities) that are somehow still connected to the child face component instances. Weirdly, 3 of the phantom faces are in the same position as their ācloneā, but 3 are directly across the cube from their clone (given a stacked face scenario. As there are textures on both sides we see z-fighting as the view is orbited.)
Well, see faces are special in that they also have vertices and edges attached that can be (and in this situation are) shared with other faces.
So trying to rip out faces from an entities context and move them into a group may not be the best paradigm.
I would say instead, (one by one) create a new component definition, and use the vertex positions of the existing faces to recreate the face in the new definition(s) also copying properties like material texture, etc. Then erase the old faces and replace with a new face component instance in the same location.
Sorry Dan for bouncing off another issue so quickly while the basic topic is resolved!
Finally I found out how to recover the UV from a face with more than 4 vertices to apply them to any other face.