HELP ME .. 2d Area FOR VOLUME SURFACE USING C#

HELP ME .. 2d Area FOR VOLUME SURFACE USING C#

hosneyalaa
Advisor Advisor
3,896 Views
14 Replies
Message 1 of 15

HELP ME .. 2d Area FOR VOLUME SURFACE USING C#

hosneyalaa
Advisor
Advisor

Hello all
Please get help 2d Area From volume surface

 

I GET total cut volume  AND total FILL volume  FROM LINK

http://docs.autodesk.com/CIV3D/2019/ENU/API_Reference_Guide/html/3ccfb05b-56ef-dcfe-d13b-1661a96ccd5...

 

BUT I AM NEED 2D AREA 

HOW  IS THAT PLEASE

http://docs.autodesk.com/CIV3D/2019/ENU/API_Reference_Guide/html/56bd45f8-92ce-c1ac-34d0-b63e46947f7...

 

// Create the surface
                    ObjectId surfaceId = TinVolumeSurface.Create(surfaceName, baseId, comparisonId);
                    TinVolumeSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as TinVolumeSurface;
                    surface.Rebuild();

 DVG1.Rows.Add(surface.Name, surface., surface.GetVolumeProperties().AdjustedCutVolume.ToString(), surface.GetVolumeProperties().AdjustedFillVolume.ToString());

 

التقاط.JPGالتقاط0.JPG

 

0 Likes
Accepted solutions (4)
3,897 Views
14 Replies
Replies (14)
Message 2 of 15

Jeff_M
Consultant
Consultant
Accepted solution

That property is not exposed. Nor can we get the triangles to calculate it ourselves.

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

hosneyalaa
Advisor
Advisor

HI @Jeff_M 

 

Do the solution extract the outer Boundare  of the surface as polyline 

And calculate its area

 

0 Likes
Message 4 of 15

Jeff_M
Consultant
Consultant
The TinVolumeSurface object does not have the ExtractBorder() method that the TinSurface has.
Jeff_M, also a frequent Swamper
EESignature
Message 5 of 15

Civil3DReminders_com
Mentor
Mentor
Accepted solution

One can create a new TIN surface (temporary) and then paste the TIN Volume Surface into it and then get access to the desired information. This works in a timely manner if the surfaces are not large.

 

http://docs.autodesk.com/CIV3D/2016/ENU/API_Reference_Guide/html/329508c0-2e0e-5cb6-1279-64666ec5a92...

http://docs.autodesk.com/CIV3D/2016/ENU/API_Reference_Guide/html/2a0de7f5-7b00-1475-e392-ed6ca2d09e0...

 

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
0 Likes
Message 6 of 15

hosneyalaa
Advisor
Advisor

@Civil3DReminders_com 

Thank you so much

This is Good Idea thank you

0 Likes
Message 7 of 15

gleeuwdrent
Advocate
Advocate
Accepted solution

You could also use the COM representation of the TinVolumeSurfaceClass. In COM the 2d Area property is exposed:

 

dynamic comVolumeSurface= volumeSurface.AcadObject; // get the COM representation

double area = comVolumeSurface.Statistics.Area2d;

0 Likes
Message 8 of 15

hosneyalaa
Advisor
Advisor

hi @gleeuwdrent 

 

I am a beginner with a language .net 
When I put in the code it gave me this image
Is it possible how to write the code completely without a mistake from me
So get the 2d Area
Thanks in advance

 

 

 

 

 

// Create the surface
                    ObjectId surfaceId = TinVolumeSurface.Create(surfaceName, baseId, comparisonId);
                    TinVolumeSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as TinVolumeSurface;
                    surface.Rebuild();
 

dynamic comVolumeSurface= volumeSurface.AcadObject; // get the COM representation

double area = comVolumeSurface.Statistics.Area2d;



 DVG1.Rows.Add(surface.Name, area , surface.GetVolumeProperties().AdjustedCutVolume.ToString(), surface.GetVolumeProperties().AdjustedFillVolume.ToString());

 

التقhhhاط.JPG

 

0 Likes
Message 9 of 15

hosneyalaa
Advisor
Advisor

التقhhhاط.JPG

 

0 Likes
Message 10 of 15

gleeuwdrent
Advocate
Advocate

Oops, I looked wrong in the API, the mentioned 

 

Statistics.Area2d;

 

property belongs to TinSurface, not to TinVolumeSurface. Even in COM the 2d area isn't exposed.

 

You could build a method yourself by iterating trough all the triangles and summarize areas. This link gives you a good starting point.

Message 11 of 15

hosneyalaa
Advisor
Advisor

tankyou @gleeuwdrent 

0 Likes
Message 12 of 15

Jeff_M
Consultant
Consultant
Accepted solution

Rather than looping through all of the triangles, just get the Border from the COM object:

 

            var doc = Application.DocumentManager.MdiActiveDocument;
            var ids = CivilApplication.ActiveDocument.GetSurfaceIds();
            using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
            {
                foreach (ObjectId obj in ids)
                {
                    var surf = tr.GetObject(obj, OpenMode.ForRead) as TinVolumeSurface;
                    if (surf == null || !surf.IsVolumeSurface)
                        continue;
                    var layname = surf.Layer;
                    dynamic volsurf = surf.AcadObject;
                    ObjectId plineId = AcDb.DBObject.FromAcadObject(volsurf.ExtractBorder(1)[0]);//1 is the Plan Display orientation type
                    var pline = (Polyline3d)tr.GetObject(plineId, OpenMode.ForRead);
                    var crv = pline.GetOrthoProjectedCurve(new Plane(new Point3d(0, 0, 0), Vector3d.ZAxis));
                    var area = crv.Area;
                    doc.Editor.WriteMessage("\n{0} area: {1}", surf.Name, area.ToString("F2"));
                }
            }
Jeff_M, also a frequent Swamper
EESignature
Message 13 of 15

vucic_tamara
Enthusiast
Enthusiast

I believe this is the way to get Area2D from TinVolumeSurface object:

 

tinVolume.GetTerrainProperties().SurfaceArea2D

0 Likes
Message 14 of 15

vucic_tamara
Enthusiast
Enthusiast
Actually no, there is no such property on TinVolumeSurface, only on TinSurface object. My mistake.
0 Likes
Message 15 of 15

Civil3DReminders_com
Mentor
Mentor

One can create a temporary TIN Surface, paste in the Volume Surface into it, get the property, and then delete the temporary surface. I haven't seen it take a long time for Civil 3D to do, but I haven't tried it on super large surfaces. 

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
0 Likes