HOW TO ACCES MATERIALQUANTITY AREAS (sq.m) OF AN OBJECT SECTION
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, someone knows if it is possible to access MaterialQuantity areas (sq.m) of an object Section through the API (code)?
This is the code that Im using=
private void UsingSectios()
{
Document AcDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDB = AcDoc.Database;
CivilDocument doc = CivilApplication.ActiveDocument;
// Use Centerline (1)
Alignment alignment = null;
//using (Transaction ts = acCurDB.TransactionManager.StartTransaction())
using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
foreach (ObjectId alignmentId in doc.GetAlignmentIds())
{
Alignment a = ts.GetObject(alignmentId, OpenMode.ForRead) as Alignment;
if (a.Name == "Centerline (1)") { alignment = a; break; }
}
// Get the first sample line group, SLG-1:
SampleLineGroup sampleLineGroup = ts.GetObject(alignment.GetSampleLineGroupIds()[0], OpenMode.ForRead) as SampleLineGroup;
foreach (ObjectId sampleLineId in sampleLineGroup.GetSampleLineIds())
{
SampleLine sampleLine = ts.GetObject(sampleLineId, OpenMode.ForRead) as SampleLine;
foreach (ObjectId sectionId in sampleLine.GetSectionIds())
{
Section section = ts.GetObject(sectionId, OpenMode.ForWrite) as Section;
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Section {0} Area {1}\n", section.Name, section.Area);
}
}
//ts.Commit();
}
}
and when I load and run the dll in civil 3d this throws me a zero value in the area=
Section SLG-1 - 0+000.00 - F1-F2-F3-F4 Inicial(878) Station 0.00 Area 0
Section SLG-1 - 0+000.00 - F3-F4 EST(879) Station 0.00 Area 0
Section SLG-1 - 0+000.00 - Material List - (15) - Material - (22)(900) Station 0.00 Area 0
Section SLG-1 - 0+004.86 - F1-F2-F3-F4 Inicial(882) Station 4.86 Area 0
Section SLG-1 - 0+004.86 - F3-F4 EST(883) Station 4.86 Area 0
Section SLG-1 - 0+004.86 - Material List - (15) - Material - (22)(901) Station 4.86 Area 0
Section SLG-1 - 0+006.81 - F1-F2-F3-F4 Inicial(884) Station 6.81 Area 0
Section SLG-1 - 0+006.81 - F3-F4 EST(885) Station 6.81 Area 0
Section SLG-1 - 0+006.81 - Material List - (15) - Material - (22)(902) Station 6.81 Area 0
Here I attached files so they will understand what I am doing.
Thanks in advance