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

    masp

    @masp

    10
    Reputation
    1
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    masp Unfollow Follow
    registered-users

    Latest posts made by masp

    • RE: [SOLVED]Reloading Component via DefinitionsList.load Problem

      Thanks for the quick reply! I think I've done everything right, but I only get a new definition (loaded) when I use the write-to-dev-null trick (but it's painfully slow!). When I use the add_cpoint() or add_group() trick my SKP file is ignored and I get the same GUID back. Here's my full script, if you don't mind taking a look:

      
      require "sketchup.rb"
      
      module RefreshComponent
        def self.force_reload_component_definition!(model, definition)
          definition_path = definition.path
          definition_name = definition.name
          definition.name = definition.name + rand.to_s
      ##    definition.entities.add_cpoint(ORIGIN)     ## <== this causes GUIDs to match (fail)
          definition.save_as("/dev/null")              ## <== this causes new definition load (success)
          reloaded_definition = model.definitions.load(definition_path)
          puts "Old GUID; " + definition.guid
          puts "New GUID; " + reloaded_definition.guid
          reloaded_definition
        end
      
        def self.reconnect_component_instances!(model, old_definition, new_definition)
          model.start_operation("Remap instances")
          old_definition.instances.each { |instance| instance.definition = new_definition }
          model.commit_operation
        end
      
        def self.delete_component_definition!(model, definition)
          model.start_operation("Delete Definition")
          definition.entities.erase_entities(definition.entities.to_a)
          model.commit_operation
        end
      
        def self.refresh_component(model, definition)
          model.start_operation("Reload current component definition", true)
          reloaded_definition = force_reload_component_definition!(model, definition)
          reconnect_component_instances!(model, definition, reloaded_definition)
          delete_component_definition!(model, definition)
          model.commit_operation
        end
      
        def self.start
          model = Sketchup.active_model
          model.start_operation("Reload component definitions from file", true)
          model
            .selection
            .select { |entity| entity.is_a?(Sketchup;;ComponentInstance) }
            .map { |instance| instance.definition }
            .uniq
            .each { |definition| refresh_component(model, definition) }
          model.commit_operation
        end
      end 
      
      unless file_loaded?("refresh_component.rb")
          UI.add_context_menu_handler do |context_menu|
            context_menu.add_item("Reload Current Component Definition") {
              RefreshComponent.start
            }
          end
         file_loaded("refresh_component.rb")
      end
      
      
      posted in Developers' Forum
      M
      masp
    • RE: [SOLVED]Reloading Component via DefinitionsList.load Problem

      This is a very useful thread: I'm trying to apply this workaround (add_cpoint) but I'm still getting an identical GUID. Would you mind posting the actual solution, so there's an explicit example I can refer to? For what it's worth, this is my attempt (I'm trying to automate re-loading certain components from their .skp files):

      
          model = Sketchup.active_model
          selection_set = model.selection
          selection = selection_set[0]
          definition = selection.definition
          definition.entities.add_cpoint(ORIGIN)   # not sure if I'm applying this to the correct entity
          new_definition = model.definitions.load(definition.path)
          puts "Old GUID; " + definition.guid
          puts "New GUID; " + new_definition.guid
      
      

      I'm not sure if I'm applying add_cpoint() to the right entity; also I'm not sure whether creating an empty group is a better workaround as suggested in the thread, or how to do that!).

      Finally, this is how I hope to replace the instances (based on someone else's example):

      
            definition.instances.each { |instance|
              instance.parent.entities.add_instance(new_definition, instance.transformation)
              instance.erase!
            }
      
      

      Many thanks, and hugely appreciated!

      Mike

      posted in Developers' Forum
      M
      masp
    • RE: Cutting components leave holes after layers disabled

      I've verified that this bug was not present in Sketchup Free 7.1.6859 . I think it may have been introduced in Sketchup Free 8 (but haven't verified that). It's certainly been around for several years, surprisingly.

      Mike

      posted in SketchUp Bug Reporting
      M
      masp
    • Cutting components leave holes after layers disabled

      I've actually noticed this bug for several years: if I create a surface inside a group, then cut a hole in that surface (inside the group) with a (cutting) component, and then put that component onto its own layer, and then finally turn off that layer, the component will disappear, but the hole that it cuts in the surface will remain. To get rid of the hole I have to select the surface inside the group. It's quite annoying, as I like to use component (on their own layers) to model potential locations for doors and windows, and use layers (via scenes) to switch between them. But as soon as I put the surface inside groups I get these annoying ghost holes left behind by each component that is no longer visible because its layer has been turned off.

      Steps to reproduce:

      1. create a surface
      2. create a group containing that surface
      3. click into that group
      4. cut a hole in the surface with a component
      5. assign the component to a new layer
      6. leave the group
      7. turn off the component's layer
      8. observe an annoying hole where the component used to be.
      9. click into the group again
      10. observe that the hole has disappeared.

      Note: this only happens when the surface being cut is within a group (or component) of its own.

      posted in SketchUp Bug Reporting sketchup
      M
      masp
    • RE: SketchUp 7.0 ?

      I found 7.1.6859 (free) for mac (based on Aerilius' post):

      http://dl.google.com/sketchup/gsu7/FM-2-1-6859-EN.dmg

      (what a relief: I've been trying to find it for ages!)

      pro would be similarly:

      http://dl.google.com/sketchup/gsu7/PM-2-1-6859-EN.dmg

      Mike

      posted in Developers' Forum
      M
      masp