New Text Document
New Text Document
New Text Document
IO;
using System.Windows.Forms;
using System;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using GenXCTool.utils;
using System.Collections;
using Application = Autodesk.AutoCAD.ApplicationServices.Application;
using Polyline = Autodesk.AutoCAD.DatabaseServices.Polyline;
using System.Collections.Generic;
using System.Data.SQLite;
using Autodesk.AutoCAD.ApplicationServices;
using System.Data;
using System.Linq;
using System.Net;
using System.Xml;
using Autodesk.AutoCAD.GraphicsInterface;
using Viewport = Autodesk.AutoCAD.DatabaseServices.Viewport;
namespace GenXCTool.Class
{
public class CClass
{
var ed = doc.Editor;
var db = doc.Database;
return p;
}
// var ed = doc.Editor;
// var db = doc.Database;
// return p;
//}
public Point3d LatLongFromPoint2d(Point3d P)
{
var doc = Application.DocumentManager.MdiActiveDocument;
var ed = doc.Editor;
var db = doc.Database;
return p;
}
tr.Commit();
return outPt;
}
}
return p2;
}
public string getBetween(string Data, string St, string En)
{
int Start, End;
if (Data.Contains(St) && Data.Contains(En))
{
Start = Data.IndexOf(St, 0) + St.Length;
End = Data.IndexOf(En, Start);
return Data.Substring(Start, End - Start);
}
else
{
return "";
}
}
if (doc == null)
return;
var ed = doc.Editor;
var db = doc.Database;
try
{
var gdId = db.GeoDataObject;
hasGeoData = true;
}
catch { }
if (hasGeoData)
{
ed.WriteMessage("\nDrawing already has geo-location data!");
return;
}
data.BlockTableRecordId = msId;
data.PostToDb();
data.CoordinateSystem = "WORLD-MERCATOR";
data.TypeOfCoordinates = TypeOfCoordinates.CoordinateTypeGrid;
var wcsPt = data.TransformFromLonLatAlt(PC);
data.DesignPoint = wcsPt;
data.ReferencePoint = PC;
ed.Command("_.GEOMAP", "_AERIAL");
}
if (clockwise)
{
bulge = -bulge;
}
}
return bulge;
}
public Point2d ArcCentroid(Point2d start, Point2d end, Point2d cen, double
tmpArea)
{
double chord = start.GetDistanceTo(end);
double angle = (end - start).Angle;
return Polar2d(cen, angle - (Math.PI / 2.0), (chord * chord * chord) /
(12.0 * tmpArea));
}
if (pl.GetSegmentType(0) == SegmentType.Arc)
{
double[] datas = GetArcGeom(pl, pl.GetBulgeAt(0), 0, 1);
area = datas[0];
cen = new Point2d(datas[1], datas[2]) * datas[0];
}
for (int i = 1; i < last; i++)
{
tmpArea = TriangleAlgebricArea(p0, pl.GetPoint2dAt(i),
pl.GetPoint2dAt(i + 1));
tmpPoint = TriangleCentroid(p0, pl.GetPoint2dAt(i),
pl.GetPoint2dAt(i + 1));
cen += (tmpPoint * tmpArea).GetAsVector();
area += tmpArea;
if (pl.GetSegmentType(i) == SegmentType.Arc)
{
double[] datas = GetArcGeom(pl, pl.GetBulgeAt(i), i, i + 1);
area += datas[0];
cen += new Vector2d(datas[1], datas[2]) * datas[0];
}
}
if (pl.GetSegmentType(last) == SegmentType.Arc)
{
double[] datas = GetArcGeom(pl, pl.GetBulgeAt(last), last, 0);
area += datas[0];
cen += new Vector2d(datas[1], datas[2]) * datas[0];
}
cen = cen.DivideBy(area);
Point3d result = new Point3d(cen.X, cen.Y, pl.Elevation);
return result.TransformBy(Matrix3d.PlaneToWorld(pl.Normal));
}
}
documentloc = document.LockDocument();
database = document.Database;
transaction = database.TransactionManager.StartTransaction();
blockTable = transaction.GetObject(database.BlockTableId,
OpenMode.ForWrite) as BlockTable;
layerTable = transaction.GetObject(database.LayerTableId,
OpenMode.ForWrite) as LayerTable;
blockTableRecordMe =
transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
as BlockTableRecord;
blockTableRecordPe =
transaction.GetObject(blockTable[BlockTableRecord.PaperSpace], OpenMode.ForWrite)
as BlockTableRecord;
editor = document.Editor;
}
if (dist > 0)
{
DBObjectCollection PloffSet1 = rute.GetOffsetCurves(dist);
rute.ReverseCurve();
DBObjectCollection PloffSet2 = rute.GetOffsetCurves(dist);
rute.ReverseCurve();
Polyline pl1buffer = new Polyline();
Polyline pl2buffer = new Polyline();
foreach (Polyline item in PloffSet1) pl1buffer = item;
foreach (Polyline item in PloffSet2) pl2buffer = item;
//Line ln = new Line(pl1buffer.EndPoint, pl2buffer.EndPoint);
//pl1buffer.JoinEntity(ln);
//pl1buffer.JoinEntity(pl2buffer);
//pl1buffer.Closed = true;
//REVISAR ESTO
//pl2buffer.ReverseCurve();
pllist.Add(pl1buffer);
pllist.Add(pl2buffer);
}
else
{
pllist.Add(rute);
}
foreach (Polyline PlB in pllist)
{
for (int i = 0; i < PlB.NumberOfVertices; i++)
{
buffer.Add(PlB.GetPoint3dAt(i));
if (PlB.GetPoint3dAt(i) !=
PlB.GetPoint3dAt(PlB.NumberOfVertices - 1))
{
if (PlB.GetSegmentType(i).ToString() == "Arc")
{
for (double j =
PlB.GetDistAtPoint(PlB.GetPoint3dAt(i)) + 1; j <
PlB.GetDistAtPoint(PlB.GetPoint3dAt(i + 1)); j++)
{
if (!buffer.Contains(PlB.GetPointAtDist(j)))
{
buffer.Add(PlB.GetPointAtDist(j));
}
}
}
}
}
if (PlB.Closed)
{
if (PlB.GetSegmentType(PlB.NumberOfVertices - 1).ToString()
== "Arc")
{
for (double j =
PlB.GetDistAtPoint(PlB.GetPoint3dAt(PlB.NumberOfVertices - 1)) + 1; j < PlB.Length;
j++)
{
buffer.Add(PlB.GetPointAtDist(j));
}
}
buffer.Add(PlB.EndPoint);
}
}
}
return buffer;
}
Insert(pl, true);
}
return LBuffer;
}
transaction.AddNewlyCreatedDBObject(OB, true);
}
transaction.AddNewlyCreatedDBObject(OB, true);
}
blockTableRecordMe.AppendEntity(Br);
transaction.AddNewlyCreatedDBObject(Br, true);
}
else
{
MessageBox.Show("Error When Copying Or Inserting Block");
}
}
BlockTableRecord blockDef =
blockTable[name].GetObject(OpenMode.ForRead) as BlockTableRecord;
if (M)
blockTableRecordMe.AppendEntity(OB);
else
blockTableRecordPe.AppendEntity(OB);
transaction.AddNewlyCreatedDBObject(OB, true);
DynamicBlockReferencePropertyCollection pc =
OB.DynamicBlockReferencePropertyCollection;
if (obj is AttributeDefinition)
{
AttributeDefinition attDef = obj as AttributeDefinition;
attRef.Visible = true;
OB.AttributeCollection.AppendAttribute(attRef);
transaction.AddNewlyCreatedDBObject(attRef, true);
}
}
}
}
transaction.AddNewlyCreatedDBObject(OB, true);
}
if (M)
blockTableRecordMe.AppendEntity(OB);
else
blockTableRecordPe.AppendEntity(OB);
transaction.AddNewlyCreatedDBObject(OB, true);
}
transaction.AddNewlyCreatedDBObject(OB, true);
}
transaction.AddNewlyCreatedDBObject(OB, true);
if (OB is BlockReference)
{
BlockReference blockReference = (BlockReference)OB;
BlockTableRecord blockDef =
blockTable[name].GetObject(OpenMode.ForRead) as BlockTableRecord;
if ((attDef != null))
{
attRef.TextString = "";
attRef.Visible = true;
blockReference.AttributeCollection.AppendAttribute(attRef);
transaction.AddNewlyCreatedDBObject(attRef, true);
}
}
}
}
return En;
}
if(!Find)
{
if (Copy_Block(Block_Name))
{
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
foreach(string S in Layers)
{
if (S == Layer_Name)
{
Find = true;
}
}
if (!Find)
{
if (Copy_Layer(Layer_Name))
{
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
try
{
Autodesk.AutoCAD.DatabaseServices.TransactionManager
Sor_Trans_Manager = Sor_Db.TransactionManager;
BlockTable Block_Table =
(BlockTable)Sor_Trans.GetObject(Sor_Db.BlockTableId, OpenMode.ForRead, false);
BlockTableRecord Block_Table_Record =
(BlockTableRecord)Sor_Trans.GetObject(Block_Table_Id, OpenMode.ForRead, false);
if (!Block_Table_Record.IsAnonymous && !
Block_Table_Record.IsLayout && Block_Table_Record.Name == Block_Name)
Blocks_Id.Add(Block_Table_Id);
Block_Table_Record.Dispose();
RETURN = true;
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
EDITOR.WriteMessage("\nError during copy: " + ex.Message);
RETURN = false;
}
Sor_Db.Dispose();
return RETURN;
}
return false;
}
else
{
var ids = new ObjectIdCollection();
ids.Add(layerTable[Layer_Name]);
var mapping = new IdMapping();
db.WblockCloneObjects(ids, curDb.LayerTableId, mapping,
DuplicateRecordCloning.Replace, false);
return true;
}
}
}
return RETURN;
}
}
// start angle.)
if (a.StartAngle > a.EndAngle)
{
newStart = a.StartAngle - 8 * Math.Atan(1);
}
else
{
newStart = a.StartAngle;
}
// Bulge is defined as the tan of
return bulge;
if (bulge != 0.0)
{
double[] datas = GetArcGeom(pl, bulge, 0, 1);
area = datas[0];
cen = new Point2d(datas[1], datas[2]) * datas[0];
}
for (int i = 1; i < last; i++)
{
tmpArea = TriangleAlgebricArea(p0, pl.GetPoint2dAt(i),
pl.GetPoint2dAt(i + 1));
tmpPoint = TriangleCentroid(p0, pl.GetPoint2dAt(i),
pl.GetPoint2dAt(i + 1));
cen += (tmpPoint * tmpArea).GetAsVector();
area += tmpArea;
bulge = pl.GetBulgeAt(i);
if (bulge != 0.0)
{
double[] datas = GetArcGeom(pl, bulge, i, i + 1);
area += datas[0];
cen += new Vector2d(datas[1], datas[2]) * datas[0];
}
}
bulge = pl.GetBulgeAt(last);
if (bulge != 0.0)
{
double[] datas = GetArcGeom(pl, bulge, last, 0);
area += datas[0];
cen += new Vector2d(datas[1], datas[2]) * datas[0];
}
cen = cen.DivideBy(area);
Point3d result = new Point3d(cen.X, cen.Y, pl.Elevation);
return result.TransformBy(Matrix3d.PlaneToWorld(pl.Normal));
}
if (bulge != 0.0)
{
double[] datas = GetArcGeom(pl, bulge, 0, 1);
area = datas[0];
cen = new Point2d(datas[1], datas[2]) * datas[0];
}
for (int i = 1; i < last; i++)
{
tmpArea = TriangleAlgebricArea(p0, pl.GetPoint2dAt(i),
pl.GetPoint2dAt(i + 1));
tmpPoint = TriangleCentroid(p0, pl.GetPoint2dAt(i),
pl.GetPoint2dAt(i + 1));
cen += (tmpPoint * tmpArea).GetAsVector();
area += tmpArea;
bulge = pl.GetBulgeAt(i);
if (bulge != 0.0)
{
double[] datas = GetArcGeom(pl, bulge, i, i + 1);
area += datas[0];
cen += new Vector2d(datas[1], datas[2]) * datas[0];
}
}
bulge = pl.GetBulgeAt(last);
if (bulge != 0.0)
{
double[] datas = GetArcGeom(pl, bulge, last, 0);
area += datas[0];
cen += new Vector2d(datas[1], datas[2]) * datas[0];
}
cen = cen.DivideBy(area);
Point3d result = new Point3d(cen.X, cen.Y, pl.Elevation);
result = result.TransformBy(Matrix3d.PlaneToWorld(pl.Normal));
return new Point2d(result.X, result.Y);
}
#endregion
}
// while (!reader.EndOfStream)
// {
// string[] comas;
// string line = reader.ReadLine();
// string[] values = line.Split(',');
// if (lines == 0)
// for (int c = 0; c < values.Length; c++)
// if (values[c] == "pole_owner")
// pole_owner_p = c;
// else if (values[c] == "material")
// material_p = c;
// else if (values[c] == "pole_class")
// pole_class_p = c;
// else if (values[c] == "ground")
// ground_p = c;
// else if (values[c] == "telco_first_attachment")
// telco_first_attachment_p = c;
// else if (values[c] == "telco_second_attachment")
// telco_second_attachment_p = c;
// else if (values[c] == "comcast")
// comcast_p = c;
// else if (values[c] == "catv_second_attachment")
// catv_second_attachment_p = c;
// else if (values[c] == "streetlight")
// streetlight_p = c;
// else if (values[c] == "secondaryneutral")
// secondaryneutral_p = c;
// else if (values[c] == "transfer" || values[c] ==
"general_notes")
// transfer_p = c;
// else if (values[c] == "pole_tag")
// pole_tag_p = c;
// if (lines == P && P != 0)
// {
// pole_owner = values[pole_owner_p];
// if (pole_tag_p != 0)
// {
// pole_tag = values[pole_tag_p];
// }
// if(pole_class_p != 0)
// pole_class = values[pole_class_p];
// if (ground_p != 0)
// ground = values[ground_p];
// if(telco_first_attachment_p != 0)
// telco_first_attachment =
values[telco_first_attachment_p];
// if(telco_second_attachment_p != 0)
// telco_second_attachment =
values[telco_second_attachment_p];
// if(comcast_p != 0)
// comcast = values[comcast_p];
// if(catv_second_attachment_p != 0)
// catv_second_attachment =
values[catv_second_attachment_p];
// if(streetlight_p != 0)
// streetlight = values[streetlight_p];
// if(secondaryneutral_p != 0)
// secondaryneutral = values[secondaryneutral_p];
// if(transfer_p != 0)
// transfer = values[transfer_p];
// try
// {
// if (pole_tag != " " && pole_tag != "")
// {
// Data += "Pole#: " +
Convert.ToInt32(pole_tag).ToString();
// }
// }
// catch (Exception)
// {
// Data += pole_tag;
// }
// if (transfer.Contains("Yes") ||
transfer.Contains("Transfer"))
// {
// Data += "\n" + transfer;
// }
// }
// else
// {
// try
// {
// if (pole_tag != " " && pole_tag != "")
// {
// Data += "Pole#: " +
Convert.ToInt32(pole_tag).ToString();
// }
// }
// catch (Exception)
// {
// Data += pole_tag;
// }
// }
// lines++;
// }
// return Data.ToUpper();
// }
// catch (Exception Ex)
// {
// MessageBox.Show(Ex + "");
// return "Explote";
// }
//}
while (!reader.EndOfStream)
{
string[] comas;
string line = reader.ReadLine();
string[] values = line.Split(',');
if (lines == 0)
for (int c = 0; c < values.Length; c++)
if (values[c] == "fulcrum_id")
fulcrum_id_p = c;
else if (values[c] == "fulcrum_parent_id")
fulcrum_parent_id_p = c;
else if (values[c] == "fulcrum_record_id")
fulcrum_record_id_p = c;
else if (values[c] == "version")
version_p = c;
else if (values[c] == "latitude")
latitude_p = c;
else if (values[c] == "longitude")
longitude_p = c;
else if (values[c] == "geometry")
geometry_p = c;
else if (values[c] == "created_at")
created_at_p = c;
else if (values[c] == "updated_at")
updated_at_p = c;
else if (values[c] == "created_by")
created_by_p = c;
else if (values[c] == "updated_by")
updated_by_p = c;
else if (values[c] == "pole_owner")
pole_owner_p = c;
else if (values[c] == "pole_tag")
pole_tag_p = c;
else if (values[c] == "pole_address_sub_thoroughfare")
pole_address_sub_thoroughfare_p = c;
else if (values[c] == "pole_address_thoroughfare")
pole_address_thoroughfare_p = c;
else if (values[c] == "pole_address_suite")
pole_address_suite_p = c;
else if (values[c] == "pole_address_locality")
pole_address_locality_p = c;
else if (values[c] == "pole_address_sub_admin_area")
pole_address_sub_admin_area_p = c;
else if (values[c] == "pole_address_admin_area")
pole_address_admin_area_p = c;
else if (values[c] == "pole_address_postal_code")
pole_address_postal_code_p = c;
else if (values[c] == "pole_address_country")
pole_address_country_p = c;
else if (values[c] == "pole_address_full")
pole_address_full_p = c;
else if (values[c] == "pole_boc_eop_measurement")
pole_boc_eop_measurement_p = c;
else if (values[c] == "pole_class")
pole_class_p = c;
else if (values[c] == "material")
material_p = c;
else if (values[c] == "strand_size")
strand_size_p = c;
else if (values[c] == "guying")
guying_p = c;
else if (values[c] == "joint_use_anchor_1")
joint_use_anchor_1_p = c;
else if (values[c] == "proposed_or_existing_1")
proposed_or_existing_1_p = c;
else if (values[c] == "anchor_size_1")
anchor_size_1_p = c;
else if (values[c] == "down_guy_wire_size_1")
down_guy_wire_size_1_p = c;
else if (values[c] == "lead_1")
lead_1_p = c;
else if (values[c] == "guy_quantity_1")
guy_quantity_1_p = c;
else if (values[c] == "guy_hoa_1")
guy_hoa_1_p = c;
else if (values[c] == "pull_1")
pull_1_p = c;
else if (values[c] == "bearing_1")
bearing_1_p = c;
else if (values[c] == "number_of_eyes_1")
number_of_eyes_1_p = c;
else if (values[c] == "joint_use_anchor_2")
joint_use_anchor_2_p = c;
else if (values[c] == "proposed_or_existing_2")
proposed_or_existing_2_p = c;
else if (values[c] == "anchor_size_2")
anchor_size_2_p = c;
else if (values[c] == "down_guy_wire_size_2")
down_guy_wire_size_2_p = c;
else if (values[c] == "lead_2")
lead_2_p = c;
else if (values[c] == "guy_quantity_2")
guy_quantity_2_p = c;
else if (values[c] == "guy_hoa_2")
guy_hoa_2_p = c;
else if (values[c] == "pull_2")
pull_2_p = c;
else if (values[c] == "bearing_2")
bearing_2_p = c;
else if (values[c] == "number_of_eyes_2")
number_of_eyes_2_p = c;
else if (values[c] == "joint_use_anchor_3")
joint_use_anchor_3_p = c;
else if (values[c] == "proposed_or_existing_3")
proposed_or_existing_3_p = c;
else if (values[c] == "anchor_size_3")
anchor_size_3_p = c;
else if (values[c] == "down_guy_wire_size_3")
down_guy_wire_size_3_p = c;
else if (values[c] == "lead_3")
lead_3_p = c;
else if (values[c] == "guy_quantity_3")
guy_quantity_3_p = c;
else if (values[c] == "guy_hoa_3")
guy_hoa_3_p = c;
else if (values[c] == "pull_3")
pull_3_p = c;
else if (values[c] == "bearing_3")
bearing_3_p = c;
else if (values[c] == "number_of_eyes_3")
number_of_eyes_3_p = c;
else if (values[c] == "joint_use_anchor_4")
joint_use_anchor_4_p = c;
else if (values[c] == "proposed_or_existing_4")
proposed_or_existing_4_p = c;
else if (values[c] == "anchor_size_4")
anchor_size_4_p = c;
else if (values[c] == "down_guy_wire_size_4")
down_guy_wire_size_4_p = c;
else if (values[c] == "lead_4")
lead_4_p = c;
else if (values[c] == "guy_quantity_4")
guy_quantity_4_p = c;
else if (values[c] == "guy_hoa_4")
guy_hoa_4_p = c;
else if (values[c] == "pull_4")
pull_4_p = c;
else if (values[c] == "bearing_4")
bearing_4_p = c;
else if (values[c] == "number_of_eyes_4")
number_of_eyes_4_p = c;
else if (values[c] == "telco_first_attachment")
telco_first_attachment_p = c;
else if (values[c] == "telco_second_attachment")
telco_second_attachment_p = c;
else if (values[c] == "roadside_attachment")
roadside_attachment_p = c;
else if (values[c] == "catv_first_attachment")
catv_first_attachment_p = c;
else if (values[c] == "catv_second_attachment")
catv_second_attachment_p = c;
else if (values[c] == "roadside_attachment_2")
roadside_attachment_2_p = c;
else if (values[c] == "provider_1")
provider_1_p = c;
else if (values[c] == "hoa_1")
hoa_1_p = c;
else if (values[c] == "provider_2")
provider_2_p = c;
else if (values[c] == "hoa_2")
hoa_2_p = c;
else if (values[c] == "provider_3")
provider_3_p = c;
else if (values[c] == "hoa_3")
hoa_3_p = c;
else if (values[c] == "provider_4")
provider_4_p = c;
else if (values[c] == "hoa_4")
hoa_4_p = c;
else if (values[c] == "provider_5")
provider_5_p = c;
else if (values[c] == "hoa_5")
hoa_5_p = c;
else if (values[c] == "secondaryneutral")
secondaryneutral_p = c;
else if (values[c] == "streetlight")
streetlight_p = c;
else if (values[c] == "transformer")
transformer_p = c;
else if (values[c] == "ground")
ground_p = c;
else if (values[c] == "general_notes")
general_notes_p = c;
else if (values[c] == "damage_notes")
damage_notes_p = c;
else if (values[c] == "photo")
photo_p = c;
else if (values[c] == "photo_caption")
photo_caption_p = c;
else if (values[c] == "photo_url")
photo_url_p = c;
if (fulcrum_id_p != 0)
fulcrum_id = values[fulcrum_id_p];
if (fulcrum_parent_id_p != 0)
fulcrum_parent_id = values[fulcrum_parent_id_p];
if (fulcrum_record_id_p != 0)
fulcrum_record_id = values[fulcrum_record_id_p];
if (version_p != 0)
version = values[version_p];
if (latitude_p != 0)
latitude = values[latitude_p];
if (longitude_p != 0)
longitude = values[longitude_p];
if (geometry_p != 0)
geometry = values[geometry_p];
if (created_at_p != 0)
created_at = values[created_at_p];
if (updated_at_p != 0)
updated_at = values[updated_at_p];
if (created_by_p != 0)
created_by = values[created_by_p];
if (updated_by_p != 0)
updated_by = values[updated_by_p];
if (pole_owner_p != 0)
pole_owner = values[pole_owner_p];
if (pole_tag_p != 0)
pole_tag = values[pole_tag_p];
if (pole_address_sub_thoroughfare_p != 0)
pole_address_sub_thoroughfare =
values[pole_address_sub_thoroughfare_p];
if (pole_address_thoroughfare_p != 0)
pole_address_thoroughfare =
values[pole_address_thoroughfare_p];
if (pole_address_suite_p != 0)
pole_address_suite = values[pole_address_suite_p];
if (pole_address_locality_p != 0)
pole_address_locality = values[pole_address_locality_p];
if (pole_address_sub_admin_area_p != 0)
pole_address_sub_admin_area =
values[pole_address_sub_admin_area_p];
if (pole_address_admin_area_p != 0)
pole_address_admin_area =
values[pole_address_admin_area_p];
if (pole_address_postal_code_p != 0)
pole_address_postal_code =
values[pole_address_postal_code_p];
if (pole_address_country_p != 0)
pole_address_country = values[pole_address_country_p];
if (pole_address_full_p != 0)
pole_address_full = values[pole_address_full_p];
if (pole_boc_eop_measurement_p != 0)
pole_boc_eop_measurement =
values[pole_boc_eop_measurement_p];
if (pole_class_p != 0)
pole_class = values[pole_class_p];
if (material_p != 0)
material = values[material_p];
if (strand_size_p != 0)
strand_size = values[strand_size_p];
if (guying_p != 0)
guying = values[guying_p];
if (joint_use_anchor_1_p != 0)
joint_use_anchor_1 = values[joint_use_anchor_1_p];
if (proposed_or_existing_1_p != 0)
proposed_or_existing_1 = values[proposed_or_existing_1_p];
if (anchor_size_1_p != 0)
anchor_size_1 = values[anchor_size_1_p];
if (down_guy_wire_size_1_p != 0)
down_guy_wire_size_1 = values[down_guy_wire_size_1_p];
if (lead_1_p != 0)
lead_1 = values[lead_1_p];
if (guy_quantity_1_p != 0)
guy_quantity_1 = values[guy_quantity_1_p];
if (guy_hoa_1_p != 0)
guy_hoa_1 = values[guy_hoa_1_p];
if (pull_1_p != 0)
pull_1 = values[pull_1_p];
if (bearing_1_p != 0)
bearing_1 = values[bearing_1_p];
if (number_of_eyes_1_p != 0)
number_of_eyes_1 = values[number_of_eyes_1_p];
if (joint_use_anchor_2_p != 0)
joint_use_anchor_2 = values[joint_use_anchor_2_p];
if (proposed_or_existing_2_p != 0)
proposed_or_existing_2 = values[proposed_or_existing_2_p];
if (anchor_size_2_p != 0)
anchor_size_2 = values[anchor_size_2_p];
if (down_guy_wire_size_2_p != 0)
down_guy_wire_size_2 = values[down_guy_wire_size_2_p];
if (lead_2_p != 0)
lead_2 = values[lead_2_p];
if (guy_quantity_2_p != 0)
guy_quantity_2 = values[guy_quantity_2_p];
if (guy_hoa_2_p != 0)
guy_hoa_2 = values[guy_hoa_2_p];
if (pull_2_p != 0)
pull_2 = values[pull_2_p];
if (bearing_2_p != 0)
bearing_2 = values[bearing_2_p];
if (number_of_eyes_2_p != 0)
number_of_eyes_2 = values[number_of_eyes_2_p];
if (joint_use_anchor_3_p != 0)
joint_use_anchor_3 = values[joint_use_anchor_3_p];
if (proposed_or_existing_3_p != 0)
proposed_or_existing_3 = values[proposed_or_existing_3_p];
if (anchor_size_3_p != 0)
anchor_size_3 = values[anchor_size_3_p];
if (down_guy_wire_size_3_p != 0)
down_guy_wire_size_3 = values[down_guy_wire_size_3_p];
if (lead_3_p != 0)
lead_3 = values[lead_3_p];
if (guy_quantity_3_p != 0)
guy_quantity_3 = values[guy_quantity_3_p];
if (guy_hoa_3_p != 0)
guy_hoa_3 = values[guy_hoa_3_p];
if (pull_3_p != 0)
pull_3 = values[pull_3_p];
if (bearing_3_p != 0)
bearing_3 = values[bearing_3_p];
if (number_of_eyes_3_p != 0)
number_of_eyes_3 = values[number_of_eyes_3_p];
if (joint_use_anchor_4_p != 0)
joint_use_anchor_4 = values[joint_use_anchor_4_p];
if (proposed_or_existing_4_p != 0)
proposed_or_existing_4 = values[proposed_or_existing_4_p];
if (anchor_size_4_p != 0)
anchor_size_4 = values[anchor_size_4_p];
if (down_guy_wire_size_4_p != 0)
down_guy_wire_size_4 = values[down_guy_wire_size_4_p];
if (lead_4_p != 0)
lead_4 = values[lead_4_p];
if (guy_quantity_4_p != 0)
guy_quantity_4 = values[guy_quantity_4_p];
if (guy_hoa_4_p != 0)
guy_hoa_4 = values[guy_hoa_4_p];
if (pull_4_p != 0)
pull_4 = values[pull_4_p];
if (bearing_4_p != 0)
bearing_4 = values[bearing_4_p];
if (number_of_eyes_4_p != 0)
number_of_eyes_4 = values[number_of_eyes_4_p];
if (telco_first_attachment_p != 0)
telco_first_attachment = values[telco_first_attachment_p];
if (telco_second_attachment_p != 0)
telco_second_attachment =
values[telco_second_attachment_p];
if (roadside_attachment_p != 0)
roadside_attachment = values[roadside_attachment_p];
if (catv_first_attachment_p != 0)
catv_first_attachment = values[catv_first_attachment_p];
if (catv_second_attachment_p != 0)
catv_second_attachment = values[catv_second_attachment_p];
if (roadside_attachment_2_p != 0)
roadside_attachment_2 = values[roadside_attachment_2_p];
if (provider_1_p != 0)
provider_1 = values[provider_1_p];
if (hoa_1_p != 0)
hoa_1 = values[hoa_1_p];
if (provider_2_p != 0)
provider_2 = values[provider_2_p];
if (hoa_2_p != 0)
hoa_2 = values[hoa_2_p];
if (provider_3_p != 0)
provider_3 = values[provider_3_p];
if (hoa_3_p != 0)
hoa_3 = values[hoa_3_p];
if (provider_4_p != 0)
provider_4 = values[provider_4_p];
if (hoa_4_p != 0)
hoa_4 = values[hoa_4_p];
if (provider_5_p != 0)
provider_5 = values[provider_5_p];
if (hoa_5_p != 0)
hoa_5 = values[hoa_5_p];
if (secondaryneutral_p != 0)
secondaryneutral = values[secondaryneutral_p];
if (streetlight_p != 0)
streetlight = values[streetlight_p];
if (transformer_p != 0)
transformer = values[transformer_p];
if (ground_p != 0)
ground = values[ground_p];
if (general_notes_p != 0)
general_notes = values[general_notes_p];
if (damage_notes_p != 0)
damage_notes = values[damage_notes_p];
if (photo_p != 0)
photo = values[photo_p];
if (photo_caption_p != 0)
photo_caption = values[photo_caption_p];
if (photo_url_p != 0)
photo_url = values[photo_url_p];
if (lines == P && P != 0)
{
if (pole_owner != " " && pole_owner != "")
{
Data += "pole_owner: " + pole_owner + "\n";
}
if (pole_tag != " " && pole_tag != "")
{
Data += "pole_tag: " + pole_tag + "\n";
}
if (pole_address_full != " " && pole_address_full != "")
{
Data += "pole_address_full: " + pole_address_full + "\
n";
}
if (pole_boc_eop_measurement != " " &&
pole_boc_eop_measurement != "")
{
Data += "pole_boc_eop_measurement: " +
pole_boc_eop_measurement + "\n";
}
if (pole_class != " " && pole_class != "")
{
Data += "pole_class: " + pole_class + "\n";
}
if (material != " " && material != "")
{
Data += "material: " + material + "\n";
}
if (strand_size != " " && strand_size != "")
{
Data += "strand_size: " + strand_size + "\n";
}
if (guying != " " && guying != "")
{
Data += "guying: " + guying + "\n";
}
if (joint_use_anchor_1 != " " && joint_use_anchor_1 != "")
{
Data += "joint_use_anchor_1: " + joint_use_anchor_1 +
"\n";
}
if (proposed_or_existing_1 != " " && proposed_or_existing_1
!= "")
{
Data += "proposed_or_existing_1: " +
proposed_or_existing_1 + "\n";
}
if (anchor_size_1 != " " && anchor_size_1 != "")
{
Data += "anchor_size_1: " + anchor_size_1 + "\n";
}
if (down_guy_wire_size_1 != " " && down_guy_wire_size_1 !=
"")
{
Data += "down_guy_wire_size_1: " + down_guy_wire_size_1
+ "\n";
}
if (lead_1 != " " && lead_1 != "")
{
Data += "lead_1: " + lead_1 + "\n";
}
if (guy_quantity_1 != " " && guy_quantity_1 != "")
{
Data += "guy_quantity_1: " + guy_quantity_1 + "\n";
}
if (guy_hoa_1 != " " && guy_hoa_1 != "")
{
Data += "guy_hoa_1: " + guy_hoa_1 + "\n";
}
if (pull_1 != " " && pull_1 != "")
{
Data += "pull_1: " + pull_1 + "\n";
}
if (bearing_1 != " " && bearing_1 != "")
{
Data += "bearing_1: " + bearing_1 + "\n";
}
if (number_of_eyes_1 != " " && number_of_eyes_1 != "")
{
Data += "number_of_eyes_1: " + number_of_eyes_1 + "\n";
}
if (joint_use_anchor_2 != " " && joint_use_anchor_2 != "")
{
Data += "joint_use_anchor_2: " + joint_use_anchor_2 +
"\n";
}
if (proposed_or_existing_2 != " " && proposed_or_existing_2
!= "")
{
Data += "proposed_or_existing_2: " +
proposed_or_existing_2 + "\n";
}
if (anchor_size_2 != " " && anchor_size_2 != "")
{
Data += "anchor_size_2: " + anchor_size_2 + "\n";
}
if (down_guy_wire_size_2 != " " && down_guy_wire_size_2 !=
"")
{
Data += "down_guy_wire_size_2: " + down_guy_wire_size_2
+ "\n";
}
if (lead_2 != " " && lead_2 != "")
{
Data += "lead_2: " + lead_2 + "\n";
}
if (guy_quantity_2 != " " && guy_quantity_2 != "")
{
Data += "guy_quantity_2: " + guy_quantity_2 + "\n";
}
if (guy_hoa_2 != " " && guy_hoa_2 != "")
{
Data += "guy_hoa_2: " + guy_hoa_2 + "\n";
}
if (pull_2 != " " && pull_2 != "")
{
Data += "pull_2: " + pull_2 + "\n";
}
if (bearing_2 != " " && bearing_2 != "")
{
Data += "bearing_2: " + bearing_2 + "\n";
}
if (number_of_eyes_2 != " " && number_of_eyes_2 != "")
{
Data += "number_of_eyes_2: " + number_of_eyes_2 + "\n";
}
if (joint_use_anchor_3 != " " && joint_use_anchor_3 != "")
{
Data += "joint_use_anchor_3: " + joint_use_anchor_3 +
"\n";
}
if (proposed_or_existing_3 != " " && proposed_or_existing_3
!= "")
{
Data += "proposed_or_existing_3: " +
proposed_or_existing_3 + "\n";
}
if (anchor_size_3 != " " && anchor_size_3 != "")
{
Data += "anchor_size_3: " + anchor_size_3 + "\n";
}
if (down_guy_wire_size_3 != " " && down_guy_wire_size_3 !=
"")
{
Data += "down_guy_wire_size_3: " + down_guy_wire_size_3
+ "\n";
}
if (lead_3 != " " && lead_3 != "")
{
Data += "lead_3: " + lead_3 + "\n";
}
if (guy_quantity_3 != " " && guy_quantity_3 != "")
{
Data += "guy_quantity_3: " + guy_quantity_3 + "\n";
}
if (guy_hoa_3 != " " && guy_hoa_3 != "")
{
Data += "guy_hoa_3: " + guy_hoa_3 + "\n";
}
if (pull_3 != " " && pull_3 != "")
{
Data += "pull_3: " + pull_3 + "\n";
}
if (bearing_3 != " " && bearing_3 != "")
{
Data += "bearing_3: " + bearing_3 + "\n";
}
if (number_of_eyes_3 != " " && number_of_eyes_3 != "")
{
Data += "number_of_eyes_3: " + number_of_eyes_3 + "\n";
}
if (joint_use_anchor_4 != " " && joint_use_anchor_4 != "")
{
Data += "joint_use_anchor_4: " + joint_use_anchor_4 +
"\n";
}
if (proposed_or_existing_4 != " " && proposed_or_existing_4
!= "")
{
Data += "proposed_or_existing_4: " +
proposed_or_existing_4 + "\n";
}
if (anchor_size_4 != " " && anchor_size_4 != "")
{
Data += "anchor_size_4: " + anchor_size_4 + "\n";
}
if (down_guy_wire_size_4 != " " && down_guy_wire_size_4 !=
"")
{
Data += "down_guy_wire_size_4: " + down_guy_wire_size_4
+ "\n";
}
if (lead_4 != " " && lead_4 != "")
{
Data += "lead_4: " + lead_4 + "\n";
}
if (guy_quantity_4 != " " && guy_quantity_4 != "")
{
Data += "guy_quantity_4: " + guy_quantity_4 + "\n";
}
if (guy_hoa_4 != " " && guy_hoa_4 != "")
{
Data += "guy_hoa_4: " + guy_hoa_4 + "\n";
}
if (pull_4 != " " && pull_4 != "")
{
Data += "pull_4: " + pull_4 + "\n";
}
if (bearing_4 != " " && bearing_4 != "")
{
Data += "bearing_4: " + bearing_4 + "\n";
}
if (number_of_eyes_4 != " " && number_of_eyes_4 != "")
{
Data += "number_of_eyes_4: " + number_of_eyes_4 + "\n";
}
if (telco_first_attachment != " " && telco_first_attachment
!= "")
{
Data += "telco_first_attachment: " +
telco_first_attachment + "\n";
}
if (telco_second_attachment != " " &&
telco_second_attachment != "")
{
Data += "telco_second_attachment: " +
telco_second_attachment + "\n";
}
if (roadside_attachment != " " && roadside_attachment !=
"")
{
Data += "roadside_attachment: " + roadside_attachment +
"\n";
}
if (catv_first_attachment != " " && catv_first_attachment !
= "")
{
Data += "catv_first_attachment: " +
catv_first_attachment + "\n";
}
if (catv_second_attachment != " " && catv_second_attachment
!= "")
{
Data += "catv_second_attachment: " +
catv_second_attachment + "\n";
}
if (roadside_attachment_2 != " " && roadside_attachment_2 !
= "")
{
Data += "roadside_attachment_2: " +
roadside_attachment_2 + "\n";
}
if (provider_1 != " " && provider_1 != "")
{
Data += "provider_1: " + provider_1 + "\n";
}
if (hoa_1 != " " && hoa_1 != "")
{
Data += "hoa_1: " + hoa_1 + "\n";
}
if (provider_2 != " " && provider_2 != "")
{
Data += "provider_2: " + provider_2 + "\n";
}
if (hoa_2 != " " && hoa_2 != "")
{
Data += "hoa_2: " + hoa_2 + "\n";
}
if (provider_3 != " " && provider_3 != "")
{
Data += "provider_3: " + provider_3 + "\n";
}
if (hoa_3 != " " && hoa_3 != "")
{
Data += "hoa_3: " + hoa_3 + "\n";
}
if (provider_4 != " " && provider_4 != "")
{
Data += "provider_4: " + provider_4 + "\n";
}
if (hoa_4 != " " && hoa_4 != "")
{
Data += "hoa_4: " + hoa_4 + "\n";
}
if (provider_5 != " " && provider_5 != "")
{
Data += "provider_5: " + provider_5 + "\n";
}
if (hoa_5 != " " && hoa_5 != "")
{
Data += "hoa_5: " + hoa_5 + "\n";
}
if (secondaryneutral != " " && secondaryneutral != "")
{
Data += "secondaryneutral: " + secondaryneutral + "\n";
}
if (streetlight != " " && streetlight != "")
{
Data += "streetlight: " + streetlight + "\n";
}
if (transformer != " " && transformer != "")
{
Data += "transformer: " + transformer + "\n";
}
if (ground != " " && ground != "")
{
Data += "ground: " + ground + "\n";
}
if (general_notes != " " && general_notes != "")
{
Data += "general_notes: " + general_notes + "\n";
}
if (damage_notes != " " && damage_notes != "")
{
Data += "damage_notes: " + damage_notes + "\n";
}
}
lines++;
}
return Data.ToUpper();
}
catch (Exception Ex)
{
MessageBox.Show(Ex + "");
return "Explote";
}
}
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
string[] values = line.Split(',');
if (lines == 0)
for (int c = 0; c < values.Length; c++)
if (values[c] == "photo")
photo_p = c;
else if (values[c] == "latitude")
latitude_p = c;
else if (values[c] == "longitude")
longitude_p = c;
if (lines != 0)
{
decimal lat1 = Math.Round(Convert.ToDecimal(Lat), 5);
decimal lon1 = Math.Round(Convert.ToDecimal(Lon), 5);
decimal lat2 =
Math.Round(Convert.ToDecimal(values[latitude_p]), 5);
decimal lon2 =
Math.Round(Convert.ToDecimal(values[longitude_p]), 5);
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
string[] values = line.Split(',');
if (lines == 0)
for (int c = 0; c < values.Length; c++)
if (values[c] == "proposed_or_existing_1")
proposed_or_existing_1_p = c;
else if (values[c] == "bearing_1")
bearing_1_p = c;
else if (values[c] == "lead_1")
lead_1_p = c;
if (lines == P && P != 0)
{
proposed_or_existing_1 = values[proposed_or_existing_1_p];
bearing_1 = values[bearing_1_p];
lead_1 = values[lead_1_p];
if (proposed_or_existing_1 == "Proposed")
Data += "PROPOSED DOWNGUY AND ANCHOR AT " + lead_1 + "'
LEAD FROM POLE ";
else if (proposed_or_existing_1 == "Existing")
Data += "EXISTING DOWNGUY BEARING" + " " + bearing_1;
//return Dow_Anc_Details.ToUpper();
}
lines++;
}
return Data.ToUpper();
}
catch (Exception Ex)
{
MessageBox.Show(Ex + "");
return "Explote";
}
}
}
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
string[] values = line.Split(',');
if (lines == 0)
for (int c = 0; c < values.Length; c++)
if (values[c] == "environment")
environment_p = c;
else if (values[c] == "aerial_value")
aerial_value_p = c;
if (lines == P && P != 0)
{
environment = values[environment_p];
aerial_value = values[aerial_value_p];
if (environment == "Buried")
Data = "{\\fArial|b1|;\\LDIRECTIONAL BORE -MAX\nBACK
REAMER SIZE =6\" \\P}INSTALL 1\'-2\" HDPE \\PCONDUIT PULL 1-FIBER OPTIC CABLE \\
P(84\" MIN. GROUND COVER)";
else if (environment == "Aerial")
Data = "{\\fArial|b1|;\\LOVERLASH \\P}OVERLASH 1 - FOC
TO \\PEXISTING STRAND \\P{\\C5;" + aerial_value + "\'}";
}
lines++;
}
return Data;
}
catch (Exception Ex)
{
MessageBox.Show(Ex + "");
return "Explote";
}
}
}
try
{
var reader = new StreamReader(S);
int lines = 0;
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
string[] values = line.Split(',');
if (lines == 0)
for (int c = 0; c < values.Length; c++)
if (values[c] == "buried_reference")
buried_reference_p = c;
else if (values[c] == "buried_ref_notes")
buried_ref_notes_p = c;
if (lines == P && P != 0)
{
buried_reference = values[buried_reference_p];
//buried_ref_notes = values[buried_ref_notes_p];
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
string[] values = line.Split(',');
if (lines == 0)
for (int c = 0; c < values.Length; c++)
if (values[c] == "buried_ref_photos")
buried_ref_photos_P = c;
else if (values[c] == "latitude")
latitude_p = c;
else if (values[c] == "longitude")
longitude_p = c;
if (lines != 0)
{
decimal lat1 = Math.Round(Convert.ToDecimal(Lat), 5);
decimal lon1 = Math.Round(Convert.ToDecimal(Lon), 5);
decimal lat2 =
Math.Round(Convert.ToDecimal(values[latitude_p]), 5);
decimal lon2 =
Math.Round(Convert.ToDecimal(values[longitude_p]), 5);
try
{
var reader = new StreamReader(S);
int lines = 0;
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
string[] values = line.Split(',');
if (lines == 0)
for (int c = 0; c < values.Length; c++)
if (values[c] == "midspan_clearance")
midspan_clearance_p = c;
if (lines == P && P != 0)
{
midspan_clearance = values[midspan_clearance_p];
values = midspan_clearance.Split('-');
Data = "Clearance " + values[0] + "\'-" + values[1] + "\"";
return Data.ToUpper();
}
lines++;
}
return Data.ToUpper();
}
catch (Exception Ex)
{
MessageBox.Show(Ex + "");
return Data;
}
}
}
public double GSLat { get => Lat; set => Lat = value; }
public double GSLon { get => Lon; set => Lon = value; }
var ed = doc.Editor;
var db = doc.Database;
return p;
}
tr.Commit();
return outPt;
}
}
Lat1 *= deg2radMultiplier;
lon1 *= deg2radMultiplier;
Lat2 *= deg2radMultiplier;
lon2 *= deg2radMultiplier;
return (distance);
}
if (bulge != 0.0)
{
double[] datas = GetArcGeom(pl, bulge, 0, 1);
area = datas[0];
cen = new Point2d(datas[1], datas[2]) * datas[0];
}
for (int i = 1; i < last; i++)
{
tmpArea = TriangleAlgebricArea(p0, pl.GetPoint2dAt(i),
pl.GetPoint2dAt(i + 1));
tmpPoint = TriangleCentroid(p0, pl.GetPoint2dAt(i),
pl.GetPoint2dAt(i + 1));
cen += (tmpPoint * tmpArea).GetAsVector();
area += tmpArea;
bulge = pl.GetBulgeAt(i);
if (bulge != 0.0)
{
double[] datas = GetArcGeom(pl, bulge, i, i + 1);
area += datas[0];
cen += new Vector2d(datas[1], datas[2]) * datas[0];
}
}
bulge = pl.GetBulgeAt(last);
if (bulge != 0.0)
{
double[] datas = GetArcGeom(pl, bulge, last, 0);
area += datas[0];
cen += new Vector2d(datas[1], datas[2]) * datas[0];
}
cen = cen.DivideBy(area);
Point3d result = new Point3d(cen.X, cen.Y, pl.Elevation);
return result.TransformBy(Matrix3d.PlaneToWorld(pl.Normal));
}
try
{
var reader = new StreamReader(SF);
int lines = 0;
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
string[] values = line.Split(',');
if (lines == 0)
for (int c = 0; c < values.Length; c++)
if (values[c] == "station_reference")
station_referenceP = c;
else if (values[c] == "sta")
staP = c;
if (lines == P && P != 0)
{
station_reference = values[station_referenceP];
sta = values[staP];
Data = (station_reference + "\n" + sta).ToString();
return Data.ToUpper();
}
lines++;
}
return Data.ToUpper();
}
catch (Exception Ex)
{
MessageBox.Show(Ex + "");
return Data;
}
}
}
// Start a transaction
using (Transaction acTrans = db.TransactionManager.StartTransaction())
{
// Open the Layer table for read
LayerTable acLyrTbl;
acLyrTbl = acTrans.GetObject(db.LayerTableId, OpenMode.ForRead) as
LayerTable;
foreach (ObjectId acObjId in acLyrTbl)
{
LayerTableRecord acLyrTblRec;
acLyrTblRec = acTrans.GetObject(acObjId, OpenMode.ForRead) as
LayerTableRecord;
Layers.Add(acLyrTblRec.Name);
}
}
// Start a transaction
using (Transaction acTrans = db.TransactionManager.StartTransaction())
{
// Open the Layer table for read
LayerTable acLyrTbl;
acLyrTbl = acTrans.GetObject(db.LayerTableId, OpenMode.ForRead) as
LayerTable;
foreach (ObjectId acObjId in acLyrTbl)
{
LayerTableRecord acLyrTblRec;
acLyrTblRec = acTrans.GetObject(acObjId, OpenMode.ForRead) as
LayerTableRecord;
Layers.Add(acLyrTblRec.Name);
}
}
Layers.Sort();
return Layers;
}
return layerTableRecord.IsOff;
}
}
}
// Start a transaction
using (Transaction acTrans =
acCurDb.TransactionManager.StartTransaction())
{
// Open the Layer table for read
BlockTable table =
(BlockTable)acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead);
Blocks.Sort();
// Start a transaction
using (Transaction acTrans =
acCurDb.TransactionManager.StartTransaction())
{
// Open the Layer table for read
BlockTable table =
(BlockTable)acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead);
Blocks.Sort();
return Blocks;
}
CbLatitude.Items.AddRange(headers);
CbLongitude.Items.AddRange(headers);
CbLatitude.Text = "latitude";
CbLongitude.Text = "longitude";
}
catch (Exception)
{
Application.ShowAlertDialog("Close file and try");
TbLoa.Text = "";
}
}
}
}
string s;
using (var reader = new StreamReader(TBLoadKML.Text))
{
while (!reader.EndOfStream)
{
s = reader.ReadLine();
if (s.Contains("<coordinates>"))
{
string info = getBetween(s, "<coordinates>",
"</coordinates>");
acBlkTbl = acTrans.GetObject(db.BlockTableId,
OpenMode.ForRead) as BlockTable;
acBlkTblRec =
acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as
BlockTableRecord;
using (Polyline acPoly = new Polyline())
{
acPoly.Layer = "ROW";
TempArrayData = j[0].Split(',');
TemArrLis.Add(TempArrayData[0]);
TemArrLis.Add(TempArrayData[1]);
int p = 0;
acPoly.AddVertexAt(acPoly.NumberOfVertices, new
Point2d(P.PointFromLatLong(Point).X, P.PointFromLatLong(Point).Y), 0, 0, 0);
}
acBlkTblRec.AppendEntity(acPoly);
acTrans.AddNewlyCreatedDBObject(acPoly, true);
acPoly.Closed = true;
}
}
}
}
acTrans.Commit();
acTrans.Dispose();
}
db.Dispose();
MessageBox.Show("Draw Complete");
}
pbm = 0;
var Dm = Application.DocumentManager.MdiActiveDocument;
Database Db = Dm.Database;
BlockTableRecord acBlkTblRec;
acBlkTblRec =
acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as
BlockTableRecord;
int NLines = 0;
while (!reader.EndOfStream)
{
acPoly = new Polyline();
string Data = reader.ReadLine();
pbm++;
NLines++;
}
NLines = 1;
while (!reader.EndOfStream)
{
acPoly = new Polyline();
if (l.Length == minddis)
{
Lines[0] = new Polyline();
Lines[0] = acPoly;
}
else
{
Lines[NLines] = new Polyline();
Lines[NLines] = acPoly;
NLines++;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
while (!Fin)
{
try
{
Lines[0].JoinEntity(Lines[Poliline]);
//OffSet(Lines[Poliline], BRP, acTrans, acBlkTblRec,
minddis, OLines);
if (Poliline == NLines - 1)
Fin = true;
}
Fin = false;
while (!Fin)
{
try
{
Lines[0].JoinEntity(Lines[Poliline]);
//OffSet(Lines[Poliline], BRP, acTrans, acBlkTblRec,
minddis, OLines);
}
catch (Exception)
{
}
finally
{
Poliline--;
}
if (Poliline == 0)
Fin = true;
}
acBlkTblRec.AppendEntity(Lines[0]);
acTrans.AddNewlyCreatedDBObject(Lines[0], true);
acTrans.Commit();
}
MessageBox.Show("Drawing Complete");
}
double min;
Point3d Sp = pl.StartPoint;
Point3d Ep = pl.EndPoint;
l1.AddVertexAt(l1.NumberOfVertices, new
Point2d(pl.StartPoint.X, pl.StartPoint.Y), 0, 0, 0);
l1.AddVertexAt(l1.NumberOfVertices, new
Point2d(P0.GetClosestPointTo(Ep, false).X, P0.GetClosestPointTo(Ep, false).Y), 0,
0, 0);
acBlkTblRec.AppendEntity(PL);
acTrans.AddNewlyCreatedDBObject(PL, true);
P0.JoinEntity(PL);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
public CParcel()
{
Line L;
//max = 1000;
min = 1000;
public CCable()
{
public CHH()
{
}
}
class CDatabase
{
//Local Database
static SQLiteConnection conn;
static SQLiteDataReader dr;
static SQLiteCommand cmd;
static System.Data.DataTable dt;
public string DataSource = (@"C:\GenXCTool\DB\Plannin");
public CDatabase()
{
}
conn.Close();
}
conn.Close();
}
conn.Close();
dt = new System.Data.DataTable();
dt.Load(dr);
conn.Close();
return dt;
}
public Boolean Existe(string commd)
{
try
{
int q = 0;
conect();
cmd = new SQLiteCommand(commd, conn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
q++;
}
if (q == 0)
return false;
else
return true;
}
return false;
}
finally
{
conn.Close();
}
}
}
}
public static void Ds(string Ds)
{
DataSource = Ds;
}
try
{
Conectar(DataSource);
Com = new SQLiteCommand(query, Con);
Dr = Com.ExecuteReader();
while (Dr.Read())
{
Dat = (byte[])Dr[0];
}
}
catch (Exception Ex)
{
MessageBox.Show("Error al Conectar en la base de datos= " +
Ex.ToString());
}
finally
{
Con.Close();
}
return Dat;
}
public void GuardarFoto(byte[] B)
{
try
{
Conectar(DataSource);
Com = new SQLiteCommand("Insert into Imagen Values(@imagen)", Con);
Com.Parameters.AddWithValue("@imagen", B);
Com.ExecuteNonQuery();
MessageBox.Show("Cambios guardados Correctamente", "Guardar",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception Ex)
{
MessageBox.Show("Error al guardar en la base de datos= " +
Ex.ToString());
}
finally
{
Con.Close();
}
}
#endregion
public SQLiteCommand select(string query, string DataSource)
{
try
{
Conectar(DataSource);
Com = new SQLiteCommand(query, Con);
Com.ExecuteNonQuery();
}
catch (Exception Ex)
{
MessageBox.Show("Error al guardar en la base de datos= " +
Ex.ToString());
}
finally
{
//Con.Close();
}
return Com;
}
return dt;
}
class CPolyline
{
public static void Lin2Pol(Polyline Pl, Line L)
{
Pl.AddVertexAt(Pl.NumberOfVertices, (new Point2d(L.StartPoint.X,
L.StartPoint.Y)), 0, 0, 0);
Pl.Layer = L.Layer;
}
}
class CLayout
{
CBlock cBlock = new CBlock();
int ViewportN = 0;
while (J)
{
PromptSelectionOptions promptPointOptions = new
PromptSelectionOptions();
promptPointOptions.MessageForAdding = ("Select Cable");
PromptSelectionResult selectLinesFollow =
Trans.editor.GetSelection(promptPointOptions);
if (selectLinesFollow.Status == PromptStatus.OK)
{
foreach (ObjectId Obj in
selectLinesFollow.Value.GetObjectIds())
{
DBObject entity = Trans.transaction.GetObject(Obj,
OpenMode.ForWrite);
if (entity is Polyline)
{
Polyline Pl = (Polyline)entity;
double Cont = 0;
PromptSelectionResult selectLinesFollow3 =
Trans.editor.SelectAll();
if (selectLinesFollow3.Status == PromptStatus.OK)
{
foreach (ObjectId Obj3 in
selectLinesFollow3.Value.GetObjectIds())
{
DBObject entity3 =
Trans.transaction.GetObject(Obj3, OpenMode.ForWrite);
if (entity3 is BlockReference)
{
BlockReference Br =
(BlockReference)entity3;
if (name == "Vport")
{
Point3dCollection AB = new
Point3dCollection();
DBObjectCollection dBObjectCollection =
new DBObjectCollection();
Br.Explode(dBObjectCollection);
foreach (DBObject Db in
dBObjectCollection)
{
if (Db is Polyline)
{
Polyline Tpl = (Polyline)Db;
Tpl.IntersectWith(Pl,
Intersect.OnBothOperands, AB, IntPtr.Zero, IntPtr.Zero);
if (AB.Count > 0)
{
foreach (Point3d P in AB)
{
if
(Pl.GetDistAtPoint(P) > Cont)
{
Cont =
Pl.GetDistAtPoint(P);
}
}
}
}
}
ViewportN = ViewportN + 1;
BlockReference Br = new
BlockReference(Pl.GetPointAtDist(Cont), ObjId);
Br.Layer = "Vport";
double RealAngle = 0;
RealAngle = TempAngle.Angle;
if(Typ == "360")
{
Br.Rotation = RealAngle;
}
if(Typ == "0_90")
{
if (RealAngle >= 0 && RealAngle <=
Math.PI / 180 * 45)
{
Br.Rotation = 0;
}
Br.Explode(DbObjCol);
double Hi =
Tpl.GetDistanceAtParameter(2) - Tpl.GetDistanceAtParameter(1);
double Le =
Tpl.GetDistanceAtParameter(1);
Br.Layer = "Vport";
Br.Rotation = 0;
Trans.Insert(Br, true);
Br.Explode(dBObjectCollection);
Tpl.IntersectWith(Pl,
Intersect.OnBothOperands, AB, IntPtr.Zero, IntPtr.Zero);
if (AB.Count > 0)
{
List<Point3d> LIP = new
List<Point3d>();
if (!Conts.Contains(Cont.ToString()))
{
Conts.Add(Cont.ToString());
}
else
{
Cont += Cont;
}
if (LengF)
Cont += Pl.Length;
}
}
}
}
}
else
{
J = false;
}
J = false;
}
}
while(Layn)
{
BlockReference Used_Vport = Get_Used_Vport(Trans, LVp);
if(Layn)
{
Create_Layout(Trans, Used_Vport);
SetLayoutOrder(Trans);
Create_Cover(Trans, Page);
Create_North(Trans, Used_Vport);
}
}
}
if (cBlock.GetBlockName(Br) == "Vport")
LViewPort.Add(entityp as BlockReference);
}
}
}
return LViewPort;
}
Pl.Explode(DB02);
Point3d Pc_Polyline_viewport =
centroide.GetCentroid(Tpol);
return Used_Vport;
}
Used_Vport.Explode(DBOC);
Application.SetSystemVariable("TILEMODE", 0);
Trans.editor.SwitchToPaperSpace();
if (acLayoutMgr.LayoutExists(Page))
{
acLayoutMgr.DeleteLayout(Page);
}
Aclayout.UpgradeOpen();
Aclayout.CopyFrom(plSet);
}
}
Vport.Width = 13.3000;
Vport.Height = 8.3000;
Vport.ViewCenter = PC2d;
Vport.On = true;
}
Trans.Start_Trans();
LayoutManager.Current.CurrentLayout = "Model";
List<Polyline> LRutes = new List<Polyline>();
Used_Vport.Explode(DB0);
P3dc.Add(Tpol.GetPoint3dAt(0));
VpPolyOri = Tpol;
}
}
PromptSelectionResult selectLinesFollow =
Trans.editor.SelectCrossingPolygon(P3dc);
if (selectLinesFollow.Status == PromptStatus.OK)
{
Application.SetSystemVariable("TILEMODE", 0);
Trans.editor.SwitchToPaperSpace();
acLayoutMgr.CurrentLayout = Page;
if (entityp is Polyline)
{
Polyline polyline = (Polyline)entityp;
if (intersectionPoints.Count > 0)
{
foreach (Point3d item in intersectionPoints)
{
CableIntersectionPoint.Add(item);
}
LRutes.Add(polyline);
}
Lpl.Add(polyline);
}
}
}
double Max = 0;
MyCableIntersectionPoint.Add(Pd3);
}
}
Br.Explode(dBObjectCollection);
if (intersectionPoints.Count > 0)
{
LVportVec.Add(Br);
}
}
}
}
//MessageBox.Show("New Cable");
BlockReference Tembr;
Br.Explode(dBObjectCollection);
if (intersectionPoints.Count > 0)
{
foreach (Point3d P3f in
intersectionPoints)
{
if (new Line(point3D, P3f).Length <
Dist)
{
Dist = new Line(point3D,
P3f).Length;
Br.Explode(dBObjectCollection);
if (intersectionPoints.Count > 0)
{
foreach (Point3d P3f in
intersectionPoints)
{
if (new Line(point3D, P3f).Length
== Dist)
{
LFVportVecU.Add(Br);
//MessageBox.Show(acAtt.TextString);
}
}
}
}
}
}
}
}
}
//rectangulo
ObjectId Obj_Id = Trans.blockTable["vPORT2"];
Br.Layer = "Vport2";
BlockTableRecord Btr =
(BlockTableRecord)Trans.blockTable["vPORT2"].GetObject(OpenMode.ForWrite);
Br.Explode(dBObjectCollection);
//Matchlines
if
(Dest.GetDistAtPoint(Dest.GetClosestPointTo(cPoint.Regla_3(VpPolyOri, Dest, P),
false)) < Dest.GetDistanceAtParameter(1))
{
Der = true;
}
else if
(Dest.GetDistAtPoint(Dest.GetClosestPointTo(cPoint.Regla_3(VpPolyOri, Dest, P),
false)) < Dest.GetDistanceAtParameter(2))
{
Der = true;
}
if (Der)
BlockName = "MatchLine2";
if
(Dest.GetDistAtPoint(Dest.GetClosestPointTo(Br.Position, false)) <
Dest.GetDistanceAtParameter(1))
{
Br.Rotation = Math.PI / 180 * 0;
//MessageBox.Show((Br.Rotation / Math.PI *
180).ToString());
}
else if
(Dest.GetDistAtPoint(Dest.GetClosestPointTo(Br.Position, false)) <
Dest.GetDistanceAtParameter(2))
{
Br.Rotation = Math.PI / 180 * 270;
//MessageBox.Show((Br.Rotation / Math.PI *
180).ToString());
}
else if
(Dest.GetDistAtPoint(Dest.GetClosestPointTo(Br.Position, false)) <
Dest.GetDistanceAtParameter(3))
{
Br.Rotation = Math.PI / 180 * 0;
//MessageBox.Show((Br.Rotation / Math.PI *
180).ToString());
}
else
{
Br.Rotation = Math.PI / 180 * 270;
// MessageBox.Show((Br.Rotation / Math.PI *
180).ToString());
}
string Pag = "";
if (!ml.Contains(Pag))
{
BlockTable blockTable =
Trans.transaction.GetObject(Trans.database.BlockTableId, OpenMode.ForWrite) as
BlockTable;
BlockTableRecord blkTbRecPaper =
Trans.transaction.GetObject(blockTable[BlockTableRecord.PaperSpace],
OpenMode.ForWrite) as BlockTableRecord;
blkTbRecPaper.AppendEntity(Br);
BlockTableRecord Btr =
(BlockTableRecord)blockTable[BlockName].GetObject(OpenMode.ForWrite);
attRef.SetAttributeFromBlock(attDef, Br.BlockTransform);
attRef.Visible = true;
Br.AttributeCollection.AppendAttribute(attRef);
Trans.transaction.AddNewlyCreatedDBObject(attRef, true);
if (attRef.Tag ==
"DESCRIPTION")
{
attRef.TextString = "SEE
DRAWING# ";
}
else if (attRef.Tag == "PAGE"
|| attRef.Tag == "REF#")
{
attRef.TextString = Pag;
}
else
{
attRef.TextString = "";
}
}
}
}
DynamicBlockReferencePropertyCollection
pcFST = Br.DynamicBlockReferencePropertyCollection;
foreach (DynamicBlockReferenceProperty dP
in pcFST)
{
if (dP.PropertyName == "Flip state1")
{
/* Trans.editor.WriteMessage(
$"\nName: {dP.PropertyName} " +
$"Type code: {dP.PropertyTypeCode}
" +
$"Unit type: {dP.UnitsType} " +
$"Allowed values: [{string.Join(",
", dP.GetAllowedValues())}]");*/
//dP.Value = "1";
}
}
if (Del)
{
Br.Erase();
}
ml.Add(Pag);
}
}
}
}
}
}
}
}
Trans.Start_Trans();
Br.Layer = "Vport2";
DynamicBlockReferencePropertyCollection DBRC =
Br.DynamicBlockReferencePropertyCollection;
Trans.Insert(Br, false);
}
Trans.Start_Trans();
LayoutManager.Current.CurrentLayout = "Model";
if (DbObj is BlockReference)
{
BlockReference Br = DbObj as BlockReference;
//Trans.Insert(Li, true);
// Trans.Insert(PLC, true);
Application.SetSystemVariable("TILEMODE", 0);
Trans.editor.SwitchToPaperSpace();
acLayoutMgr.CurrentLayout = Page;
Layout Aclayout =
Trans.transaction.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout),
OpenMode.ForRead) as Layout;
Trans.Insert(acVport, false);
acVport.On = true;
LayoutManager.Current.CurrentLayout = "Model";
}
var modelPt2 =
Pl.GetPointAtDist((Pl.GetDistAtPoint(Pl.GetPoint3dAt(3)) + Pl.Length) / 2);
C = new Circle();
C.Radius = 15;
C.Center = modelPt2;
//Trans.Insert(C, true);
modelPt1 =
modelPt1.TransformBy(ed.CurrentUserCoordinateSystem);
modelPt2 =
modelPt2.TransformBy(ed.CurrentUserCoordinateSystem);
C = new Circle();
C.Radius = 15;
C.Center = centroide.GetCentroid(Pl);
//Trans.Insert(C, true);
// ed.SwitchToPaperSpace();
var paperPt2 = new Point3d(1.2694, 6.1092, 0);
C = new Circle();
C.Radius = 2;
C.Center = paperPt2;
//Trans.Insert(C, false);
paperPt1 =
paperPt1.TransformBy(ed.CurrentUserCoordinateSystem);
paperPt2 =
paperPt2.TransformBy(ed.CurrentUserCoordinateSystem);
//ed.SwitchToModelSpace();
}
tr.Commit();
}
}
var modelPt1 =
Pl.GetPointAtDist(Pl.GetDistAtPoint(Pl.GetPoint3dAt(3)) + (Pl.Length -
Pl.GetDistAtPoint(Pl.GetPoint3dAt(3))) / 2);
//richTextBox1.Text += modelPt1.ToString() + "\n";
var modelPt2 =
Pl.GetPointAtDist(Pl.GetDistAtPoint(Pl.GetPoint3dAt(1)) +
(Pl.GetDistAtPoint(Pl.GetPoint3dAt(2)) - Pl.GetDistAtPoint(Pl.GetPoint3dAt(1))) /
2);
//richTextBox1.Text += modelPt2.ToString() + "\n";
modelPt1 =
modelPt1.TransformBy(Trans.editor.CurrentUserCoordinateSystem);
modelPt2 =
modelPt2.TransformBy(Trans.editor.CurrentUserCoordinateSystem);
Trans.editor.SwitchToPaperSpace();
//Verify Points
{
Circle C = new Circle
{
Center = modelPt1,
Radius = 5
};
// Trans.Insert(C, true);
C = new Circle
{
Center = modelPt2,
Radius = 5
};
// Trans.Insert(C, true);
C = new Circle
{
Center = paperPt1,
Radius = 1
};
// Trans.Insert(C, false);
C = new Circle
{
Center = paperPt2,
Radius = 1
};
// Trans.Insert(C, false);
}
paperPt1 =
paperPt1.TransformBy(Trans.editor.CurrentUserCoordinateSystem);
paperPt2 =
paperPt2.TransformBy(Trans.editor.CurrentUserCoordinateSystem);
modelPt1 =
modelPt1.TransformBy(Trans.editor.CurrentUserCoordinateSystem);
modelPt2 =
modelPt2.TransformBy(Trans.editor.CurrentUserCoordinateSystem);
Trans.editor.SwitchToPaperSpace();
//Verify Points
{
Circle C = new Circle
{
Center = modelPt1,
Radius = 5
};
// Trans.Insert(C, true);
C = new Circle
{
Center = modelPt2,
Radius = 5
};
// Trans.Insert(C, true);
C = new Circle
{
Center = paperPt1,
Radius = 1
};
// Trans.Insert(C, false);
C = new Circle
{
Center = paperPt2,
Radius = 1
};
// Trans.Insert(C, false);
}
paperPt1 =
paperPt1.TransformBy(Trans.editor.CurrentUserCoordinateSystem);
paperPt2 =
paperPt2.TransformBy(Trans.editor.CurrentUserCoordinateSystem);
//MessageBox.Show(objectId.ToString());
modelPt1 =
modelPt1.TransformBy(ed.CurrentUserCoordinateSystem);
modelPt2 =
modelPt2.TransformBy(ed.CurrentUserCoordinateSystem);
ed.SwitchToPaperSpace();
paperPt1 =
paperPt1.TransformBy(ed.CurrentUserCoordinateSystem);
paperPt2 =
paperPt2.TransformBy(ed.CurrentUserCoordinateSystem);
ed.SwitchToModelSpace();
}
}
}
}
else
{
vp = (Viewport)tr.GetObject(ed.ActiveViewportId,
OpenMode.ForWrite);
ed.SwitchToPaperSpace();
paperPt1 =
paperPt1.TransformBy(ed.CurrentUserCoordinateSystem);
paperPt2 =
paperPt2.TransformBy(ed.CurrentUserCoordinateSystem);
ed.SwitchToModelSpace();
tr.Commit();
}
//this.Show();
}
vp.Locked = locked;
}
Point3dCollection P3dc;
PromptPointOptions promptPointOptions = new
PromptPointOptions("Point");
PromptPointResult selectStartPoint =
Trans.editor.GetPoint(promptPointOptions);
if (selectStartPoint.Status == PromptStatus.OK)
{
P3d = selectStartPoint.Value;
}
else
{
Layn = false;
}
if (Layn)
{
PromptSelectionResult selectLinesFollow = Trans.editor.SelectAll();
if (selectLinesFollow.Status == PromptStatus.OK)
{
foreach (ObjectId objectid in
selectLinesFollow.Value.GetObjectIds())
{
DBObject entityp = Trans.transaction.GetObject(objectid,
OpenMode.ForWrite);
if (entityp is BlockReference)
{
BlockReference Br = (BlockReference)entityp;
name = Br.IsDynamicBlock ?
((BlockTableRecord)Br.DynamicBlockTableRecord.GetObject(OpenMode.ForWrite)).Name :
Br.Name;
if (name == "Vport")
LViewPort.Add(entityp as BlockReference);
}
}
}
Pl.Explode(DB0);
Point3d Pc_Polyline_viewport =
Poi.GetCentroid(Tpol);
{
P3dc = new Point3dCollection();
Used_Vport.Explode(DB0);
P3dc.Add(Tpol.GetPoint3dAt(0));
}
}
//Trans.Insert(PLC, true);
Used_Vport.Explode(collection);
int CabCon = 1;
int Hhcon = 0;
double MaxX = 0;
double MinX = 0;
double MaxY = 0;
double MinY = 0;
double MaxWidth = 0;
//Polyline VpPolyDes;
PromptSelectionResult selectLinesFollow =
Trans.editor.SelectCrossingPolygon(P3dc);
if (selectLinesFollow.Status == PromptStatus.OK)
{
PromptSelectionResult selectLines = Trans.editor.SelectAll();
if (selectLines.Status == PromptStatus.OK)
{
foreach (ObjectId objectid in selectLines.Value.GetObjectIds())
{
DBObject entityp = Trans.transaction.GetObject(objectid,
OpenMode.ForWrite);
if (entityp is BlockReference)
{
BlockReference Br = (BlockReference)entityp;
if (name == "Vport")
{
LVp.Add(Br);
}
}
}
}
Application.SetSystemVariable("TILEMODE", 0);
Trans.editor.SwitchToPaperSpace();
if (acLayoutMgr.LayoutExists(Page))
{
acLayoutMgr.DeleteLayout(Page);
}
Aclayout.CopyFrom(plSet);
}
}
// Set the layout current if it is not already
acLayoutMgr.CurrentLayout = Page;
//vp2.ViewCenter = PC2d;
vp2.CenterPoint = new Point3d(10.2319, 7.7190, 0);
//vp2.StandardScale = StandardScaleType.Scale1To8inchAnd1ft;
//
vp2.Width = 9;
vp2.Height = 7;
//Application.ShowAlertDialog(vp2.ViewCenter.ToString());
vp2.ViewCenter = PC2d;
vp2.On = true;
//freezing los layer dentro del viewport
ObjectIdCollection Layers = new ObjectIdCollection();
ObjectIdCollection Layers2 = new ObjectIdCollection();
LayerTable acLyrTbl;
acLyrTbl =
Trans.transaction.GetObject(Trans.database.LayerTableId, OpenMode.ForRead) as
LayerTable;
foreach (ObjectId acObjId in acLyrTbl)
{
LayerTableRecord acLyrTblRec;
acLyrTblRec = Trans.transaction.GetObject(acObjId,
OpenMode.ForRead) as LayerTableRecord;
////cover
ObjectId Obj_Id = Trans.blockTable["AT&T_COVER"];
Br.Layer = "Vport2";
DynamicBlockReferencePropertyCollection DBRC =
Br.DynamicBlockReferencePropertyCollection;
BlockTable blockTable =
Trans.transaction.GetObject(Trans.database.BlockTableId, OpenMode.ForWrite) as
BlockTable;
BlockTableRecord blkTbRecPaper =
Trans.transaction.GetObject(blockTable[BlockTableRecord.PaperSpace],
OpenMode.ForWrite) as BlockTableRecord;
blkTbRecPaper.AppendEntity(Br);
BlockTableRecord Btr =
(BlockTableRecord)blockTable["AT&T_COVER"].GetObject(OpenMode.ForWrite);
Br.AttributeCollection.AppendAttribute(attRef);
Trans.transaction.AddNewlyCreatedDBObject(attRef, true);
}
}
}
}
}
////datos
Obj_Id = Trans.blockTable["BURIED STAMP"];
Br.Layer = "Vport2";
DynamicBlockReferencePropertyCollection DBRC =
Br.DynamicBlockReferencePropertyCollection;
BlockTable blockTable =
Trans.transaction.GetObject(Trans.database.BlockTableId, OpenMode.ForWrite) as
BlockTable;
BlockTableRecord blkTbRecPaper =
Trans.transaction.GetObject(blockTable[BlockTableRecord.PaperSpace],
OpenMode.ForWrite) as BlockTableRecord;
blkTbRecPaper.AppendEntity(Br);
Br.AttributeCollection.AppendAttribute(attRef);
Trans.transaction.AddNewlyCreatedDBObject(attRef, true);
attRef.TextString = Page;
}
}
}
}
}
////detalles
Obj_Id = Trans.blockTable["Placement_Detail"];
Br.Layer = "Vport2";
BlockTable blockTable =
Trans.transaction.GetObject(Trans.database.BlockTableId, OpenMode.ForWrite) as
BlockTable;
BlockTableRecord blkTbRecPaper =
Trans.transaction.GetObject(blockTable[BlockTableRecord.PaperSpace],
OpenMode.ForWrite) as BlockTableRecord;
blkTbRecPaper.AppendEntity(Br);
BlockTableRecord Btr =
(BlockTableRecord)blockTable["Placement_Detail"].GetObject(OpenMode.ForWrite);
attRef.Visible = true;
Br.AttributeCollection.AppendAttribute(attRef);
Trans.transaction.AddNewlyCreatedDBObject(attRef, true);
attRef.TextString = "";
}
}
}
}
}
//rectangulo
Obj_Id = Trans.blockTable["vPORT2"];
Br.Layer = "Vport2";
BlockTable blockTable =
Trans.transaction.GetObject(Trans.database.BlockTableId, OpenMode.ForWrite) as
BlockTable;
BlockTableRecord blkTbRecPaper =
Trans.transaction.GetObject(blockTable[BlockTableRecord.PaperSpace],
OpenMode.ForWrite) as BlockTableRecord;
blkTbRecPaper.AppendEntity(Br);
BlockTableRecord Btr =
(BlockTableRecord)blockTable["vPORT2"].GetObject(OpenMode.ForWrite);
attRef.Visible = true;
Br.AttributeCollection.AppendAttribute(attRef);
Trans.transaction.AddNewlyCreatedDBObject(attRef, true);
}
}
}
Br.Explode(dBObjectCollection);
double Max = 0;
MyCableIntersectionPoint.Add(Pd3);
}
}
Br.Explode(dBObjectCollection);
if (intersectionPoints.Count > 0)
{
LVportVec.Add(Br);
}
}
}
}
//MessageBox.Show("New Cable");
Br.Explode(dBObjectCollection);
if (intersectionPoints.Count > 0)
{
foreach (Point3d P3f in
intersectionPoints)
{
if (new Line(point3D, P3f).Length <
Dist)
{
Dist = new Line(point3D,
P3f).Length;
//
MessageBox.Show(point3D.ToString() + "\n" +PaGe);
}
}
}
}
}
}
}
}
}
Br.Explode(dBObjectCollection);
if (intersectionPoints.Count > 0)
{
foreach (Point3d P3f in
intersectionPoints)
{
if (new Line(point3D, P3f).Length
== Dist)
{
LFVportVecU.Add(Br);
//MessageBox.Show(acAtt.TextString);
}
}
}
}
}
}
}
}
}
if
(Dest.GetDistAtPoint(Dest.GetClosestPointTo(Poi.Regla_3(VpPolyOri, Dest, P),
false)) < Dest.GetDistanceAtParameter(1))
{
Der = true;
}
else if
(Dest.GetDistAtPoint(Dest.GetClosestPointTo(Poi.Regla_3(VpPolyOri, Dest, P),
false)) < Dest.GetDistanceAtParameter(2))
{
Der = true;
}
if (Der)
BlockName = "MatchLine2";
//MessageBox.Show((Br.Rotation / Math.PI *
180).ToString());
}
else if
(Dest.GetDistAtPoint(Dest.GetClosestPointTo(Br.Position, false)) <
Dest.GetDistanceAtParameter(2))
{
Br.Rotation = Math.PI / 180 * 270;
//Br.Position = new Point3d(Br.Position.X +
0.1463, Br.Position.Y, 0);
//MessageBox.Show((Br.Rotation / Math.PI *
180).ToString());
}
else if
(Dest.GetDistAtPoint(Dest.GetClosestPointTo(Br.Position, false)) <
Dest.GetDistanceAtParameter(3))
{
Br.Rotation = Math.PI / 180 * 0;
//MessageBox.Show((Br.Rotation / Math.PI *
180).ToString());
}
else
{
Br.Rotation = Math.PI / 180 * 270;
if (!ml.Contains(Pag))
{
BlockTable blockTable =
Trans.transaction.GetObject(Trans.database.BlockTableId, OpenMode.ForWrite) as
BlockTable;
BlockTableRecord blkTbRecPaper =
Trans.transaction.GetObject(blockTable[BlockTableRecord.PaperSpace],
OpenMode.ForWrite) as BlockTableRecord;
blkTbRecPaper.AppendEntity(Br);
BlockTableRecord Btr =
(BlockTableRecord)blockTable[BlockName].GetObject(OpenMode.ForWrite);
attRef.SetAttributeFromBlock(attDef, Br.BlockTransform);
attRef.Visible = true;
Br.AttributeCollection.AppendAttribute(attRef);
Trans.transaction.AddNewlyCreatedDBObject(attRef, true);
if (attRef.Tag ==
"DESCRIPTION")
{
attRef.TextString = "SEE
PAGE# ";
}
else if (attRef.Tag == "PAGE"
|| attRef.Tag == "REF#")
{
attRef.TextString = Pag;
}
else
{
attRef.TextString = "";
}
}
}
}
DynamicBlockReferencePropertyCollection
pcFST = Br.DynamicBlockReferencePropertyCollection;
foreach (DynamicBlockReferenceProperty dP
in pcFST)
{
if (dP.PropertyName == "Flip state1")
{
/* Trans.editor.WriteMessage(
$"\nName: {dP.PropertyName} " +
$"Type code: {dP.PropertyTypeCode}
" +
$"Unit type: {dP.UnitsType} " +
$"Allowed values: [{string.Join(",
", dP.GetAllowedValues())}]");*/
//dP.Value = "1";
}
}
if (Del)
{
Br.Erase();
}
ml.Add(Pag);
}
}
}
}
}
}
////set vecinos
// Get the current layout and output its name in the Command Line
window
Layout acLayout =
acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout),
OpenMode.ForRead) as Layout;
DBDictionary acPlSet =
acTrans.GetObject(acCurDb.PlotSettingsDictionaryId,
OpenMode.ForRead) as
DBDictionary;
acDoc.Editor.Regen();
//Trans.editor.SwitchToModelSpace();
SpaceAlign2(PLC);
LayoutManager.Current.CurrentLayout = "Model";
}
class CStreet
{
public void AddCl(CTransaction Trans)
{
WebClient Client = new WebClient();
GeoLocationData geo =
Trans.transaction.GetObject(Trans.database.GeoDataObject, OpenMode.ForWrite) as
GeoLocationData;
//Application.ShowAlertDialog(geo.TransformToLonLatAlt(psr.Value).ToString());
//Application.ShowAlertDialog(geo.TransformToLonLatAlt(psr1.Value).ToString());
Y.Add(geo.TransformToLonLatAlt(psr.Value).Y);
Y.Add(geo.TransformToLonLatAlt(psr1.Value).Y);
string LongMin = X.Min().ToString("0.000");
string LatMin = Y.Min().ToString("0.000");
string LongMax = X.Max().ToString("0.000");
string LatMax = Y.Max().ToString("0.000");
if (File.Exists(@"C:\GenXCTool\Temp Arc\CL.txt"))
{
File.Delete(@"C:\GenXCTool\Temp Arc\CL.txt");
}
File.WriteAllText(@"C:\GenXCTool\Temp Arc\CL.txt",
Client.DownloadString("http://api.openstreetmap.org/api/0.6/map?bbox=" + LongMin +
"," + LatMin + "," + LongMax + "," + LatMax));
XmlDocument XDoc = new XmlDocument();
XDoc.Load(@"C:\GenXCTool\Temp Arc\CL.txt");
XmlNodeList xnNode = XDoc.GetElementsByTagName("node");
XmlNodeList xnWay = XDoc.GetElementsByTagName("way");
List<string> way = new List<string>();
string[] highway = new string[] { "motorway", "trunk",
"primary", "secondary", "tertiary", "unclassified", "residential", "road" };
bool flag = false;
bool flag0 = false;
foreach (XmlNode xWay in xnWay)
{
}
}
flag = false;
flag0 = false;
foreach (XmlNode xWayNode in xWay)
{
if (xWayNode.Name == "nd")
{
IdNode.Add(xWayNode.Attributes[0].Value);
}
if (xWayNode.Name == "tag")
{
}
if (xWayNode.Attributes[0].Value ==
"tiger:name_base")
{
Base = xWayNode.Attributes[1].Value;
}
if (xWayNode.Attributes[0].Value ==
"tiger:name_type")
{
sux = xWayNode.Attributes[1].Value;
}
if (xWayNode ==
xWay.ChildNodes[xWay.ChildNodes.Count - 1])
{
flag0 = true;
}
}
}
if (flag2)
{
if (xATT.Name == "lon")
{
lon =
Convert.ToDouble(xATT.Value);
}
if (xATT.Name == "lat")
{
lat =
Convert.ToDouble(xATT.Value);
}
}
if (flag2)
{
//Application.ShowAlertDialog(lat.ToString()+","+lon.ToString());
pl.AddVertexAt(pl.NumberOfVertices, new
Point2d(geo.TransformFromLonLatAlt(new Point3d(lon, lat, 0)).X,
geo.TransformFromLonLatAlt(new Point3d(lon, lat, 0)).Y), 0, 0, 0);
}
Trans.Insert(pl, true);
Trans.Hyper(pl, Name, EOP, "");
//dgvCenterLine.Rows.Add(pl.Handle.Value.ToString(),Name, pl.Hyperlinks[0].Name,
pl.Hyperlinks[0].SubLocation);
pl.Layer = "Streets";
}
}
}
}
}