Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HOW TO ACCES THE MATERIALQUANTITY AREA OF THE OBJECT SECTION

1 REPLY 1
Reply
Message 1 of 2
inversiones_edgar_itriago
268 Views, 1 Reply

HOW TO ACCES THE MATERIALQUANTITY AREA OF THE OBJECT SECTION

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

Tags (3)
1 REPLY 1
Message 2 of 2

You would be better of placing this in the customization forum.

Rick Jackson
Survey CAD Technician VI

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report