Get pipes and structures in profileview

Get pipes and structures in profileview

Anonymous
Not applicable
948 Views
5 Replies
Message 1 of 6

Get pipes and structures in profileview

Anonymous
Not applicable

I have a problem. first, I select a pipe in upperstreamline, next  i select a pipe in lowerstreamline, then i select profileview, which contain them. I want to get entire pipes and structures in profileview, and ascending to sort them according to station. Can you give me this code?

0 Likes
949 Views
5 Replies
Replies (5)
Message 2 of 6

Jeff_M
Consultant
Consultant

@Anonymous, welcome to the forums! Do you have any code you've already tried and are having trouble with? We are here to help, not do it for you.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 3 of 6

Anonymous
Not applicable

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

 

code box.png

0 Likes
Message 4 of 6

Jeff_M
Consultant
Consultant

@Anonymous, since you have the start & end parts that you want to use, you can call the FindShortestNetworkPath() method. This returns an ObjectIdCollection of all of the parts between those 2 parts.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 5 of 6

Anonymous
Not applicable

@Jeff_M I can't use this method. what reference i need add to use this method ? if you have written this method, could you give it for me? thank you so much!

0 Likes
Message 6 of 6

Jeff_M
Consultant
Consultant

You use it like this:

Network.FindShortestNetworkPath(part1.ObjectId, part2.ObjectId, ref dbl);

Where Network is the Class, not the actual network you are working with.

 

Here's the help for it:

http://docs.autodesk.com/CIV3D/2016/ENU/API_Reference_Guide/html/4e245ebc-ede6-291d-0ead-7c0d2b3f86d...

Jeff_M, also a frequent Swamper
EESignature
0 Likes