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

    BigAl

    @BigAl

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

    BigAl Unfollow Follow
    registered-users

    Latest posts made by BigAl

    • RE: Reload component script - anyone have one

      Thanks Dan,
      I hadn't noticed that behaviour before. Initially being only interested in getting a couple of components into the model it wasn't an issue and I would always have the proxies in the model to check that the swap worked ok.
      Looking at this again it looks like the components are all loaded into the file in turn. When I repeat ThomThom's text as below only Comp4 gets deleted if not required to replace comp3 (being the last to be loaded). Comp2 get left behind.

      newDef = model.definitions.load("J:/Comp2.skp")
      oldDef = model.definitions['Comp1']
      oldDef.instances.each{|old_inst|old_inst.definition=newDef
      t = old_inst.transformation
      ents = old_inst.parent.entities
      ents.add_instance(newDef, t)
      old_inst.erase!
      }
      newDef = model.definitions.load("J:/Comp4.skp")
      oldDef = model.definitions['Comp3']
      oldDef.instances.each{|old_inst|old_inst.definition=newDef
      t = old_inst.transformation
      ents = old_inst.parent.entities
      ents.add_instance(newDef, t)
      old_inst.erase!
      }

      posted in Developers' Forum
      B
      BigAl
    • RE: Reload component script - anyone have one

      I'm using Thom Thom's lines of code below to batch replace a series of proxy components with hi-res versions.
      newDef = model.definitions.load(path_to_new_component)
      oldDef = model.definitions['definitionName']
      oldDef.instances.each { |old_inst|
      t = old_inst.transformation
      ents = old_inst.parent.entities
      ents.add_instance(newDef, t)
      old_inst.erase!
      }
      To speed this process up I'd like to add a conditional test before this code such that the code to replace Component A with Component B only runs if Component A already exists within the model. Otherwise skip to the next component in the list.
      Does such code or similar already exist somewhere?
      Any help greatly appreciated.

      posted in Developers' Forum
      B
      BigAl