TheSwamp

Code Red => .NET => Topic started by: cadplayer on September 15, 2015, 03:08:06 AM

Title: Autodesk::Civil::Land::DatabaseServices::SurfaceOperationPasteSurface
Post by: cadplayer on September 15, 2015, 03:08:06 AM
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();

            }
        }
Title: Re: Autodesk::Civil::Land::DatabaseServices::SurfaceOperationPasteSurface
Post by: Jeff_M on September 15, 2015, 09:33:21 AM
surface.PasteSurface(surfToPasteId);
Title: Re: Autodesk::Civil::Land::DatabaseServices::SurfaceOperationPasteSurface
Post by: cadplayer on September 25, 2015, 05:26:53 AM
Hello again!
Yes it works -thanks
Title: Re: Autodesk::Civil::Land::DatabaseServices::SurfaceOperationPasteSurface
Post by: cadplayer 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
 
Title: Re: Autodesk::Civil::Land::DatabaseServices::SurfaceOperationPasteSurface
Post by: cadplayer on September 29, 2015, 09:51:45 AM
solved!
http://forums.autodesk.com/t5/net/opening-a-civil-3d-drawing-for-edit-in-c-net/td-p/5490349/page/2