public void Execute(UIApplication app) { UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; string baseLevel = Properties.Settings.Default.BaseLevelName; string topLevel = Properties.Settings.Default.TopLevelName; float scale = Properties.Settings.Default.Scale; double overhang = UnitUtils.ConvertToInternalUnits(Properties.Settings.Default.Overhang, UnitTypeId.Meters);; XYZ slopeVector = BuildRoofForm.SlopeVector; RoofDesign roofDesign = BuildRoofForm.RoofDesign; double slope = RoofSelector.GetSlopeByType(roofDesign); HouseBuilder elementPlacer = new HouseBuilder(doc, baseLevel, topLevel, scale); try { using (Transaction transaction = new Transaction(doc, "Roof Command")) { transaction.Start(); elementPlacer.CreateRoof(overhang, slope, slopeVector, roofDesign); transaction.Commit(); } } catch { } }
public House ConstructHouse(HouseBuilder builder) { House house = builder.CreateHouse(); Console.WriteLine(house.GetRepresentation()); house.SetFloor(builder.CreateFloor()); Console.WriteLine(house.GetFloor().GetRepresentation()); house.SetWalls(builder.CreateWalls()); Console.WriteLine(house.GetWalls().GetRepresentation()); house.SetRoof(builder.CreateRoof()); Console.WriteLine(house.GetRoof().GetRepresentation()); return(house); }
public void Execute(UIApplication app) { UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; float scale = 0; double overhang = 0; string levelName = "", topLevelName = ""; try { scale = Properties.Settings.Default.Scale; overhang = UnitUtils.ConvertToInternalUnits(Properties.Settings.Default.Overhang, UnitTypeId.Meters); levelName = Properties.Settings.Default.BaseLevelName; topLevelName = Properties.Settings.Default.TopLevelName; } catch (Exception e) { MessageBox.Show(e.Message); PlaceElementsForm.CloseForm(); } string path = PlaceElementsForm.filePath; XYZ roofVector = PlaceElementsForm.roofSelector.SlopeVector; RoofDesign roofDesign = PlaceElementsForm.roofSelector.RoofStyle; double slope = RoofSelector.GetSlopeByType(roofDesign); HouseBuilder builder = new HouseBuilder(doc, levelName, topLevelName, scale); string errorMessage = ""; using (Transaction transaction = new Transaction(doc, "Contruir JSON")) { transaction.Start(); try { builder.BuildJSON(path); } catch (Exception e) { errorMessage += $"\nErro ao construir elementos do JSON: \"{e.Message}\""; } try { builder.CreateFloor(Properties.Settings.Default.FloorName); } catch (Exception e) { errorMessage += $"\nErro ao construir piso: \"{e.Message}\""; } try { builder.CreateCeiling(Properties.Settings.Default.CeilingName); } catch (Exception e) { errorMessage += $"\nErro ao construir laje: \"{e.Message}\""; } try { builder.ClassifyRooms(); } catch (Exception e) { errorMessage += $"\nErro ao classificar ambientes: \"{e.Message}\""; } transaction.Commit(); } using (Transaction transaction = new Transaction(doc, "Contruir Telhado")) { transaction.Start(); try { builder.CreateRoof(overhang, slope, roofVector, roofDesign); } catch (Exception e) { errorMessage += $"\nErro ao construir telhado: \"{e.Message}\""; } transaction.Commit(); } if (errorMessage.Length > 1) { MessageBox.Show(errorMessage, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } PlaceElementsForm.CloseForm(); }