How do i Change Texture in Plugin?

This topic has been viewed 5667 times and has 3 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
jrmobile
Posts: 11
Joined: Sat May 16, 2020 9:20 pm
Country: Россия

How do i Change Texture in Plugin?

Post by jrmobile »

Hi.
I need some help on my plugin.
I need to change pieceoffurniture texture to specific one from catalog.
I've found one in catalog and setting it with setTexture, but it requires HomeTexture object type.
How do i set it?

Code: Select all

private void placeFurniture(float[] XYZRot, CatalogPieceOfFurniture furniture, String modelName, float ModelHeight, String CurrentWall) {
		HomePieceOfFurniture model = furnitureController.createHomePieceOfFurniture(furniture);

		
		TexturesCatalog texturesCatalog = userPreferences.getTexturesCatalog();
		java.util.List<TexturesCategory> texturesCategories = texturesCatalog.getCategories();

		TexturesCategory garderobCategory = null;
		for (TexturesCategory category : texturesCategories) {
			if (category.getName().matches("ЛДСП")) {
				garderobCategory = category;
			}
		}
	
		
		java.util.List<CatalogTexture> garderobTextures = garderobCategory.getTextures();
		for (CatalogTexture texture : garderobTextures) {
			if (texture.getName().matches("Гардеробная ЛДСП 31"))
				model.setTexture(texture);
		}
Would appreciate help on this item.
Thanks in advance.
User avatar
Puybaret
Posts: 9440
Joined: Mon Nov 07, 2005 12:00 pm
Country: Paris, France
Contact:

Re: How do i Change Texture in Plugin?

Post by Puybaret »

Look how HomeTexture is instantiated in TextureChoiceComponent class.
Emmanuel Puybaret, Sweet Home 3D creator
jrmobile
Posts: 11
Joined: Sat May 16, 2020 9:20 pm
Country: Россия

Re: How do i Change Texture in Plugin?

Post by jrmobile »

Thank you.
Will try.
jrmobile
Posts: 11
Joined: Sat May 16, 2020 9:20 pm
Country: Россия

Re: How do i Change Texture in Plugin?

Post by jrmobile »

I've made it.
If anyone need, i just leave it here

Code: Select all

TexturesCatalog texturesCatalog = userPreferences.getTexturesCatalog();
				java.util.List<TexturesCategory> texturesCategories = texturesCatalog.getCategories();
	
				TexturesCategory garderobCategory = null;
				for (TexturesCategory category : texturesCategories) {
					if (category.getName().matches("ЛДСП")) {
						garderobCategory = category;
					}
				}
					
				
				java.util.List<CatalogTexture> garderobTextures = garderobCategory.getTextures();
				for (CatalogTexture catalogTexture : garderobTextures) 
				{
				    if (catalogTexture.getName().matches(ldspColor)) {
				        HomeTexture texture = new HomeTexture(catalogTexture);
				        model.setTexture(texture);        
				      }
				}
Post Reply New Topic

Who is online

Users browsing this forum: No registered users and 2 guests