Empty groups get deleted?!
-
Do you have a code sample that shows this?
I highly doubt we have to insert a DrawingElement (if such a hack is necessary, then that behavior is a bug in SketchUp). I wonder why the group is garbage-collected, maybe we have to check again what kind of variable is used. -
Maybe the code is between a start and commit operation? Doesent Sketchup garbage collect then?
I don't think this is unusual, seen several hacks around conserning this. But they where rather old and I can't remember where I saw it. Maybe there's a better fix as Aerilius says... -
SketchUp will remove empty definitions from the model. Even definitions of ComponentInstances. Think it usually happens on commit - but there might be other triggers as well. Always seen this as part of the automatic cleanup.
-
@thomthom said:
SketchUp will remove empty definitions from the model. Even definitions of ComponentInstances.
definitions ??
I thought it was empty instances that were GC'd ?
-
It's a know way of removing an unused definition from the Component Browser without recourse to
definitions.purge_unused
, which of course might also remove components that the users has not yet got inserted, but would like to keep for later...
definition.entities.clear!
within a start/commit block will remove the definition.
Similarlygroup.entities.clear!
, although in that casegroup.erase!
will work BUT can can fall foul of some new BIMish ill-advisedentities-observers
... -
@dan rathbun said:
@thomthom said:
SketchUp will remove empty definitions from the model. Even definitions of ComponentInstances.
definitions ??
I thought it was empty instances that were GC'd ?
Instances are just references to definitions. And it's not garbage collection - if it had been then they would not have disappeared when you have reference to them. It's SketchUp cleaning up.
-
-
No. Back on the topic of the OP,... he was asking about group instances that get GC'd before he can use them, because they are empty.
-
Andreas as the first one to mention the GC. The OP only said the group was deleted - which is what happens to definitions when they are empty.
@niccah said:
okay, I insert now a small edge and hide the full group... when the user insert his first objects, I delete this line and make the group again visible...
Why not create the group only right before you need to add something to it?
-
At first! Thank you very much again for all your comments! I'm always learning a lot, "listening" to your discussions!
@thomthom said:
Why not create the group only right before you need to add something to it?
Following idea:
- the user can create a "project" => so, in my code, I create at first an empty group
- all the projects will be listed in a table
- now, the user can add to a single project some "parts"
So, my current problem:
- user create a project, and then he / her starts to draw the "part" => during drawing, the empty project group will be removed by GC...
My hidden line in the groups works perfect! I know, it not realy smart, but...
-
That's where I ask: why do you need to create the group in advance before you actually make use of it? Seems to me it complicates things a little when you try to fight SketchUp for the group - slapping its wrist using hidden temp geometry.
-
@thomthom said:
That's where I ask: why do you need to create the group in advance before you actually make use of it? Seems to me it complicates things a little when you try to fight SketchUp for the group - slapping its wrist using hidden temp geometry.
Okay, let me "answer" with a new question - what can I do else? The user would like to create a project => so, somewhere I have to save this information about the projects (name, options, etc, ..). And the user could create a project and close Sketchup => so, the information about the new project has to be saved somewhere "for ever".
I realy agree, my way is realy complicated...
-
OK major problem with your logic.
In Ruby you can cause the current editing context (the "project" group,) to be exited, via:
model#close_active()BUT there is no API method to enter INTO an editing context. (You cannot cause the "project" group to become active for edit.)
-
@niccah said:
The user would like to create a project => so, somewhere I have to save this information about the projects (name, options, etc, ..). And the user could create a project and close Sketchup => so, the information about the new project has to be saved somewhere "for ever".
Use an attribute dictionary to attach information to the model. It will stay with it after the model is closed and opened.
Single Dictionatires
http://www.sketchup.com/intl/en/developer/docs/ourdoc/attributedictionaryCollections of multiple dictionaries
http://www.sketchup.com/intl/en/developer/docs/ourdoc/attributedictionariesThis is a much more stable way to maintain data in the model from session to session.
Chris
Advertisement