Author Topic: Autodesk::Civil::Land::DatabaseServices::SurfaceOperationPasteSurface  (Read 2658 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Hello colleagues!
I have a question how to build in method "SurfaceOperationPasteSurface". For example I want create a new surface "ExampleTINSurface" as code after and than select a surface in drawing that would paste in the created surface. Iīm a little bit new in CivilAPI and have not so much experience. Maybe somebody can help me. Thank you!

Code: [Select]
       
[CommandMethod("xx")]
        public void CDS_CreateTinSurface()
        {

            using (tr)
            {
                string surfaceName = "ExampleTINSurface";
                // Select a style to use
                ObjectId surfaceStyleId = civilDoc.Styles.SurfaceStyles[3];

                // Create the surface
                ObjectId surfaceId = TinSurface.Create(surfaceName, surfaceStyleId);

                TinSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as TinSurface;

               

                tr.Commit();

            }
        }

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Autodesk::Civil::Land::DatabaseServices::SurfaceOperationPasteSurface
« Reply #1 on: September 15, 2015, 09:33:21 AM »
surface.PasteSurface(surfToPasteId);

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Autodesk::Civil::Land::DatabaseServices::SurfaceOperationPasteSurface
« Reply #2 on: September 25, 2015, 05:26:53 AM »
Hello again!
Yes it works -thanks
« Last Edit: September 26, 2015, 06:39:37 AM by cadplayer »

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: Autodesk::Civil::Land::DatabaseServices::SurfaceOperationPasteSurface
« Reply #3 on: September 26, 2015, 06:45:36 AM »
Hello!
Did annybody know, why it canīt build a new Civil3d surface, if use metod in a objekt
Code: [Select]
[CommandMethod("create")]
        public void CreateTinSurfaceTest()
        {
            Document m_Doc = Application.DocumentManager.MdiActiveDocument;
            Database db = m_Doc.Database;
            Editor ed = m_Doc.Editor;
            using (Transaction m_Tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    m_SurfaceId = Autodesk.Civil.DatabaseServices.TinSurface.Create(db, "m_NewSurfaceName");
                    m_Surface = m_SurfaceId.GetObject(OpenMode.ForWrite) as TinSurface;
                    ed.WriteMessage("Import succeeded: {0} \n {1}", m_SurfaceId.ToString(), db.Filename);
                }
                catch (System.Exception e)
                {
                    ed.WriteMessage("Import failed: {0}", e.Message);
                }
                m_Tr.Commit();
            }
        }

By typing command: create - it works > surface "m_NewSurfaceName" would created

But if I call metod from class-object
Code: [Select]
public NewSurface()
        {
            Surface newSurf = new Surface();
            newSurf.CreateTinSurfaceTest();
        }

I get only error-message "failed to create"

Somebody know a trick, how I can create a surface an other way
 

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)