[code] ComponentDefinition-delete

[code] ComponentDefinition-delete

Postby TIG » Sun Mar 29, 2009 5:57 pm

This script adds a new method for a ComponentDefinition...
component_definition.delete
It mimics deleting a component-definition from the component-browser.
All instances of the component-definition are erased (including any locked ones)
and the component-definition itself is then purged.
However, any other 'unused' component-definitions remain unaffected...
unlike "definitions.purge_all", which purges everything that's unused...
[EDIT: AlexM has written a better version - recommend you get it here - viewtopic.php?p=145255#p145255]
I have removed my 'code' 20090402...
0
Last edited by TIG on Thu Apr 02, 2009 9:43 am, edited 5 times in total.
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentDefinition-delete

Postby broomstick » Sun Mar 29, 2009 6:05 pm

This is a very handy time saver :)

Thanks :fro:
0
User avatar
broomstick 
 

Re: [Plugin] ComponentDefinition-delete

Postby Chris Fullmer » Sun Mar 29, 2009 6:12 pm

Yeah, thats great. Thanks TIG!

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] ComponentDefinition-delete

Postby thomthom » Sun Mar 29, 2009 6:15 pm

I wonder what the performance impact is if there's many unused components in a model. Where I work I've seen models which has been worked on for years without every being purged... But until we get a native function this is the only way I can imagine it working.
Thanks for looking into this TIG.
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] ComponentDefinition-delete

Postby TIG » Sun Mar 29, 2009 6:18 pm

You could also use my Purge.rb that purges all Components, Layers, Materials and Styles in one go... Then your model would be 'trim'... Later on a few unused things won't give much of an overhead...

I've tried "definition.delete" with 30+ unused definitions and it took 'no time at all'...
0
Last edited by TIG on Sun Mar 29, 2009 6:51 pm, edited 1 time in total.
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] ComponentDefinition-delete

Postby thomthom » Sun Mar 29, 2009 6:35 pm

Personally I purge like every five minutes. Hooked up to a hotkey. But I'm a bit afraid to just purge stuff from other people's model when I write my plugins. But your method is a fine workaround in any case. I expect that's what I'll be using.
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] ComponentDefinition-delete

Postby wolfy » Sun Mar 29, 2009 6:48 pm

Thanks Tig! Will come in usefull when rendering with Vray since getting rid of any component instances should make render times quicker (after a file copy of course).
0

wolfy 
 

Re: [code] ComponentDefinition-delete

Postby TIG » Wed Apr 01, 2009 10:00 am

A better version has been written by AlexM viewtopic.php?p=145255#p145255
I recommend you change to that and I have added a note to the initial page on this thread...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [code] ComponentDefinition-delete

Postby TIG » Thu Apr 02, 2009 9:42 am

AlexM has found the basis of doing this without a new method at all...
Code: Select all
model.start_operation("Delete Definition")
  definition.entities.erase_entities(definition.entities.to_a)
model.commit_operation

I'm removing my 'code' and rewriting ComponentInstance-add_entites.rb to suit...
0
TIG
User avatar
TIG 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 18 guests

Visit our sponsors: