internal static UIElement generateImage(ECCABeam selectedBeam) { Line line = new Line(); Thickness thickness = new Thickness(101, -11, 362, 250); line.Margin = thickness; line.Visibility = System.Windows.Visibility.Visible; line.StrokeThickness = 4; line.Stroke = System.Windows.Media.Brushes.Black; //StartPoint line.X1 = 10; line.Y1 = 70; //EndPoint line.X2 = selectedBeam.Length / 25; line.Y2 = 70; return(line); Rectangle rect; rect = new System.Windows.Shapes.Rectangle(); rect.Stroke = new SolidColorBrush(Colors.Black); rect.Fill = new SolidColorBrush(Colors.Black); rect.Width = 50; rect.Height = 50; Canvas.SetLeft(rect, 50); Canvas.SetTop(rect, 050); return(rect); }
public frm_ECCAProgram(ECCAProject myProject) { InitializeComponent(); Project = myProject; selectedBeam = new ECCABeam(); RefreshScreen(); }
public frm_ECCAProgram(ECCABeam selectedBeam) { InitializeComponent(); Project = new ECCAProject(); bool isunique; Project.BeamCollection.AddBeam(selectedBeam, out isunique); RefreshScreen(); }
public void AddBeam(ECCABeam beamToAdd, out bool isUnique) { isUnique = IsUnique(beamToAdd); if (isUnique == true) { BeamCollectionList.Add(beamToAdd); } else { //updateOnlyBasics } }
/// <summary> /// Get Beam from a Id /// </summary> /// <param name="beamId"></param> /// <returns></returns> public ECCABeam GetBeam(int beamId) { ECCABeam result = new ECCABeam(); foreach (ECCABeam eccaBeam in BeamCollectionList) { if (eccaBeam.Id == beamId) { result = eccaBeam; break; } } return(result); }
public ECCABeam GetBeam(ECCABeam requestedBeam) { ECCABeam result = null; foreach (ECCABeam eccaBeam in BeamCollectionList) { if (eccaBeam.Id == requestedBeam.Id) { result = eccaBeam; break; } } return(result); }
public bool IsUnique(ECCABeam beamToAdd) { //result.Contains(eccamaterial.CategoryName) bool result = true; foreach (ECCABeam eccaBeam in BeamCollectionList) { if (eccaBeam.Id == beamToAdd.Id) { result = false; break; } } return(result); }
public frm_ECCAProgram(ECCAProject myProject, ECCABeam newBeam) { InitializeComponent(); bool isunique; Project = myProject; Project.BeamCollection.AddBeam(newBeam, out isunique); if (isunique) { selectedBeam = newBeam; } else { selectedBeam = Project.BeamCollection.GetBeam(newBeam); } LoadBeamToInterface(); }
private void dgv_Beams_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { DataRowView row = (DataRowView)dgv_Beams.SelectedItems[0]; Int32 beamId = Convert.ToInt32(row["Id"]); ECCABeam selectedBeamBuffer = Project.BeamCollection.GetBeam(beamId); if (selectedBeamBuffer != null) { selectedBeam = selectedBeamBuffer; } LoadBeamToInterface(); } catch { } }
private ECCABeam ConvertToECCABeam(Element selectedBeam) { FamilyInstance selectedBeamAsfamInst = selectedBeam as FamilyInstance; ECCABeam result = new ECCABeam(); BuiltInParameter lengthBIPar = BuiltInParameter.STRUCTURAL_FRAME_CUT_LENGTH; Parameter lengthPar = selectedBeam.get_Parameter(lengthBIPar); string MaterialName = selectedBeamAsfamInst.StructuralMaterialType.ToString(); FamilySymbol sectionSymbol = selectedBeamAsfamInst.Symbol; result.Id = selectedBeam.Id.IntegerValue; result.RevitUId = selectedBeam.UniqueId; result.Length = Utils.FeetTomm(lengthPar.AsDouble()); result.RevitSectionName = sectionSymbol.Name; result.RevitMaterialName = MaterialName; return(result); }
internal static IList <UIElement> generateImage(Canvas myCanvas, ECCABeam selectedBeam) { IList <UIElement> result = new List <UIElement>(); double canvasWidth = myCanvas.ActualWidth; double canvasHeight = myCanvas.ActualHeight; double beamLength = selectedBeam.Length; double scalingfactor = getScalingfactor(canvasWidth, beamLength); double beamCanvasScale = 5000 / (canvasWidth * 0.75); double beamCanvasLength = (beamLength / beamCanvasScale) * scalingfactor; Line line = new Line(); Thickness thickness = new Thickness(101, -11, 362, 250); line.Margin = thickness; line.Visibility = System.Windows.Visibility.Visible; line.StrokeThickness = 3; line.Stroke = System.Windows.Media.Brushes.Black; //StartPoint line.X1 = (canvasWidth / 2) - (beamCanvasLength / 2); line.Y1 = canvasHeight / 2; //EndPoint line.X2 = (canvasWidth / 2) + (beamCanvasLength / 2); line.Y2 = canvasHeight / 2; result.Add(line); return(result); }
public frm_ECCAProgram() { InitializeComponent(); Project = new ECCAProject(); selectedBeam = new ECCABeam(); }
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument uidoc = app.ActiveUIDocument; Document doc = uidoc.Document; string expetedfilesavepath = ""; if (doc.IsWorkshared) { expetedfilesavepath = ModelPathUtils.ConvertModelPathToUserVisiblePath(doc.GetWorksharingCentralModelPath()); } else { expetedfilesavepath = doc.PathName; } string MyECCAFile = Path.GetDirectoryName(expetedfilesavepath) + "\\ECCalcAidFile.bin"; ECCAProject myProject = new ECCAProject(MyECCAFile); try { IList <ElementId> selectedElements = uidoc.Selection.GetElementIds().ToList(); if (selectedElements.Count > 0) { Element selectedBeam = doc.GetElement(selectedElements[0]); bool validStructuralBeam = ValidateStructuralBeam(selectedBeam); if (validStructuralBeam == true) { ECCABeam newBeam = ConvertToECCABeam(selectedBeam); if (!(myProject.BeamCollection.IsUnique(newBeam))) { MessageBox.Show("Note this beam already exisits in the collection, do you want to reset its properties?", "Warning ", MessageBoxButton.YesNo, MessageBoxImage.Warning); } frm_ECCAProgram ECCAMainProgram = new frm_ECCAProgram(myProject, newBeam); ECCAMainProgram.ShowDialog(); } else { MessageBox.Show("The element you selected cannot be read as a structural beam"); } } //serialisation test } catch (Exception ex) { } return(Result.Succeeded); }