Hi.
I have this:
for(int i=0;i<= tinSurface.BreaklinesDefinition.Count-1;i++) { ............................
}
I have each breakline sets, but I want each breakline of each breakline set(breaklinesDefinition).
I can do this:
Autodesk.Civil.DatabaseServices.SurfaceBreakline sfb = default(Autodesk.Civil.DatabaseServices.SurfaceBreakline); SurfaceBreakline sfb= trans.GetObject(id,OpenMode.ForWrite) as SurfaceBreakline;
But how can I get ObjectIdcollection of surfaceBreakline of one breaklinesDefinition?
I have seen that there is "AECC.Interop.Land.SurfaceBreaklines". Do I have to use this?
Thank you.
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
Solved by joantopo. Go to Solution.
Thanks.
I will wait then because I am very bad with COM.
Here's that code, Joan. It is an extension method for a TinSurface which returns the Entity ObjectIds of the specified SurfaceOperationBreakline object.
//a command to test against [CommandMethod("brkTest")] public void brktestcommand() { CivilDocument civdoc = CivilApplication.ActiveDocument; using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()) { TinSurface surf = (TinSurface)civdoc.GetSurfaceIds()[0].GetObject(OpenMode.ForRead); SurfaceOperationAddBreakline brkln = surf.BreaklinesDefinition[0]; ObjectIdCollection brkentsIds = surf.GetBreaklineEntityIds(brkln); tr.Commit(); } } //and the extension method which should go in it's own static class public static class SurfaceExtensions { public static ObjectIdCollection GetBreaklineEntityIds(this CivDb.TinSurface surf, CivDb.SurfaceOperationAddBreakline brklineOp) { string name = brklineOp.Description; ObjectIdCollection result = new ObjectIdCollection(); object tinsurf = surf.AcadObject; object brklines = (object)tinsurf.GetType().InvokeMember("Breaklines", System.Reflection.BindingFlags.GetProperty, null, tinsurf, null); object[] args = new object[1]; for (int j = 0; j < (int)brklines.GetType().InvokeMember("Count", System.Reflection.BindingFlags.GetProperty, null, brklines, null); j++) { args[0] = j; object brklin = brklines.GetType().InvokeMember("Item", System.Reflection.BindingFlags.InvokeMethod, null, brklines, args); string desc = (string)brklin.GetType().InvokeMember("Description", System.Reflection.BindingFlags.GetProperty, null, brklin, null); if (desc == name) { object[] ents = (object[])brklin.GetType().InvokeMember("BreaklineEntities", System.Reflection.BindingFlags.GetProperty, null, brklin, null); for (int i = 0; i < ents.GetLength(0); i++) { ObjectId id = DBObject.FromAcadObject(ents[i]); result.Add(id); } } } return result; } }
Hope that helps.
Thanks a lot ,Jeff.
Once I have Id entity, could I delete that breakline?
deletebreakline method doesn´t exist.
I have this:
Autodesk.Civil.DatabaseServices.TinSurface tinSurface = trans.GetObject(surfaceId, OpenMode.ForWrite) as Autodesk.Civil.DatabaseServices.TinSurface; //obtenemos todos los id de las líneas de rotura de la superfície y comprobamos si coincide con el Id de la entidad seleccionada if (tinSurface.BreaklinesDefinition.Count > 0) //si hay algún conjunto de líneas de rotura { SurfaceDefinitionBreaklines brkdefs = tinSurface.BreaklinesDefinition; for (int i = 0; i <= brkdefs.Count - 1; i++) { SurfaceOperationAddBreakline brklines = brkdefs[i]; ObjectIdCollection coll = new ObjectIdCollection(); coll = ExtensionMethods.SurfaceExtensions.GetBreaklineEntityIds(tinSurface, brklines); //lo añadimos todos a la colección principal. foreach (ObjectId id in coll) { todosIDbrkl.Add(id); } } } if (todosIDbrkl.Contains(entRes.ObjectId) == false) //si la entidad seleccionada no existe como línea de rotura de la superficie. { MessageBox.Show("La entidad seleccionada no pertenece a la superfície como línea de rotura.", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //if exists Id entity, erase that breakline // rebuild the surface tinSurface.Rebuild();
I have other function to delete all breaklines definitions and create new breaklinesdefinitions. Perhaps I can call this function and put Id as parameter to not include this entity as breakline.
I don´t understand why Civil 3D give us possibility add 2 or more times the same entity as breakline in the surface. ¿?
@joantopo wrote:
Thanks a lot ,Jeff.
Once I have Id entity, could I delete that breakline?
deletebreakline method doesn´t exist.
I have other function to delete all breaklines definitions and create new breaklinesdefinitions. Perhaps I can call this function and put Id as parameter to not include this entity as breakline.
You're welcome. This is what I have done as well. There is no good way to do this with the current API, at least not that I have found.
Not sure, but I think this may come from looping through breaklines whose Autocad entities have been erased but the surface retains them if the Build operations "Copy deleted dependent objects" is set to true. When this happens there is no object to get an objectid for. If this is what you are seeing, adding a try{} catch{} should work around that. If you want to add the object back, I think that can be done with the .NET Breakline object....would have to do some testing, but I can't do that right now.