sketchucation logo sketchucation
    • Login
    1. Home
    2. gkd720
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    G
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Groups 1

    gkd720

    @gkd720

    0
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    gkd720 Unfollow Follow
    registered-users

    Latest posts made by gkd720

    • RE: Trouble adding entity to component definition

      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.

      posted in Developers' Forum
      G
      gkd720
    • 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:in entities' 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)>'

      posted in Developers' Forum
      G
      gkd720