Print at Dec 17, 2025, 9:13:32 PM

Posted by scoop7 at Jan 22, 2025, 4:32:12 AM
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);