protected override void OnContentRendered(EventArgs e) { model1.Layers[0].LineWeight = 2; model1.Layers[0].Color = MyModel.DrawingColor; model1.Layers.TryAdd(new Layer("Dimensions", System.Drawing.Color.ForestGreen)); model1.Layers.TryAdd(new Layer("Reference geometry", System.Drawing.Color.Red)); tableTabControl.Environment = model1; model1.ActiveLayerName = model1.Layers[0].Name; // enables FastZPR when the scene exceeds 3000 objects _maxComplexity = model1.Turbo.MaxComplexity = 3000; selectionComboBox.SelectedIndex = 0; rendererVersionStatusLabel.Text = model1.RendererVersion.ToString(); model1.SetView(viewType.Top); model1.Invalidate(); model1.Focus(); EnableControls(false); #if SETUP string fileName = String.Format(@"{0}\Eyeshot {1} {2} Samples\dataset\Assets\Misc\app8.dwg", System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), _helper.Edition, _helper.Version.Major); ReadFileAsync ra = _helper.GetReadAutodesk(model1, fileName); #else ReadAutodesk ra = new ReadAutodesk("../../../../../../dataset/Assets/Misc/app8.dwg"); ra.HatchImportMode = ReadAutodesk.hatchImportType.BlockReference; #endif model1.StartWork(ra); base.OnContentRendered(e); }
private void GetWalls(ReadAutodesk CadReader) { Walls = new List <Wall>(); List <List <Point3D> > lstMidPoints = new List <List <Point3D> >(); List <double> lstThickness = new List <double>(); List <Line> lstWallLines = CadHelper.LinesGetByLayerName(CadReader, CadLayerName.Wall); List <List <Line> > lstWalls = new List <List <Line> >(); for (int i = 0; i < lstWallLines.Count; i++) { Line parallel = lstWallLines[i].LineGetNearestParallel(lstWallLines.ToArray()); if (parallel != null && (lstWallLines[i].Length() > parallel.Length())) {//Exclude Lines from list lstWalls.Add(new List <Line> { lstWallLines[i], parallel }); lstThickness.Add(MathHelper.DistanceBetweenTwoParallels(lstWallLines[i], parallel)); lstWallLines.IndexOf(parallel); } } foreach (List <Line> lstParallels in lstWalls) { Point3D stPt1 = lstParallels[0].StartPoint; Point3D stPt2 = lstParallels[1].StartPoint; Point3D endPt1 = lstParallels[0].EndPoint; Point3D endPt2 = lstParallels[1].EndPoint; Point3D midStart = MathHelper.MidPoint3D(stPt1, stPt2); midStart.Z = Level - Slabs[0].Thickness * 1000; Point3D midEnd = MathHelper.MidPoint3D(endPt1, endPt2); midEnd.Z = Level - Slabs[0].Thickness * 1000; if (stPt1.DistanceTo(stPt2) < stPt1.DistanceTo(endPt2)) { lstMidPoints.Add(new List <Point3D> { midStart, midEnd }); } else { lstMidPoints.Add(new List <Point3D> { midEnd, midStart }); } } for (int i = 0; i < lstMidPoints.Count; i++) { Walls.Add(new Wall(lstThickness[i], lstMidPoints[i][0], lstMidPoints[i][1])); } }
public Floor(ReadAutodesk cadReader, double level) { Level = level; //Reinforced Slabs LstRcSlab = base.GetRcSLabs(cadReader); //RC Columns LstRcColumn = base.GetRCColumns(cadReader); //RC Retaining Walls this.LstMasonaryWall = base.GetMasonaryWall(cadReader); //Stairs GetStairs(cadReader); //Reinforced Shear Walls LstRcShearWall = GetRCShearWalls(cadReader); //Ramps LstRamp = GetRamps(cadReader); //Electricity hoses GetElectricalConduit(cadReader); }
private void GetColumns(ReadAutodesk cadFileReader) { Columns = new List <RectColumn>(); List <LinearPath> lstPolyLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Column, true); for (int i = 0; i < lstPolyLine.Count; i++) { double width = double.MaxValue; double length = 0; Point3D widthMidPt = Point3D.Origin; int verticesCount = lstPolyLine[i].Vertices.Length; for (int j = 0; j < verticesCount - 1; j++) { double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(lstPolyLine[i].Vertices[j], lstPolyLine[i].Vertices[j + 1]); width = Math.Min(width, dist); if (width == dist) { widthMidPt = MathHelper.MidPoint3D(lstPolyLine[i].Vertices[j], lstPolyLine[i].Vertices[j + 1]); } length = Math.Max(length, dist); } Point3D center = MathHelper.MidPoint3D(lstPolyLine[i].Vertices[0], lstPolyLine[i].Vertices[2]); center.Z = Level; widthMidPt.Z = Level; RectColumn col = new RectColumn(width, length, center, widthMidPt, lstPolyLine[i]); Columns.Add(col); } }
public static AutocadCrossSection FromAutocad(string path, string name) { ReadAutodesk ra = new ReadAutodesk(path); ra.DoWork(); var curves = new List <ICurve>(); foreach (var entity in ra.Entities) { if (entity is ICurve curve) { curves.Add(curve); } } var reg = new Region(curves.ToArray()); reg.Regen(0.0); Point3D bboxMid = (reg.BoxMax + reg.BoxMin) / 2.0; reg.Translate(-bboxMid.X, -bboxMid.Y, bboxMid.Z); reg.Regen(0.0); var ret = new AutocadCrossSection(reg) { Path = path }; return(ret); }
public Foundation(ReadAutodesk cadReader, double level) { Level = level; GetPCFootings(cadReader); GetRCFootings(cadReader); GetRamps(cadReader); }
private List <Semelle> GetSmelles(ReadAutodesk cadReader) { List <Semelle> LstSemelle = new List <Semelle>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.Semelle); for (int i = 0; i < lstPLine.Count; i++) { for (int j = 0; j < lstPLine[i].Vertices.Length; j++) { lstPLine[i].Vertices[j].Z = Level + DefaultValues.PCFootingThinkess; } } for (int i = 0; i < lstPLine.Count; i++) { Line shortestLine = CadHelper.ShortestLineGet(lstPLine[i]); List <LinearPath> lstCol = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.Column); //double thickness = CadHelper.IsIntersectingWithElmCategory(shortestLine, lstCol) ? DefaultValues.SmellesWithColumnThickness : DefaultValues.SmellesWithFootingThickness; Semelle semelle = new Semelle(lstPLine[i], DefaultValues.SmellesWithFootingThickness); LstSemelle.Add(semelle); } return(LstSemelle); }
public Foundation(ReadAutodesk cadReader, double height, double level) { Level = level; Height = height; //Ramps LstRamp = GetRamps(cadReader); //Reinforced Columns LstRcColumn = base.GetRCColumns(cadReader); //PC Footingds GetPCFooting(cadReader); //RC Footings GetRCFooting(cadReader); //RC Shear Walls LstRCShearWall = GetRCShearWalls(cadReader); //RC Semelles LstRCSemelle = GetReinforcedSemelles(cadReader); //RC Footing LstRCCadFooting = GetReinforcedFootings(cadReader); //RC Retaining Wall LstRCCadWall = base.GetRCWalls(cadReader); //floor axes LstAxis = GetAxes(cadReader); }
private void importButton_OnClick(object sender, EventArgs e) { using (var importFileDialog = new System.Windows.Forms.OpenFileDialog()) using (var importFileAddOn = new ImportFileAddOn()) { importFileDialog.Filter = "CAD drawings (*.dwg)|*.dwg|Drawing Exchange Format (*.dxf)|*.dxf|All compatible file types (*.*)|*.dwg;*.dxf"; importFileDialog.Multiselect = false; importFileDialog.AddExtension = true; importFileDialog.CheckFileExists = true; importFileDialog.CheckPathExists = true; if (importFileDialog.ShowDialog(importFileAddOn, null) == System.Windows.Forms.DialogResult.OK) { model1.Clear(); _yAxisUp = importFileAddOn.YAxisUp; EnableControls(false); #if SETUP ReadFileAsync ra = _helper.GetReadAutodesk(model1, importFileDialog.FileName); #else ReadAutodesk ra = new ReadAutodesk(importFileDialog.FileName); #endif model1.StartWork(ra); } } }
public BasementFloor(ReadAutodesk cadReader, double level, double height) { this.Level = level; this.Height = height; //Reinforced Slabs LstRcSlab = base.GetRcSLabs(cadReader); //RC Columns LstRcColumn = base.GetRCColumns(cadReader); //RC Retaining Walls this.LstRcCadRetainingWall = base.GetRCWalls(cadReader); //Stairs GetStairs(cadReader); //Reinforced Shear Walls LstRcShearWall = GetRCShearWalls(cadReader); //Ramps LstRamp = GetRamps(cadReader); //Electricity hoses GetElectricalConduit(cadReader); //floor axes LstAxis = GetAxes(cadReader); }
private void GetSlabs(ReadAutodesk cadFileReader) { List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Slab, true); for (int i = 0; i < lstPLine.Count; i++) { double width = double.MaxValue; double length = 0; List <Point2D> lstVertices = new List <Point2D>(); Point3D widthMidPt = Point3D.Origin; int nVertices = lstPLine[i].Vertices.Length; for (int j = 0; j < nVertices; j++) { if (j + 1 == nVertices) { break; } double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(lstPLine[i].Vertices[j], lstPLine[i].Vertices[j + 1]); width = Math.Min(width, dist); if (width == dist) { widthMidPt = MathHelper.MidPoint3D(lstPLine[i].Vertices[j], lstPLine[i].Vertices[j + 1]); } length = Math.Max(length, dist); } Point3D center = MathHelper.MidPoint3D(lstPLine[i].Vertices[0], lstPLine[i].Vertices[2]); center.Z = Level; widthMidPt.Z = Level; Slabs.Add(new Slab(width, length, center, widthMidPt)); } }
public Floor(ReadAutodesk cadReader, double level) { Level = level; GetSlabs(cadReader); GetOpening(cadReader); GetColumns(cadReader); GetWalls(cadReader); }
private void ReadFile(string fileName) { if (!string.IsNullOrWhiteSpace(fileName)) { ReadAutodesk readAutodesk = new ReadAutodesk(fileName); readAutodesk.DoWork(); Entities = readAutodesk.Entities.ToList(); } }
private void GetRamps(ReadAutodesk cadReader) { this.Ramps = new List <SlopedSlab>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.Ramp); List <SlopedSlab> lstSlopedSlab = lstPLine.Where(e => e is LinearPathEx).Select(s => new SlopedSlab(s.Vertices.ToList())).ToList(); Ramps.AddRange(lstSlopedSlab); }
public static List <LinearPath> PLinesGetByLayerName(ReadAutodesk cadReader, string layerName, bool isClosed) { if (isClosed) { return(cadReader.Entities.Where(e => e.LayerName == layerName && e is LinearPath).Cast <LinearPath>() .Where(l => l.IsClosed).ToList()); } return(cadReader.Entities.Where(e => e.LayerName == layerName && e is LinearPath).Cast <LinearPath>().ToList()); }
public static List <LinearPath> PLinesGetByLayerName(ReadAutodesk cadReader, params string[] layers) { List <LinearPath> lstEntity = new List <LinearPath>(); for (int i = 0; i < layers.Length; i++) { lstEntity.AddRange(cadReader.Entities.Where(e => e.LayerName == layers[i] && e is LinearPath).Cast <LinearPath>().ToList()); } return(lstEntity); }
private void GetRCFootings(ReadAutodesk cadReader) { RCFooting = new List <RCRectFooting>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.RCFooting).Where(pl => pl.IsClosed).ToList(); for (int i = 0; i < lstPLine.Count; i++) { RCRectFooting footing = RectFootingCreate(lstPLine[i], RcThickness, "RC") as RCRectFooting; RCFooting.Add(footing); } }
public List <SlopedSlab> GetRamps(ReadAutodesk cadReader) { List <SlopedSlab> Ramps = new List <SlopedSlab>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadReader, CadLayerName.Ramp); List <SlopedSlab> lstSlopedSlab = lstPLine.Where(e => e is LinearPathEx).Select(s => new SlopedSlab(s.Vertices.Select(v => new Point3D(v.X, v.Y, v.Z + Level)).ToList())).ToList(); Ramps.AddRange(lstSlopedSlab); return(Ramps); }
internal List <ReinforcedCadSlab> GetRcSLabs(ReadAutodesk cadReader) { List <Slab> LstSlab = GetSlabs(cadReader); List <ReinforcedCadSlab> lstRcSlab = new List <ReinforcedCadSlab>(); for (int i = 0; i < LstSlab.Count; i++) { lstRcSlab.Add(new ReinforcedCadSlab(LstSlab[i])); } return(lstRcSlab); }
private List <ReinforcedCadSemelle> GetReinforcedSemelles(ReadAutodesk cadReader) { List <Semelle> lstSemelle = GetSmelles(cadReader); List <ReinforcedCadSemelle> lstRCSemelle = new List <ReinforcedCadSemelle>(); for (int i = 0; i < lstSemelle.Count(); i++) { lstRCSemelle.Add(new ReinforcedCadSemelle(cadReader, lstSemelle[i])); } return(lstRCSemelle); }
private void GetStairs(ReadAutodesk cadFileReader) { LstStair = new List <Stair>(); List <LinearPathEx> lstStairFlightPath = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Stair).Where(p => p is LinearPathEx).Cast <LinearPathEx>().ToList(); LstLandingLinPath = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Stair).Except <LinearPath>(lstStairFlightPath).ToList(); for (int i = 0; i < LstLandingLinPath.Count; i++) { for (int j = 0; j < LstLandingLinPath[i].Vertices.Length; j++) { LstLandingLinPath[i].Vertices[j].Z += Level; } } Dictionary <int, List <Line> > dicStairLines = new Dictionary <int, List <Line> >(); //Dictionary<double, List<Line>> dicSlopedStairLines = new Dictionary<double, List<Line>>(); for (int i = 0; i < lstStairFlightPath.Count(); i++) { List <Line> lstLines = new List <Line>(); for (int j = 0; j < lstStairFlightPath[i].Vertices.Count() - 1; j++) { Line l = new Line(lstStairFlightPath[i].Vertices[j], lstStairFlightPath[i].Vertices[j + 1]); lstLines.Add(l); } dicStairLines.Add(i, lstLines); } foreach (KeyValuePair <int, List <Line> > item in dicStairLines) { List <Line> slopedLines = new List <Line>(); List <Line> hzLines = new List <Line>(); for (int i = 0; i < item.Value.Count(); i++) { if (Math.Abs(item.Value[i].StartPoint.Z - item.Value[i].EndPoint.Z) > 0.0001) { slopedLines.Add(new Line(new Point3D(item.Value[i].StartPoint.X, item.Value[i].StartPoint.Y, Level + item.Value[i].StartPoint.Z) , new Point3D(item.Value[i].EndPoint.X, item.Value[i].EndPoint.Y, Level + item.Value[i].EndPoint.Z))); } else { hzLines.Add(new Line(new Point3D(item.Value[i].StartPoint.X, item.Value[i].StartPoint.Y, Level + item.Value[i].StartPoint.Z) , new Point3D(item.Value[i].EndPoint.X, item.Value[i].EndPoint.Y, Level + item.Value[i].EndPoint.Z))); } } double stairWidth = hzLines[0].Length(); LstStair.Add(new Stair(stairWidth, slopedLines)); } }
private void GetOpenings(ReadAutodesk cadFileReader, LinearPath path, double level) { Openings = new List <Opening>(); List <LinearPath> lstPolyLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Opening, true); List <LinearPath> PolyLines = new List <LinearPath>(); for (int i = 0; i < lstPolyLine.Count; i++) { if (MathHelper.IsInsidePolygon(lstPolyLine[i], path)) { PolyLines.Add(lstPolyLine[i]); } } for (int i = 0; i < PolyLines.Count; i++) { #region Old code using rectangule shape method //double width = double.MaxValue; //double length = 0; //List<Point2D> lstVertices = new List<Point2D>(); //Point3D widthMidPt = Point3D.Origin; //int nVertices = PolyLines[i].Vertices.Length; //for (int j = 0; j < nVertices - 1; j++) //{ // double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(PolyLines[i].Vertices[j], PolyLines[i].Vertices[j + 1]); // width = Math.Min(width, dist); // if (width == dist) // { // widthMidPt = MathHelper.MidPoint3D(PolyLines[i].Vertices[j], PolyLines[i].Vertices[j + 1]); // } // length = Math.Max(length, dist); //} //Point3D center = MathHelper.MidPoint3D(PolyLines[i].Vertices[0], PolyLines[i].Vertices[2]); //center.Z = level; //widthMidPt.Z = level; #endregion for (int j = 0; j < PolyLines[i].Vertices.Length; j++) { PolyLines[i].Vertices[j].Z = level; } Openings.Add(new Opening(PolyLines[i])); } }
public List <ReinforcedCadColumn> GetRCColumns(ReadAutodesk cadReader) { List <Column> Columns = GetColumns(cadReader); List <ReinforcedCadColumn> RcColumns = new List <ReinforcedCadColumn>(); ReinforcedCadColumn RcCol = null; foreach (var col in Columns) { RcCol = new ReinforcedCadColumn(col, Level); RcColumns.Add(RcCol); } return(RcColumns); }
public List <ReinforcedCadWall> GetRCWalls(ReadAutodesk cadReader) { List <Wall> lstWall = GetWalls(cadReader); List <ReinforcedCadWall> lstRcWall = new List <ReinforcedCadWall>(); ReinforcedCadWall rcWall = null; foreach (var wall in lstWall) { rcWall = new ReinforcedCadWall(wall); lstRcWall.Add(rcWall); } return(lstRcWall); }
private List <Slab> GetSlabs(ReadAutodesk cadFileReader) { List <Slab> lstSlab = new List <Slab>(); List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Slab); for (int i = 0; i < lstPLine.Count; i++) { Slab slab = new Slab(cadFileReader, lstPLine[i], Level); lstSlab.Add(slab); } return(lstSlab); }
internal List <ReinforcedCadShearWall> GetRCShearWalls(ReadAutodesk cadReader) { List <ShearWall> shearWalls = GetShearWalls(cadReader); List <ReinforcedCadShearWall> RcShearWalls = new List <ReinforcedCadShearWall>(); ReinforcedCadShearWall RcShearWall = null; foreach (var shearWall in shearWalls) { RcShearWall = new ReinforcedCadShearWall(shearWall); RcShearWalls.Add(RcShearWall); } return(RcShearWalls); }
public List <ReinforcedCadFooting> GetReinforcedFootings(ReadAutodesk cadFileReader) { List <RCFooting> LstRcFootings = GetRCFooting(cadFileReader); List <ReinforcedCadFooting> RcFootings = new List <ReinforcedCadFooting>(); ReinforcedCadFooting RcFooting = null; foreach (var footing in LstRcFootings) { RcFooting = new ReinforcedCadFooting(footing); RcFootings.Add(RcFooting); } return(RcFootings); }
private void btnImport_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog() { Filter = "STL File|*.STL", Multiselect = false, AddExtension = true, CheckFileExists = true, CheckPathExists = true }; openFileDialog.InitialDirectory = "c:\\"; // openFileDialog.Filter = "Object files (*.STL,*.OBJ,*.FBX,*.3DS)|*.STL,*.OBJ,*.FBX,*.3DS|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == true) { //Get the path of specified file var filePath = openFileDialog.FileName; //Read the contents of the file into a stream var fileStream = openFileDialog.OpenFile(); var fileContent = ""; using (StreamReader reader = new StreamReader(fileStream)) { //devDept.Eyeshot.Translators.ReadFile filePath = new devDept.Eyeshot.Translators.ReadFile(filePath); model1.Clear(); var readAutodesk = new ReadAutodesk(filePath); readAutodesk.DoWork(); readAutodesk.AddToScene(model1); var ReadObj = new ReadSTL(filePath); ReadObj.DoWork(); Entity[] toAdd = ReadObj.Entities; //fileContent = reader.ReadToEnd(); //ModelVisual3D device3D = new ModelVisual3D(); //Viewport3DVisual viewport = new Viewport3DVisual(); //viewport readFile; model1.Entities.AddRange(toAdd, System.Drawing.Color.Chocolate); //model1.SetView(viewType.Top); //model1.ZoomFit(); model1.Invalidate(); } //view.Export(filePath); } }
private List <RCFooting> GetRCFooting(ReadAutodesk cadFileReader) { List <LinearPath> lstPLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.RCFooting, true); for (int i = 0; i < lstPLine.Count; i++) { for (int j = 0; j < lstPLine[i].Vertices.Length; j++) { lstPLine[i].Vertices[j].Z = Level + DefaultValues.PCFootingThinkess; } } List <RCFooting> lstRCFooting = lstPLine.Select(s => new RCFooting(s, RcThickness)).ToList(); return(lstRCFooting); }
public static Region FromAutocad(this Region me, string path) { ReadAutodesk ra = new ReadAutodesk(path); ra.DoWork(); var curves = new List <ICurve>(); foreach (var entity in ra.Entities) { if (entity is ICurve curve) { curves.Add(curve); } } return(new Region(curves.ToArray())); }