using System;
using System.Collections.Generic;
using System.Windows.Forms;
using acad = Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using acil = Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
namespace chinhcong
{
public partial class Chinh_nhieu_cong : Form
{
public Chinh_nhieu_cong()
{
InitializeComponent();
}
private void Chinh_nhieu_cong_Load(object sender, EventArgs e)
{
}
// đăt tên biến chung
Pipe _p1 = null;
Pipe _p2 = null;
public void btn_choncong_Click(object sender, EventArgs e)
{
acad.Document doc = acad.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
acil.CivilDocument _civil = acil.CivilApplication.ActiveDocument;
using (acad.DocumentLock acLck = doc.LockDocument())
{
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
this.Hide();
TypedValue[] _tv = new TypedValue[] {
new TypedValue((int)DxfCode.Start, "AECC_GRAPH_PROFILE_NETWORK_PART")
};
SelectionFilter _slf = new SelectionFilter(_tv);
PromptSelectionOptions _sop = new PromptSelectionOptions();
ed.WriteMessage("\n Chon cong thuong luu");
PromptSelectionResult _kq = ed.GetSelection(_sop, _slf);
if (_kq.Status != PromptStatus.OK) return;
ObjectId _id1 = _kq.Value.GetObjectIds()[0];
_sop = new PromptSelectionOptions();
ed.WriteMessage("\n Chon cong ha luu");
_kq = ed.GetSelection(_sop, _slf);
if (_kq.Status != PromptStatus.OK) return;
ObjectId _id2 = _kq.Value.GetObjectIds()[0];
// chon doi tuong profileview
TypedValue[] _tv1 = new TypedValue[] {
new TypedValue((int)DxfCode.Start, "AECC_PROFILE_VIEW")
};
SelectionFilter _slf1 = new SelectionFilter(_tv1);
_sop = new PromptSelectionOptions();
ed.WriteMessage("\n Chọn ProfileView");
_kq = ed.GetSelection(_sop, _slf1);
if (_kq.Status != PromptStatus.OK) return;
ObjectId _id3= _kq.Value.GetObjectIds()[0];
// get cống về đối tượng part
ProfileViewPart _ct = tr.GetObject(_id1, OpenMode.ForRead) as ProfileViewPart;
ProfileViewPart _ch = tr.GetObject(_id2, OpenMode.ForWrite) as ProfileViewPart;
Autodesk.Civil.DatabaseServices.Entity _ent1 = tr.GetObject(_ct.ModelPartId, OpenMode.ForWrite) as Autodesk.Civil.DatabaseServices.Entity;
Autodesk.Civil.DatabaseServices.Entity _ent2 = tr.GetObject(_ch.ModelPartId, OpenMode.ForWrite) as Autodesk.Civil.DatabaseServices.Entity;
if (_ent1 is Pipe && _ent2 is Pipe)
{
_p1 = _ent1 as Pipe;
_p2 = _ent2 as Pipe;
txt_ct.Text = _p1.Name;
txt_ch.Text = _p2.Name;
}
// get trắc dọc về đối tượng profileview
ProfileView _prfv = tr.GetObject(_id3, OpenMode.ForRead) as ProfileView;
// get toàn bộ các đối tượng cống và hầm ga có trong profileview
//
// I can help me.
}
}
}
public void btn_ok_Click(object sender, EventArgs e)
{
// so lieu dau vao
double _i = Convert.ToDouble(txt_i.Text);
double _drop = Convert.ToDouble(txt_drop.Text);
// get tuyến chứa cống đầu tiên
}
}
}
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using acad = Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using acil = Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
namespace chinhcong
{
public partial class Chinh_nhieu_cong : Form
{
public Chinh_nhieu_cong()
{
InitializeComponent();
}
private void Chinh_nhieu_cong_Load(object sender, EventArgs e)
{
}
// đăt tên biến chung
Pipe _p1 = null;
Pipe _p2 = null;
public void btn_choncong_Click(object sender, EventArgs e)
{
acad.Document doc = acad.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
acil.CivilDocument _civil = acil.CivilApplication.ActiveDocument;
using (acad.DocumentLock acLck = doc.LockDocument())
{
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
this.Hide();
TypedValue[] _tv = new TypedValue[] {
new TypedValue((int)DxfCode.Start, "AECC_GRAPH_PROFILE_NETWORK_PART")
};
SelectionFilter _slf = new SelectionFilter(_tv);
PromptSelectionOptions _sop = new PromptSelectionOptions();
ed.WriteMessage("\n Chon cong thuong luu");
PromptSelectionResult _kq = ed.GetSelection(_sop, _slf);
if (_kq.Status != PromptStatus.OK) return;
ObjectId _id1 = _kq.Value.GetObjectIds()[0];
_sop = new PromptSelectionOptions();
ed.WriteMessage("\n Chon cong ha luu");
_kq = ed.GetSelection(_sop, _slf);
if (_kq.Status != PromptStatus.OK) return;
ObjectId _id2 = _kq.Value.GetObjectIds()[0];
// chon doi tuong profileview
TypedValue[] _tv1 = new TypedValue[] {
new TypedValue((int)DxfCode.Start, "AECC_PROFILE_VIEW")
};
SelectionFilter _slf1 = new SelectionFilter(_tv1);
_sop = new PromptSelectionOptions();
ed.WriteMessage("\n Chọn ProfileView");
_kq = ed.GetSelection(_sop, _slf1);
if (_kq.Status != PromptStatus.OK) return;
ObjectId _id3= _kq.Value.GetObjectIds()[0];
// get cống về đối tượng part
ProfileViewPart _ct = tr.GetObject(_id1, OpenMode.ForRead) as ProfileViewPart;
ProfileViewPart _ch = tr.GetObject(_id2, OpenMode.ForWrite) as ProfileViewPart;
Autodesk.Civil.DatabaseServices.Entity _ent1 = tr.GetObject(_ct.ModelPartId, OpenMode.ForWrite) as Autodesk.Civil.DatabaseServices.Entity;
Autodesk.Civil.DatabaseServices.Entity _ent2 = tr.GetObject(_ch.ModelPartId, OpenMode.ForWrite) as Autodesk.Civil.DatabaseServices.Entity;
if (_ent1 is Pipe && _ent2 is Pipe)
{
_p1 = _ent1 as Pipe;
_p2 = _ent2 as Pipe;
txt_ct.Text = _p1.Name;
txt_ch.Text = _p2.Name;
}
// get trắc dọc về đối tượng profileview
ProfileView _prfv = tr.GetObject(_id3, OpenMode.ForRead) as ProfileView;
// get toàn bộ các đối tượng cống và hầm ga có trong profileview
//
// I can help me.
}
}
}
public void btn_ok_Click(object sender, EventArgs e)
{
// so lieu dau vao
double _i = Convert.ToDouble(txt_i.Text);
double _drop = Convert.ToDouble(txt_drop.Text);
// get tuyến chứa cống đầu tiên
}
}
}
Note in the fututure when posting code please use the code window on the Rich text tab see image it helps the other posters
Edited by
Discussion_Admin
