Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 2
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 1532 times and has 1 reply
scoop7
Newbie



中国
Joined: Jan 22, 2025
Post Count: 1
Status: Offline
Reply to this Post  Reply with Quote 
Automatically add windows and doors

I'm working on a plugin whose purpose is to automate the creation of windows and doors based on the scripts I entered, and I've implemented the basic functionality.
But I've encountered a problem: there is a big gap between the door, window and the wall.



I am using IntelliJ IDEA COMMUNITY EDITION 2024.1.4
Here's my core code:


Wall wall = new Wall(x1, y1, x2, y2, width, wallHeight);
Home home = getHome();
home.addWall(wall);

UserPreferences userPreferences = getUserPreferences();
FurnitureCatalog furnitureCatalog = userPreferences.getFurnitureCatalog();
FurnitureCategory furnitureCategory = furnitureCatalog.getCategory(3);
for (CatalogPieceOfFurniture catalogPieceOfFurniture : furnitureCategory.getFurniture()) {
if ("门".equals(catalogPieceOfFurniture.getName())) {
Door = new HomeDoorOrWindow((DoorOrWindow) catalogPieceOfFurniture);
System.out.println("找到门的模型");
} else if ("窗户".equals(catalogPieceOfFurniture.getName())) {
Window = new HomeDoorOrWindow((DoorOrWindow) catalogPieceOfFurniture);
System.out.println("找到窗户的模型");
}
}

HomeDoorOrWindow window = new HomeDoorOrWindow(Window);
window.setDepth(Depth);
window.setWidth(Width);
window.setX(X);
window.setY((Y);
window.setBoundToWall(true);
home.addPieceOfFurniture(window);

[Jan 22, 2025, 4:32:12 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 448
Status: Offline
Reply to this Post  Reply with Quote 
Re: Automatically add windows and doors

It looks like you have set a value too large for the door depth. How are you computing it?

Look at the source of PlanController class and search for "getWallThickness" to find out how to compute the proper depth and position for a door. The wall thickness and distance are publicly accessible.
You may also search the forum for "doorOrWindowWallThickness" to find out more about these values.
[Jan 24, 2025, 8:14:57 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved