A quick one…not really tested, but it looks like is O.K
No guarantee! Use your own risk!
Backup, Backup…
Follow the animation:
- Select the desired components, groups or everything (Ctrl+A)
- Open Ruby Console
- Copy-Paste the code from below into Ruby Console
- Hit Enter (Return)
The axis origin of selected components, groups will set to its bound left front bottom corner. Including all nested…
You can Undo it.
module Dezmo
module Reset_Axes
extend self
def transform_obj_origin(obj, point)
tr = Geom::Transformation.new( point )
obj.entities.transform_entities( tr.inverse, obj.entities.to_a )
obj.instances.each { |instance|
instance.transformation = instance.transformation * tr
@count_inst += 1
}
end
def set_origin(definitions)
definitions.each{|obj|
point = obj.bounds.corner(0)
transform_obj_origin(obj, point)
}
end
def get_defs(instance)
@definitions<<instance.definition
classify(instance.definition.entities).each{|inst|
get_defs(inst)
}
true
end
def classify(ents)
componets = ents.grep(Sketchup::ComponentInstance)
groups = ents.grep(Sketchup::Group)
componets + groups
end
def run
model = Sketchup.active_model
sel = model.selection
@definitions = []
@count_inst = 0
if !sel.empty?
classify(sel).each{|instance|
get_defs(instance)
}
@definitions.uniq!
model.start_operation('Dezmo:Reset_Axes', true)
set_origin(@definitions)
model.commit_operation
puts "Axes reset to bound left front bottom corner:"
puts "Definitions:#{@definitions.size} Instances:#{@count_inst}"
end
end
end
end
Dezmo::Reset_Axes.run
Some bits from Thomas Thomassen ( thomas[at]thomthom[dot]net). Thanks.