Thank you for the replies! I managed to fix it on my own, the problem was that a small mistake in the lines 1173 to 1204 caused the creation of the face to fail. I still can't explain why this would affect the other entities object, though. Oh well, now it's all working fine so I better don't bother
@tig said:
You haven't [thankfully] given all of your code...
BUT, if you add a new group into an entities-context, but you leave its own entities empty, then SketchUp's 'garbage-collection' can sometimes delete that empty group [any empty groups/component-definitions are auto-purged by SketchUp's GC], so then later on when you try to add content to its entities you get an error message saying it's no longer valid [deleted]...
So, either use add_cpoint into the new group.entities immediately you create that otherwise empty group to stop the GC [you can erase the cpoint later when there is geometry added], OR more logically, only add that new group immediately before you want to add content into group.entities - thus giving no time for SketchUp's GC to kick in and spot the momentarily empty group...
But I'm not using groups unless I want its content not to touch the existing geometry to avoid automatic "glueing to each other" or however it's called when edges share a vertex and stick to other edges. So, I'm not using groups in empty entities objects, nor am I leaving empty groups anywhere. Thanks anyway for the hint!
@dan rathbun said:
Also do not put a space between the method name and the parenthesis surrounding it's arguments. It is no longer allowed in Ruby 2.x.
Also it is now convention to always use parenthesis around method call argument lists, except for global methods (those defined in module
Kernel
or classObject
, and any added "legally" to them such as those in "sketchp.rb", RubyGems or standard library gems.)
They are said to have "keyword status".
But I'm not leaving spaces when I call method(arg0, arg1, ...), the only times I have spaces is when I initialize a new point or vector on the spot, like method [0, 1, 0], arg1, ... ; but in this case the parenthesis "[]" are used to make an array of values that will be auto-converted to point3d or vector3d by SketchUp, or am I wrong?
I didn't know parenthesis are now required by convention, though. Good to know.
Here is the finished screw, just need to fix one or two small bugs...