[Plugin] Component Comparison

[Plugin] Component Comparison

Postby thomthom » Sun Aug 15, 2010 2:55 pm

Experimental Alpha Version
Use with own risk - backup/save before using!

This plugin is in very early experimental development. Lots of debug menus.

Overview
Compares components for geometric similarities - replaces the instances of similar definitions to use the same definition.

Access
Plugins -> Similar Objects

Usage
Select nothing to compare all definitions.

Select a bunch of instances to compare only their definitions against the rest.

Caveats
Comparison is currently strictly geometric - material and layer comparison is currently not done. (Event face direction or position is not compared.)

With my test models (one attached) objects that appeared similar where not within SU's tolerance of 0.001 inch. I added a debug menu to adjust it. In the attached test model I had to set the tolerance to 0.002 to be able to make it replace all.

I would appreciate it someone with better know-how of float point tolerances could comment on the code. If there are places where I can reduce precision loss in my code. (it might be that the geometry from Revit simply has too much deviance - but I'm not sure.)

NOTE: In the test model, the third window from the top left looks similar to some of the others, but it doesn't have the same number of faces. So this window should be ignored. It simply IS different.

NOTE: Inspect Comparison (Debug) will colour some of the edges of the definitions you inspect.

Todo
  • Recursive comparison of sub-instances
  • Support mirrored objects
  • Support groups - Done!
  • Option to compare face normals - Done!
  • Option to compare entity visibility
  • Option to compare layers - Done!
  • Option to compare materials - Done!
  • Option to compare UV mapping

Download



Footprint
<Sketchup>/Plugins/
+-
tt_cc.rb

0
Last edited by thomthom on Fri Nov 29, 2013 12:24 am, edited 1 time in total.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.1.0a) — 15 August 2010

Postby plot-paris » Sun Aug 15, 2010 9:11 pm

brilliant, Thomthom!
I will try it out as soon as possible. have been waiting for a long time for this.
eventually an option to even take the scaling of components into account would be perfect.
and the next step might even enable group comparisson...
0
User avatar
plot-paris 
 

Re: [Plugin] Component Comparison (0.1.0a) — 15 August 2010

Postby plot-paris » Sun Aug 15, 2010 10:22 pm

alright, I got to playing with the plugin for a bit. first of all, let me say that it worked brilliantly, never making a wrong decision (admittedly on rather simple test components with no more than a few dozen edges). I was also impressed with it's speed. even the comparisson of a selection of almost 4.000 copies of 6 equal but unique components took less than a third of a second.

I found out some odd behaviors though...


Once there are nested components in a model, there are two bugs I repeatedly encounter:

    When nothing is selected (therefore the plugin is supposed to inspect all entities) the plugin only changes the components within other components (nested ones). Single components are being ignored.
    If you do select them however, components will be replaced, no matter if they are single entities or nested within other components (even in 2nd or 3rd level). Note however, that it is always only the innermost components that are being inspected.
    The report message, stating how many definitions have been replaced and how long that took, isn’t showing up.
    As soon as I delete the nested components, single components are being changed again, as expected, even while not being selected. Also does the report message show up again.

I also observed, that components, containing other grouped objects (whether groups or components), will not be changed, even if the objects they contain are equal. This might be a goal for future versions of this plugin, don't you think? ;)

all in all, Thomthom, this is a great start for a plugin that many people (especially those who import objects, e.g. trees) have been waiting for - one that will enable us to save huge ammounts of time and produce far cleaner models. well done, mate!
0
User avatar
plot-paris 
 

Re: [Plugin] Component Comparison (0.1.0a) — 15 August 2010

Postby thomthom » Mon Aug 16, 2010 6:54 am

Ah, yea - I've not tested nested groups. And after posting the plugin I'd already found some bugs in the way it iterated the selection.

It does not matter so much how many instance you have, it's the definitions that are processed. So if your 4000 copies where unique I'd spend some time processing.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.1.0a) — 15 August 2010

Postby Chris Fullmer » Mon Aug 16, 2010 6:02 pm

plot-paris wrote: it worked brilliantly, never making a wrong decision (admittedly on rather simple test components with no more than a few dozen edges).


Actually, the fewer the faces and edges, the harder it can be to determine if a component is similar or not! Its easy to determine if two very detailed components - maybe like high poly faces - are different than each other. But it can be VERY tricky to determine if two boxes are supposed to be the same root component or not.

So its encouraging to hear it worked on fairly simple components in my mind!

Way cool Thom!

Chris
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: [Plugin] Component Comparison (0.1.0a) — 15 August 2010

Postby thomthom » Mon Aug 16, 2010 9:26 pm

The posted version will be confused by two boxes with the same dimmension, but where one lack a face. The one I got now compares these - so even that isn't any problem.
What I do seem to have problems with is face normals - checking if the normals are facing the same direction. I think I'm running into some precision problems...
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.1.0a) — 15 August 2010

Postby autarchos » Tue Aug 17, 2010 5:20 am

well, great news. i imported an xfrog 3ds young birch tree and after quite some time spent converting raw geometry to components, i have made every leaf the same component. your plugin worked extremely fast despite there being about 8000 leaf component instances. for whatever reason, it missed several hundred unique leaf comps, but identifying them in outliner and running the comp comparison in two smaller batches resolved the issue.

i was also unable to run the comparison on leaf components nested in the 'sub-groups' that are default with xfrog trees. exploding the groups and using free comps, worked as expected though.

tried to convert branch and root components to the same, but no luck. the branches appear visually to have the same structure, but even with a tolerance of 500" no luck. they are quite complex meshes as you know.

pre-comparison SKP file was 102Mb. post-comparison SKP file is 45.7Mb, 8048 comp instances, 11 comp definitions. amazing!

THANK YOU, thomthom.
0

autarchos 
 

Re: [Plugin] Component Comparison (0.1.0a) — 15 August 2010

Postby thomthom » Tue Aug 17, 2010 9:22 am

autarchos wrote:for whatever reason, it missed several hundred unique leaf comps, but identifying them in outliner and running the comp comparison in two smaller batches resolved the issue.

That reason is me. A bug. ;) well, at least this related to one of the bugs I found.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Wed Sep 01, 2010 8:20 pm

A small update - 0.2.0a.
It still doesn't handle sub-groups/components. Coming soon.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby guaucorreo » Thu Sep 02, 2010 8:57 am

great great plugin
questions...
i work with xfrog trees, when i insert the tree in sketchup an i explode it, the leaves are individual faces, but not groups or components.
its posible to use your plugin in this case, how???
thanks an sorry for my english
greetings from spain
0

guaucorreo 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Thu Sep 02, 2010 9:06 am

You manage to explode X-Frog trees??
When I try that SU sit sinks into a bog of eternal unresponsiveness and I never had the patience to wait for it to complete.

You would need each leaf to be a group or component. Chris got a plugin that groups loose geometry: viewtopic.php?t=16154
However, when I tried that on a X-Frog tree it took ages - and again I could not bother to wait for it to complete. You might have more luck than I though.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby guaucorreo » Thu Sep 02, 2010 9:33 am

thanks for your link
you can reduce the xfrog tree all you want with a very good definition. you can do this by two ways:
-reducing in 3dsmax by the option Modifiers Multires after selects all geometry
-and you can open the xfrog 3.5 and CHANGE the tree (not crunch) reducing the trunk scale, the number of branches, crockedness, growth scale, etc..
its simple and when you imports in sketchup explodes very well (10 minutes). the very best xfrog have finally in sketchup less than 20 mb.
0

guaucorreo 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Thu Sep 02, 2010 9:39 am

guaucorreo wrote:-and you can open the xfrog 3.5 and CHANGE the tree (not crunch) reducing the trunk scale, the number of branches, crockedness, growth scale, etc..

Oh - So not using the detail slider? (I've just tried that, and it eventual makes the trunk flat)
You got some screens of how you managed to process your X-Frog trees? And some stats?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby guaucorreo » Thu Sep 02, 2010 9:44 am

its an example, the olive of the mediterranean with a lot of modifications
0

guaucorreo 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Thu Sep 02, 2010 9:45 am

I don't see any image.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby guaucorreo » Thu Sep 02, 2010 9:49 am

you can use the detail slider a bit, but be carefoul with the third branches
(and of course in xfrog 3.5 you can reduce the section of this objetcs, trunks, branches, (a circle of 12 lines you can reduce manually to 6,etcc)
0

guaucorreo 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Thu Sep 02, 2010 9:52 am

I really need to have a proper look at the X-Frog app. Got any good resource links?
Maybe we could start a X-Frog thread to collect tips and tricks for X-Frog in SU?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby guaucorreo » Thu Sep 02, 2010 10:03 am

the manual XFROG REFERENCE of the xfrog 3.5 explain in detail all the process to modify a tree
i am going to work with the link you bring me to make all the leaves individual groups and then apply your plugin similar objects.
this saturday i ve got a lot of work

thanksss
pedro barrera from valencia, spain
0

guaucorreo 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Thu Sep 02, 2010 10:09 am

I'm not sure if CC will work on the X-Frog trees, since I've not gotten around to test it. (I'm not sure if the leafs are identical geometry...)
And remember that it doesn't deal with sub-groups/components yet.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby autarchos » Fri Sep 03, 2010 5:00 am

the leaves are identical geometry - just a simple rectangle. at least with the models i have. i converted the leaves of a young birch to identical components with matt666's component/groups plugin: viewtopic.php?t=17590
it is quite slow, the plugin and the process - took me several hours: select 200-300 leaves at a time, select faces only with thomthom's selection tools, use matt666's plug to convert entities to components, and then run component comp to make them all the same. don't explode the leaf groups until you've converted them all to components, then it takes only seconds.
0

autarchos 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Fri Sep 03, 2010 7:18 am

Ohh, it worked? yay! :D
Cool. The process should be easier once I get support for sub-groups/components working.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby Krisidious » Tue Sep 07, 2010 9:44 am

Thom,

I downloaded and installed the plugin and found it under your menu.

I opened my little atrium where I have several windows that I need to make.

I used your "groups to components" tool to change each of the window groups you see to components.

then I rebuilt the one on the end into a window.

then I select all of the instances (each of which are separate components) and run your tool replace similar objects.
inspector.jpg



it returns a menu item that says 0 Definitions replaced. it took 0.53

any ideas on what I'm doing wrong?

if I understand this plugin correctly it should replace each of the components with one instance? and how does it know which instance I want it to use?
0
By: Kristoff Rand
Home Designer
Unique House Plans
User avatar
Krisidious 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Tue Sep 07, 2010 10:00 am

Krisidious wrote:any ideas on what I'm doing wrong?

Maybe nothing, this is very early experimental code.

Krisidious wrote:if I understand this plugin correctly it should replace each of the components with one instance? and how does it know which instance I want it to use?

It doesn't, it just picks one and compares it.
Note that it takes all the components/groups you select and compares it against the whole of the model.

Also beware that it's not working well with sub-components. Your model appear to be a complex one with many sub-components.


If you want you can send me the model and I can have a look at it. I'd be very useful to have more sample models to test against.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby Krisidious » Tue Sep 07, 2010 10:44 am

ok I sent you the model.

what's more I cut the groups and raised them to the top level of the model and ran the script again and it replaced 9 units... although it made 2 distinct groups of components and not the 1 it should have. they were the same so I'm not sure why.
0
By: Kristoff Rand
Home Designer
Unique House Plans
User avatar
Krisidious 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby diegog321 » Wed Sep 08, 2010 11:04 pm

Hi Thom:
First let me thank you for this and all awesome plugins you make.
I got today this huge and monstrous autocad 3d file that I need to convert to sketchup in order to do my job. I was kind of depressed after i imported it because it has about 500.000 faces, most of them autocad components imported as groups. So I went into sketchucation and voila! you just did a plugin for that.

I wanted to share my experience so it may help in the development of the plugin.

Since the script just went on forever with the complete model, I thought to give it a hand and use a wall made of a exactly same block repeated in multiple positions.

The plugin was quite successful as it recognized 112 of the 122 component instances. But it did it as two separate entities.

(applause!!!)

But now I have a question: In the entity info it now says that there are X nunmbers of copies of the same group. I want to turn that into X copies of the same component for easy editing and memory optimization. Is that posible? Do you think that this file might be relevant to you?

Again thank you for this plugin. It will eventually save millions of lives.

Diego

PD: Wouldnt it be nice if a plug in had a way of saying: "-Hey im not dead, I have done X numbers of operations of a total of X"?

PD2: I succeeded. I just needed to use your old plugin groups to components. It reduced the 122 to 3 o 4 copies of the same component. I will keep experimenting.

PD3: I funny thing is that when i try to edit any of those components (or groups) they dissapear until i click elsewhere and return to the model. Does anyone know why this happen?
0

diegog321 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Thu Sep 09, 2010 7:21 am

diegog321 wrote:PD: Wouldnt it be nice if a plug in had a way of saying: "-Hey im not dead, I have done X numbers of operations of a total of X"?

Yes, that can be done. But you still have the problem where SU tend to freeze up the UI - so you end up not getting any feedback. That's in particular with long processing.

diegog321 wrote:PD2: I succeeded. I just needed to use your old plugin groups to components. It reduced the 122 to 3 o 4 copies of the same component. I will keep experimenting.

Yea, I should probably have an option where it converted groups into components automatically. (There is my Selection Toys that let you convert Groups that have mulitple instances into components.)
You got different results if the walls where groups or components?

diegog321 wrote:PD3: I funny thing is that when i try to edit any of those components (or groups) they dissapear until i click elsewhere and return to the model. Does anyone know why this happen?

Sounds like you have Hide Rest of Model turned on. You find that under View > Component Edit.
(Oh wait - does the group/component you open up also disappear??)

Would you mind sending me a sample model with the wall segments? (Before you ran the operation?) I'd help me to have more test data to run.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby diegog321 » Fri Sep 10, 2010 4:36 am

Hi thom:

Here is the file. But beware because it comes from the terrible realm of autocad 3D.

I also found a funny bug. If I dont select anything then it does a relative good job ( it replaces 79/125 with two or three copied groups).

If I select all the "walls" and run the script then it is much more effective ( replacing 113/125 again with tow or three copies). But if you look closely at the second image, a few blocks have moved far away to the other side of the model.

I have successfully converted those group into components before or after running the script with the help of your others plug ins.

And finally I dont have activated "hide the rest of the model". It is like you said, everything dissapears. I heard somewhere that it was because the origin of the block is extremely far away. What do you think?

Hope the info is useful

Diego
0

diegog321 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby thomthom » Fri Sep 10, 2010 7:01 am

diegog321 wrote:I also found a funny bug. If I dont select anything then it does a relative good job ( it replaces 79/125 with two or three copied groups).

what is the bug?
By design, if you haven't got anything selected the plugin analyse the whole model.
If you have some groups/components selectes it compare it's definitions against the rest of the model.
1
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby diegog321 » Sat Sep 11, 2010 5:08 pm

Hi thom what I tried to say is that the script had a different level of success in finding and replacing similar blocks while manually selecting all the objects or just running the script with nothing selected.

Also it if you look carefully to the second image I posted before you will see that a few walls have moved far away from the model. I didnt touch anything I just runned the script.

If you ever more examples like this that come from autocad you just let me know. I got millions! with increasing levels of difficulty.

Or if you need help from an non ruby programer.

Diego

PD: Also do you or anyone knows why the model dissapear completely (including the component) when I try to edit a block or component? I have deactivated the "hide rest of the model" option. Thanks
0

diegog321 
 

Re: [Plugin] Component Comparison (0.2.0a) — 15 August 2010

Postby wyatt » Tue Oct 26, 2010 10:41 pm

Thom,
This is a very useful script. I'm trying to understand what the tolerance setting does. I have a 3D tree with leaves (a simple square faces with png texture) that are all components. With a tolerance of 0.01 I was able to reduce the number of instances from over 3500 to 905. I'd like to be run the script again to further simplify the model, but I continue to get 0 changes. The tolerance settings don't seem to have any impact, even though the faces of the leaves vary from 36 sq. in. to 80 sq. in. Any ideas? Or is this something that will have to fixed in the next update? (I hope there is an update coming) :)
Wyatt
0

wyatt 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: No registered users and 9 guests

Visit our sponsors: