[Code] material.name= v1.2

[Code] material.name= v1.2

Postby TIG » Wed Jun 24, 2009 2:35 pm

material-name=.rb adds a new Method to Sketchup's Material Class-
material.name="new_name"
it makes a cloned new-material from the original-material
and gives it the 'new_name',
if the name 'new_name' exists then it's made unique with a #N suffix,
it gives the new-material to any entities that had the original-material,
the original-material is deleted from the model and material-browser:
if the current-material in the browser was the original-material then
the current-material in the browser becomes the new_material...
Edit:
v1.1 Temp folder fixed for Mac users.
v1.2 Attribute Dictionaries copied over.
v1.3 Error with attrdict==nil fixed.
material-name=.rb
0
Last edited by TIG on Fri Aug 21, 2009 9:32 am, edited 4 times in total.
TIG
User avatar
TIG 
Global Moderator
 

Re: [Code] material.name=

Postby RickW » Wed Jun 24, 2009 3:19 pm

Sounds like a candidate for SKX
0

RickW 
 

Re: [Code] material.name=

Postby thomthom » Wed Jun 24, 2009 3:22 pm

Yup.
Though recently I've begun to ponder about forwards compatibility. What if Google later implements the methods we add or fixes? viewtopic.php?f=315&t=20113
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: [Code] material.name=

Postby AdamB » Wed Jun 24, 2009 8:43 pm

Yeah, its a tricky one because you can check with respond_to? if it already exists but the semantics of the new method might be completely different.

I think extending the SU classes is a theological gray area / no-no.. as opposed to specialization through class derivation.

But I've done it a few times over the years. Most recently when I really want to be able to treat Selection just like a Model, so I added a bunch of methods that simply kick the message to Selection to self.model. It just made the rest of my code so much cleaner not having to constantly check what its dealing with.

Adam
0
Developer of LightUp Click for website
User avatar
AdamB 
LightUp Support
LightUp Support
 

Re: [Code] material.name=

Postby thomthom » Wed Jun 24, 2009 8:56 pm

AdamB wrote:Yeah, its a tricky one because you can check with respond_to? if it already exists but the semantics of the new method might be completely different.

I think extending the SU classes is a theological gray area / no-no.. as opposed to specialization through class derivation.

Yea, it'd be nice to hear from Scott or any of the other Google-heads on this. He seemed positive to the Skx project, but I don't think anyone has mentioned this topic.
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: [Code] material.name= v1.1

Postby TIG » Fri Jun 26, 2009 10:06 am

Here's v1.1 viewtopic.php?p=167219#p167219
The Temp folder is now fixed to suit Mac users too...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Code] material.name= v1.2

Postby TIG » Wed Aug 19, 2009 8:27 pm

Here's v1.2 viewtopic.php?p=167219#p167219
Any Attribute Dictionaries now copied to renamed material...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Code] material.name= v1.2

Postby TIG » Fri Aug 21, 2009 9:33 am

Here's v1.3 - with error on attrdicts==nil fixed...
viewtopic.php?p=167219#p167219
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 16 guests