Making groups uniques leads to dirty things


#1

Hi guys,

I had a look around on Google and Sketchup Community first but I couldn’t find any informations regarding my issue, so I’m posting here hoping that someone will have a kind of clue for me :wink:

For production pipeline reasons I need to freeze the model groups transformations but, because of multiple copy/paste tasked performed by the design engineers, I’m having multiples groups that are depending on the same definition which gets everything upside down when freezing the transforms.

That leads me to make groups uniques before moving on to transformations freeze which works pretty well BUT unfortunatly dirty things occurs. After making groups uniques, if I run a validity check I get some errors that weren’t there before. Here is an exemple :

Point reference 2 for CDimensionLinear (820208) is not valid
Entity CDimensionLinear (820208) should be erased - done
Point reference 2 for CDimensionLinear (820209) is not valid
Entity CDimensionLinear (820209) should be erased - done
Point reference 2 for CDimensionLinear (820222) is not valid
Entity CDimensionLinear (820222) should be erased - done
Point reference 2 for CDimensionLinear (820228) is not valid
Entity CDimensionLinear (820228) should be erased - done

Sor here are my questions :

  1. Can some tells me what are CDimensionLinear and CText items ?
  2. Why do they have a non persistant entityID (each time I’m reopening the file the ID is different) ?
  3. How can I have a validity check performed without fixing problems to get the entityID and investigate what is going wrong before it would be deleted ?

Thanks for your appreciated help :wink:


Making group unique leads to dimension corruption
#2

Hi again,

I found a way to track down the modifications made by the validity check tool and I’m now sure that some Sketchup::DimensionLinear or Sketchup::Text are affected and been deleted.

Does anyone know why making some groups unique may end with corrupted Sketchup::DimensionLinear or Sketchup::Text ? Is there a workaround here ?

Thanks


#3

Are the dimension and text objects wholly inside (ie, a member of) the group entities before making them unique ?

… or are they part of the group’s parent’s entities collection, and only the text’s arrow point, or one end of the dimension line, is referencing a vertex inside the group before the unique operation ?


#4

Hi Dan,

Thanks for your feedback,
All the concerned entities are hold by the model entities collection :
[341268, 341270, 341271, 341272, 341278].each{|current_id| puts Sketchup.active_model.find_entity_by_id(current_id).parent} Sketchup::Model:0x000000528ee368 Sketchup::Model:0x000000528ee368 Sketchup::Model:0x000000528ee368 Sketchup::Model:0x000000528ee368 Sketchup::Model:0x000000528ee368

All these dimensions and texts are bounds at least on one side to an entity that isn’t unique.

So your comment and my thought are converging toward on the fact (as SU is able to dynamically resize the dimension when you move an entity) that a dmiension/text is linked by some way to the entities/groups it’s bound to.

Do you have some informations regarding that ? I couldn’t find anything in the API to be able to track down a link between a dimension and an entity.

Thanks again :wink:


#5

Here are 2 example files that highlight this problem :
1 | One with the groups duplicated using Copy/Past (named CP) or Dragged (named DRAG) sharing definitions.
example_non_unique.skp (855.7 KB)

Sketchup.active_model.entities.each{|current| puts "#{current.name.upcase} | #{current.definition}" if current.class.to_s == "Sketchup::Group"} ITEM#1 | #<Sketchup::ComponentDefinition:0x000000524baa08> ITEM#CP1 | #<Sketchup::ComponentDefinition:0x000000524ba8a0> ITEM#DRAG1 | #<Sketchup::ComponentDefinition:0x000000524baa08> ITEM#DRAG2 | #<Sketchup::ComponentDefinition:0x000000524baa08> ITEM#DRAG3 | #<Sketchup::ComponentDefinition:0x000000524baa08> ITEM#CP3 | #<Sketchup::ComponentDefinition:0x000000524ba8a0> ITEM#CP2 | #<Sketchup::ComponentDefinition:0x000000524ba8a0>

.

2 | One with the same content but with each group unique implying broken links between groups and dimentions (run the validity check to see it).
example_unique.skp (859.0 KB)

Sketchup.active_model.entities.each{|current| puts "#{current.name.upcase} | #{current.definition}" if current.class.to_s == "Sketchup::Group"} ITEM#1 | #<Sketchup::ComponentDefinition:0x000000516251c8> ITEM#CP1 | #<Sketchup::ComponentDefinition:0x00000051624b38> ITEM#DRAG1 | #<Sketchup::ComponentDefinition:0x000000516252b8> ITEM#DRAG2 | #<Sketchup::ComponentDefinition:0x00000051625470> ITEM#DRAG3 | #<Sketchup::ComponentDefinition:0x00000051624908> ITEM#CP3 | #<Sketchup::ComponentDefinition:0x00000051624f48> ITEM#CP2 | #<Sketchup::ComponentDefinition:0x00000051624688>

The conclusion is that dimensions get dirty when making groups uniques when they are bound to entities that share the same definition. The only thing I’m thinking of right now is detecting an rebuilding the dimensions.

Does anyone think of something else ?


#6

@milmandre , I tried exploding the group and then regrouping to make it unique.

I am using @ChrisFullmer code from http://sketchucation.com/forums/viewtopic.php?f=180&t=53894#p488800 and it seems to work.

def rg(g)

a = g.explode

random_classes = []
ents_to_regroup = []

a.each do |e|
random_classes << e.class
end

random_classes.uniq!

random_classes.each do |e|
single_class_objects = a.grep(e)
if single_class_objects[0].respond_to?(:bounds)
then ents_to_regroup << single_class_objects
end
end

ents_to_regroup.flatten!
Sketchup.active_model.entities.add_group(ents_to_regroup)
end

groups = Sketchup.active_model.entities.grep(Sketchup::Group)

groups.each do |g| rg(g) end


#7

Hi Yogesh,

Thanks for the tip, this is a nice approche but unfortunatelly a destructive one. That well works on a simple model like the one I posted as an exemple, but this is more tricky with real models and a global production pipeline behind it.

I’m always unsure of pipeline sides effects when using destructive solutions because everything setted up need to be restore exactly the same (parent, name, attributes dictionaries, materials and so on). So I’ll keep your solution as a backup solution it if I can’t find an another way to makes unique my groups.

But again thanks for this really efficient proposal :wink: