TheSwamp

Code Red => .NET => Topic started by: cadplayer on February 20, 2016, 04:10:38 AM

Title: Civil3d-api Add Contourset to Surface
Post by: cadplayer on February 20, 2016, 04:10:38 AM
Code: [Select]
Transaction tr = doc.TransactionManager.StartTransaction();
            using (tr)
            {
                TinSurface surf = Surface.GetSurfaceObject(m_name);
                ObjectIdCollection coll = null;
                coll = Selection.Sset3dPolyline();
                SurfaceOperationAddContour contlines = null;

                try
                {
                    contlines = surf.ContoursDefinition.AddContours(coll, 1.0, 100.0, 15.0, 4.444);
                    surf.Rebuild();
                }
                catch (System.Exception ex)
                {

                }

                tr.Commit();
            }

Hi guys!
I have trouble with the metod ContoursDefinition.AddContours(coll, 1.0, 100.0, 15.0, 4.444) in Civil3d-api
If I do manually add contours to a surface - select 3dPolylines to add and give parameters
Mid-ordinate distance = 1
Maximum distance = 100
Weeding distance = 15
Weeding angle = 4,444
(see picture1)

the triangulation between selected 3dPolylines looks fine.

But if I do the same with metod ContoursDefinition.AddContours() it looks like diffrent. I do not understand why. Have I missing something?!
(see picture 2)
Title: Re: Civil3d-api Add Contourset to Surface
Post by: cadplayer on February 20, 2016, 05:34:50 AM
Hi!
I have found a diffrent in Surfaces between creates triangles after my code and if I do the same only with Civil3d prospector.
In definition of right case shows "Minimize flat areas", but not in created triangles after min code. Have it something to do, why itīs diffrent triangulations ?

Title: Re: Civil3d-api Add Contourset to Surface
Post by: Jeff_M on February 20, 2016, 10:45:20 AM
When you add Contours data to the surface definition in C3D you supply the Minimize flat areas options. So you must also do this when adding them in code with the MinimizeFlatAreas() method which takes a SurfaceOperationMinimizeFlatAreas structure as an argument.

Title: Re: Civil3d-api Add Contourset to Surface
Post by: cadplayer on February 20, 2016, 02:32:20 PM
Super, Iīm very happy - thanks so much Jeff. I tried many times with metod surf.MinimizeFlatAreas(SminiFlatAreaO) - but nothing happens. I didnīt realize what settings in ContoursDefinition.AddContours() means in there arguments ?!
Mid-ordinate distance = 1
Maximum distance = 100
Weeding distance = 15
Weeding angle = 4,444
After using your parameters in surf.ContoursDefinition.AddContours(coll, 0.001, 0.015, 0.01, 4.0) itīs going right;

Code: [Select]
            Transaction tr = doc.TransactionManager.StartTransaction();
            using (tr)
            {
                TinSurface surf = Surface.GetSurfaceObject(m_name);
                ObjectIdCollection coll = null;
                coll = Selection.Sset2dPolyline();
                SurfaceOperationAddContour contlines = null;
                SurfaceMinimizeFlatAreaOptions SminiFlatAreaO = new SurfaceMinimizeFlatAreaOptions(true, true, true, true);

                try
                {
                    //contlines = surf.ContoursDefinition.AddContours(coll, 1.0, 100.0, 15.0, 4.444);
                    contlines = surf.ContoursDefinition.AddContours(coll, 0.001, 0.015, 0.01, 4.0);
                    surf.MinimizeFlatAreas(SminiFlatAreaO);
                    surf.Rebuild();
                }
                catch (System.Exception ex)
                {

                }

                tr.Commit();
            }