In the attached file there is a component which contains a subcomponent and within this is only an edge.
When getting the subcomponent by find_entity_by_id (entity.guid) Sketchup is returning a different object with a different scale.
I already solved the issue by directly storing the entity in the list but I wonder what is causing this problem here.
Here is a simplified script to reproduce the issue:
def print_details(entity)
msg = “\n===============================\n”
msg += “#{entity}”
msg += “\nTYPE: #{entity.class}”
msg += “\nGUID: #{entity.guid}”
msg += “\nEntityID: #{entity.entityID}”
msg += “\nPERS ID: #{entity.persistent_id}\n”
msg += (“\nDef name: " + entity.definition.name + “\n”)
msg += “Matrix: #{entity.transformation.to_a.join(”,\n”)}\n"
puts msg
end
def id_test()
model = Sketchup::active_model
ent_instance = nil
model.entities.each do |entity|
if entity.is_a? Sketchup::ComponentInstance
entity.definition.entities.each do |sub_ent|
if sub_ent.is_a? Sketchup::ComponentInstance
ent_instance = sub_ent
break
end
end
end
end
print_details(ent_instance)
ent_tmp = Sketchup.active_model.find_entity_by_id(ent_instance.guid)
print_details(ent_tmp)
end
OUTPUT:
#Sketchup::ComponentInstance:0x0000028d81d68948
TYPE: Sketchup::ComponentInstance
GUID: 3kG1Q74FTAjRALzO029s2s
EntityID: 19876
PERS ID: 860278
Def name: centerline
Matrix: 1.0,
0.0,
7.048027557333175e-29,
0.0,
0.0,
1.0,
0.0,
0.0,
4.674090022094917e-28,
0.0,
30.617283950617278,
0.0,
1.830708661417323,
1.8307086614173222,
0.0,
1.0
===============================
#Sketchup::ComponentInstance:0x0000028d81b39320
TYPE: Sketchup::ComponentInstance
GUID: 3kG1Q74FTAjRALzO029s2s
EntityID: 17391
PERS ID: 859635
Def name: centerline
Matrix: 1.0,
0.0,
1.1100643402799756e-28,
0.0,
0.0,
1.0,
0.0,
0.0,
4.674090022094918e-28,
0.0,
48.22222222222222,
0.0,
1.830708661417323,
1.8307086614173222,
-6.310887241768095e-30,
1.0
=> nil
get_by_guid_issue.skp (634.1 KB)