How to replace one Texture with another Texture using code

This topic has been viewed 6765 times and has 4 replies
Thread status: Active
Questions about extending features and developing plug-ins [img]http://www.sweethome3d.com/images/flags/en_small.gif[/img]
Post Reply New Topic
rkv104
Posts: 19
Joined: Sat Jun 22, 2013 3:37 pm

How to replace one Texture with another Texture using code

Post by rkv104 »

I wish to develop a plugin that will replace one texture with another texture in entire home model.

user will supply old texture name and new texture name. I wish to know how to create a HomeTexture if you know just the texture name as displayed in Available Texture List.
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How to replace one Texture with another Texture using code

Post by Puybaret »

Textures in the textures catalog (i.e. Available Texture List in the user interface) are accessible by getTexturesCatalog method in preferences (see TextureChoiceComponent class) and each CatalogTexture instance has a name. To create a HomeTexture instance just use in parameter the instance of the CatalogTexture instance in the catalog with the name you want.
In case you didn't know it, have also a look to Change Texture Plugin which might give you some ideas.
Emmanuel Puybaret, Sweet Home 3D creator
hobbyrv
Posts: 97
Joined: Fri Oct 30, 2015 5:55 pm
Country: Berkel en Rodenrijs

Re: How to replace one Texture with another Texture using code

Post by hobbyrv »

How can I implement the Change Texture Plugin. I downloadedit but it doesn't do anything
rkv104
Posts: 19
Joined: Sat Jun 22, 2013 3:37 pm

Re: How to replace one Texture with another Texture using code

Post by rkv104 »

Thanks Puybaret,

I could write code to access CatalogTexture object using texture name. I am writing code to undo texture changes in my plugin.
i can see that undo code gets called and it is able to invoke wall.setLeftSideColour() method where i am changing colour of the wall.

though this method is invoked the change is not reflected in 3d model display screen. if i double click on wall i could see that left side colour checkbox is checked..but colour change is not getting reflected in 3d display.......

what could be the problem...do i need to call some extra method besides calling settter methods for changing colour and textures..so that the changes are reflected in 3d model...

please reply
rkv104
Posts: 19
Joined: Sat Jun 22, 2013 3:37 pm

Re: How to replace one Texture with another Texture using code

Post by rkv104 »

I got the solution to my problem.. so don't bother my earlier query
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 1 guest