/// <summary> /// Initializes a new instance of the <see cref="LandFeatureline"/> class. /// </summary> /// <param name="fl">The AeccLandFeatureline.</param> /// <param name="style">The style name.</param> internal LandFeatureline(AeccLandFeatureLine fl, string style = "") { if (fl == null) { return; } this._featureline = fl; this._name = fl.Name; this._minGrade = fl.MiniGrade; this._minElevation = fl.MiniElevation; this._maxElevation = fl.MaxElevation; this._maxGrade = fl.MaxGrade; this._style = style; // Andrew Milford - Using reflection does not crash Dynamo Type fltype = fl.GetType(); if (fltype != null) { try { dynamic coord = fltype.InvokeMember("GetPoints", BindingFlags.InvokeMethod, System.Type.DefaultBinder, fl, new object[] { AeccLandFeatureLinePointType.aeccLandFeatureLinePointPI }); IList <Point> points = new List <Point>(); for (int i = 0; i < coord.Length; i = i + 3) { double x = coord[i]; double y = coord[i + 1]; double z = coord[i + 2]; points.Add(Point.ByCoordinates(x, y, z)); } if (points.Count > 1) { try { PolyCurve pc = PolyCurve.ByPoints(Point.PruneDuplicates(points)); this._polycurve = pc; } catch { // Not all Polycurves are branching this._polycurve = null; } } } catch { } } }
/// <summary> /// Initializes a new instance of the <see cref="LandFeatureline"/> class. /// </summary> /// <param name="fl">The AeccLandFeatureline.</param> /// <param name="pc">The PolyCurve.</param> /// <param name="style">The style name.</param> internal LandFeatureline(AeccLandFeatureLine fl, PolyCurve pc, string style = "") { this._featureline = fl; this._name = fl.Name; this._minGrade = fl.MiniGrade; this._minElevation = fl.MiniElevation; this._maxElevation = fl.MaxElevation; this._maxGrade = fl.MaxGrade; this._polycurve = pc; this._style = style; }
public IList <LandFeatureline> GetLandFeaturelines(string xmlPath = "") { Utils.Log(string.Format("CivilDocument.GetLandFeaturelines started...", "")); if (string.IsNullOrEmpty(xmlPath)) { xmlPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "LandFeatureLinesReport.xml"); } bool result = this.SendCommand("-ExportLandFeatureLinesToXml\n"); IList <LandFeatureline> output = new List <LandFeatureline>(); if (result) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlPath); AcadDatabase db = this._document as AcadDatabase; AcadModelSpace ms = db.ModelSpace; foreach (AcadEntity e in ms) { if (e.EntityName.ToLower().Contains("featureline")) { AeccLandFeatureLine f = e as AeccLandFeatureLine; XmlElement fe = xmlDoc.GetElementsByTagName("FeatureLine").Cast <XmlElement>().First(x => x.Attributes["Name"].Value == f.Name); IList <Point> points = new List <Point>(); foreach (XmlElement p in fe.GetElementsByTagName("Point")) { double x = Convert.ToDouble(p.Attributes["X"].Value); double y = Convert.ToDouble(p.Attributes["Y"].Value); double z = Convert.ToDouble(p.Attributes["Z"].Value); points.Add(Point.ByCoordinates(x, y, z)); } PolyCurve pc = PolyCurve.ByPoints(points); string style = fe.Attributes["Style"].Value; output.Add(new LandFeatureline(f, pc, style)); } } Utils.Log(string.Format("CivilDocument.GetLandFeaturelines completed.", "")); } return(output); }
public static LandFeatureline ByObjectPolyCurve(AeccLandFeatureLine fl, PolyCurve polyCurve) { return(new LandFeatureline(fl, polyCurve)); }
public IList <LandFeatureline> GetLandFeaturelines(string xmlPath = "") { Utils.Log(string.Format("CivilDocument.GetLandFeaturelines started...", "")); if (string.IsNullOrEmpty(xmlPath)) { xmlPath = System.IO.Path.Combine(Environment.GetEnvironmentVariable("TMP", EnvironmentVariableTarget.User), "LandFeatureLinesReport.xml"); } this.SendCommand("-ExportLandFeatureLinesToXml\n"); DateTime start = DateTime.Now; while (true) { if (System.IO.File.Exists(xmlPath)) { if (System.IO.File.GetLastWriteTime(xmlPath) > start) { start = System.IO.File.GetLastWriteTime(xmlPath); } else { break; } } } Utils.Log("XML acquired."); bool result = true; IList <LandFeatureline> output = new List <LandFeatureline>(); if (result) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlPath); AcadDatabase db = this._document as AcadDatabase; AcadModelSpace ms = db.ModelSpace; foreach (AcadEntity e in ms) { if (e.EntityName.ToLower().Contains("featureline")) { AeccLandFeatureLine f = e as AeccLandFeatureLine; XmlElement fe = xmlDoc.GetElementsByTagName("FeatureLine").Cast <XmlElement>().First(x => x.Attributes["Handle"].Value == f.Handle.ToString()); IList <Point> points = new List <Point>(); foreach (XmlElement p in fe.GetElementsByTagName("Point")) { double x = Convert.ToDouble(p.Attributes["X"].Value, CultureInfo.InvariantCulture); double y = Convert.ToDouble(p.Attributes["Y"].Value, CultureInfo.InvariantCulture); double z = Convert.ToDouble(p.Attributes["Z"].Value, CultureInfo.InvariantCulture); points.Add(Point.ByCoordinates(x, y, z)); } points = Point.PruneDuplicates(points); if (points.Count > 1) { PolyCurve pc = PolyCurve.ByPoints(points); string style = fe.Attributes["Style"].Value; output.Add(new LandFeatureline(f, pc, style)); } } } Utils.Log(string.Format("CivilDocument.GetLandFeaturelines completed.", "")); } return(output); }
CBF() { try { AeccDatabase db = BaseObjsCom.aeccDb; ObjectId idPoly3d = Select.getBrkLine("Select 3d Breakline"); Handle hPoly3d = idPoly3d.getHandle(); ResultBuffer rbPoly3d = idPoly3d.getXData(apps.lnkBrks); if (rbPoly3d == null) { return; } List <Handle> hCgPnts = rbPoly3d.rb_handles(); TypedValue[] tvsX = rbPoly3d.AsArray(); List <string> nameApps = null; List <TypedValue[]> lstTVs = xData.parseXData(tvsX, out nameApps); AeccSites sites = db.Sites; AeccSite site = null; bool exists = false; foreach (AeccSite s in sites) { if (s.Name == "Site1") { site = s; exists = true; break; } } if (!exists) { site = sites.Add("Site1"); } AeccLandFeatureLines features = site.FeatureLines; AeccFeatureLineStyles styles = db.FeatureLineStyles; AeccFeatureLineStyle style = styles[0]; long idOldPoly3d = (long)idPoly3d.OldIdPtr; AeccLandFeatureLine feature = features.AddFromPolyline(idOldPoly3d, style); feature.Layer = idPoly3d.getLayer(); short[] varType = null; object[] varVal = null; for (int i = 0; i < lstTVs.Count; i++) { TypedValue[] tvs = lstTVs[i]; string nameApp = tvs[0].Value.ToString(); if (nameApp == apps.lnkBrks) { myUtility.tvsToList(tvs, ref varType, ref varVal); feature.SetXData(varType, varVal); break; } } Polyline3d poly3d = (Polyline3d)idPoly3d.getEnt(); foreach (Handle hCgPnt in hCgPnts) { ObjectId idCgPnt = hCgPnt.getObjectId(); idCgPnt.replaceHandleInXdata(apps.lnkBrks, feature.Handle.stringToHandle(), poly3d.Handle); } rbPoly3d = idPoly3d.getXData(apps.lnkBrks3); if (rbPoly3d == null) { return; } TypedValue[] tvsPoly3d = rbPoly3d.AsArray(); ObjectId idPoly3dFL = tvsPoly3d[1].getObjectId(); idPoly3dFL.replaceHandleInXdata(apps.lnkBrks3, feature.Handle.stringToHandle(), poly3d.Handle); varType = new short[2]; varVal = new object[2]; varType[0] = 1001; varVal[0] = apps.lnkBrks3; varType[1] = 1005; varVal[1] = idPoly3dFL.getHandle().ToString(); feature.SetXData(varType, varVal); idPoly3d.delete(); } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " cmdCBF.cs: line: 107"); } }
update3dPoly_lnkBrks1_2(string nameApp, ObjectId idCogoPnt, Handle hEnt3d) { ObjectId idEnt3d = ObjectId.Null; Entity ent3d = hEnt3d.getEnt(); if (ent3d == null) { return(idEnt3d); } if (ent3d is Polyline3d) { Polyline3d poly3d = (Polyline3d)ent3d; ObjectId idPoly3d = poly3d.ObjectId; idEnt3d = idPoly3d; Point3d pnt3dBeg = idPoly3d.getBegPnt(); Point3d pnt3dEnd = idPoly3d.getEndPnt(); bool closed = false; if (pnt3dBeg.isEqual(pnt3dEnd, 0.01)) { closed = true; } ResultBuffer rb = idEnt3d.getXData(nameApp); if (rb == null) { return(idEnt3d); } List <Handle> handles = rb.rb_handles(); int n = 0; for (int i = 0; i < handles.Count; i++) { Point3d pnt3d = handles[i].getCogoPntCoordinates(); idPoly3d.updateVertex(i, pnt3d); n = i; } if (closed) { idPoly3d.updateVertex(n + 1, handles[0].getCogoPntCoordinates()); } } if (ent3d is FeatureLine) { try { DBObject dbObj = ent3d; AeccLandFeatureLine fLine = (AeccLandFeatureLine)dbObj.AcadObject; idEnt3d = ent3d.ObjectId; var points = fLine.GetPoints(AeccLandFeatureLinePointType.aeccLandFeatureLinePointPI); object varType = null; object varVal = null; fLine.GetXData(apps.lnkBrks, out varType, out varVal); fLine = null; List <Handle> handles = Base_VB.myUtility.comXDataToList(varVal); using (Transaction tr = BaseObjs.startTransactionDb()) { AeccLandFeatureLine oFL = (AeccLandFeatureLine)dbObj.AcadObject; for (int i = 0; i < handles.Count; i++) { Point3d pnt3d = handles[i].getCogoPntCoordinates(); double[] varPoint = new double[3]; varPoint[0] = pnt3d.X; varPoint[1] = pnt3d.Y; varPoint[2] = pnt3d.Z; oFL.SetPointElevation((object)varPoint); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Grading_Utility.cs: line: 193"); } } return(idEnt3d); }