Wow. Thanks TIG and sdmitch, that works!
But why might that be? I would think that making a new component definition without yet any entities would not be that fragile or incomplete. Is there any documentation that states this, or suggests this? Why isn't this like declaring a variable but not initializing it? It also would have helped if the error message indicated which component definition it didn't like. Is this a ruby thing or a Sketchup thing? Thanks.
G
Latest posts made by gkd720
-
RE: Trouble adding entity to component definition
-
Trouble adding entity to component definition
I'm trying to add an instance of a component definition as an entity in another component definition, but I'm getting an error. I searched here but didn't find anything that helped yet. Any thoughts or guidance on how to diagnose and fix? Code and error below, with error line marked. Thanks.
def self.create_component_definition_piece(width, height, depth, angle) @componentDefinitionPiece=@definitions.add "Piece" ptLL=[0,0,0] ptLR=[width,0,0] ptUR=[width,0,height] ptUL=[0,0,height] new_face = @componentDefinitionPiece.entities.add_face ptLL, ptLR, ptUR, ptUL if new_face.normal == [0,-1,0] new_face.pushpull depth else new_face.pushpull -depth end end def self.create_component_definition_laddershelves() @componentDefinitionLadderShelves=@definitions.add "LadderShelves" self.create_component_definition_piece(2.5,48,0.75,0) @componentDefinitionLadderShelves.entities.add_instance(@componentDefinitionPiece,@transform000) <<<<< Error on this line. end # Draw the ladder shelves self.create_component_definition_laddershelves() transform=Geom;;Transformation.new([0,0,0]) rotateAndTransform=transform * Geom;;Transformation.rotation([0,0,0],[0,1,0],0) @entities.add_instance(@componentDefinitionLadderShelves,rotateAndTransform) # puts "Number of entities in LadderShelves=",@componentDefinitionLadderShelves.entities.count
Error:
Error: #<TypeError: reference to deleted ComponentDefinition>
C:/Users/gkd/SketchupRubyScripts/ladderShelves2.rb:86:inentities' C:/Users/gkd/SketchupRubyScripts/ladderShelves2.rb:86:in
create_component_definition_laddershelves'
C:/Users/gkd/SketchupRubyScripts/ladderShelves2.rb:99:in<module:LadderShelves>' C:/Users/gkd/SketchupRubyScripts/ladderShelves2.rb:5:in
<top (required)>'