Author Topic: Civil3d-api Add Contourset to Surface  (Read 1656 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Civil3d-api Add Contourset to Surface
« 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)

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Civil3d-api Add Contourset to Surface
« Reply #1 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 ?


Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Re: Civil3d-api Add Contourset to Surface
« Reply #2 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.


cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Civil3d-api Add Contourset to Surface
« Reply #3 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();
            }