Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

get surfaceBreaklines.

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
joantopo
709 Views, 11 Replies

get surfaceBreaklines.

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.

 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
11 REPLIES 11
Message 2 of 12
Jeff_M
in reply to: joantopo

Yes, you actually need to use the BreaklineEntities property using COM. I have some code at home that shows how this can be done using late binding so the COM Interops don't need to be referenced. I will post it when I return from AU, unless you get it figured out first.
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 12
joantopo
in reply to: Jeff_M

Thanks.

I will wait then because I am very bad with COM.

 

 

 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 4 of 12
Jeff_M
in reply to: joantopo

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.

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 12
joantopo
in reply to: Jeff_M

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.

 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 6 of 12
joantopo
in reply to: joantopo

I don´t understand why Civil 3D give us possibility add 2 or more times the same entity as breakline in the surface. ¿?

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 7 of 12
Jeff_M
in reply to: joantopo


@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.

Jeff_M, also a frequent Swamper
EESignature
Message 8 of 12
joantopo
in reply to: Jeff_M

Hi Jeff. Sometines I get a bug in your GetBreaklineEntityIds() method: Here, there is a screenshoot in VS: http://s22.postimg.org/yarcpmoht/capturada.jpg
Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 9 of 12
joantopo
in reply to: joantopo

it is a "TargetInvocationException".
Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 10 of 12
joantopo
in reply to: joantopo

COMPlusExceptionCode= -532462766
Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 11 of 12
Jeff_M
in reply to: joantopo

Can you send me the drawing you get this error in?

Jeff_M, also a frequent Swamper
EESignature
Message 12 of 12
Jeff_M
in reply to: Jeff_M

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.

Jeff_M, also a frequent Swamper
EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report