sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Importing don't have to bring inherit of lenz

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 1 Posters 283 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • kimpastroK Offline
      kimpastro
      last edited by

      Hi again everyone.

      I thought that had finished my import tool... but.. found a "bug". I have a situation, as follows:

      *Note: Not sure about the name of the things yet.. When I say entity I mean a rack, shelf, desk, table or anything that is a full mounted object.

      When create an entity with LenZ 700mm, put another entity on your side with LenZ 400mm, then export all, everything is save with correct attributes. But, when I import, the second entity assume LenZ = 700mm. The both assume the same height.

      But if I change the order of put entities (400mm first, then 700mm after), when Import, everything occurs as it meant to be, with the respective LenZ.

      Here's my import code:

      
        loaded_module = Sketchup.active_model.definitions.load_from_url uri
      
        moduli['attributes'].each do |key, value|
          my_load_texture_method
          loaded_module.set_attribute 'dynamic_attributes', key, method_to_inches_mm_etc(value)
        end
        
        my_method_to_set pos_x, pos_y, pos_z and rot_z
              
        t_rotation = Geom;;Transformation.rotation(ORIGIN, Z_AXIS, rot_z.degrees)
        point = Geom;;Point3d.new pos_x, pos_y, pos_z
        t_position = Geom;;Transformation.new point
      
        entities = Sketchup.active_model.active_entities     
        instance = entities.add_instance(loaded_module, t_rotation)
        instance.transform!(t_position)
      
        $dc_observers.get_latest_class.redraw_with_undo instance
      
      

      What I could observe is that, SU execute a rotation in ORIGIN, then apply texture and high(at this point he puts the wrong LenZ attribute), then move to his position.

      1 Reply Last reply Reply Quote 0
      • kimpastroK Offline
        kimpastro
        last edited by

        well.. that's embarrassing...

        actually the "problem" is that i had overloaded "onElementAdded" method.. and put:

        
        @service.recent_inherit! entity
        
        

        now i send a new attribute, then it becomes:

        
        if entity.definition.get_attribute 'dynamic_attributes', 'imported_entity'
          @service.recent_inherit! entity
        end
        
        

        sorry about that and thanks for your time.

        cheers.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement