TheSwamp
Code Red => .NET => Topic started 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!
[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();
}
}
-
surface.PasteSurface(surfToPasteId);
-
Hello again!
Yes it works -thanks
-
Hello!
Did annybody know, why it canīt build a new Civil3d surface, if use metod in a objekt
[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 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
-
solved!
http://forums.autodesk.com/t5/net/opening-a-civil-3d-drawing-for-edit-in-c-net/td-p/5490349/page/2