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 ObjectId from CorridorSurface?

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
joantopo
510 Views, 8 Replies

get ObjectId from CorridorSurface?

Hi.

 

If I have TIN surfaces in drawing, I can read (transaction) that objects.

 

PromptEntityOptions entOpts2 = new PromptEntityOptions("\nSelect TIN surface: ");

            var _with2 = entOpts2;
            _with2.SetRejectMessage("\Incorrect object.");


            _with2.AddAllowedClass(typeof(Autodesk.Civil.DatabaseServices.TinSurface), true);
            _with2.AllowNone = true;
            _with2.AllowObjectOnLockedLayer = true;
            PromptEntityResult entRes2 = ed.GetEntity(entOpts2);
            if (entRes2.Status != PromptStatus.OK)
                return;

            ObjectId IdSurf = entRes2.ObjectId;

using (Transaction trans = db.TransactionManager.StartTransaction())
{


TinSurface sup = trans.GetObject(IdSurf, OpenMode.ForRead as TinSurface);



trans.Commit();
}


 

However, if I have corridor surfaces in the drawing, I canĀ“t read them (doing the transaction), because CorridorSurfaces have "surfaceId" property and "ObjectId" is not valid.

 

So, How can I do it?

 

 

Thanks.

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
8 REPLIES 8
Message 2 of 9
joantopo
in reply to: joantopo

Moreover, I get this bug:

 

img.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 3 of 9
Jeff_M
in reply to: joantopo

Joan, A corridor surface is just a TinSurface. You can select it on screen just like any other surface.
Jeff_M, also a frequent Swamper
EESignature
Message 4 of 9
joantopo
in reply to: Jeff_M

Ok.

Thanks Jeff.

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 5 of 9
joantopo
in reply to: Jeff_M

Sorry.

 

How do you know if a TIN Surface is a corridor surface?

 

I donĀ“t find any property in TinSurface class about this?

 

Perhaps, it was good an extension method (for TinSurfaces) like "IsFromCorridor".

 

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 9
joantopo
in reply to: joantopo

Do I have to get a corridor surface List and compare their "Names" property  with the "DisplayName" property of TinSurfaces, to guess if  each surface is actually a corridor surface?

 

I have seen this:

http://knowledge.autodesk.com/support/autocad-civil-3d/learn-explore/caas/CloudHelp/cloudhelp/2015/E...

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 9
Jeff_M
in reply to: joantopo

Like so...

                TinSurface tinsurf = civilEnt as TinSurface;
                if (tinsurf!=null)
                {
                    for (int i = 0; i < tinsurf.Operations.Count; i++)
                    {
                        SurfaceOperation op = tinsurf.Operations[i];
                        if (op.Enabled && op.GetType() == typeof(SurfaceOperationCreatedFromCorridor))
                        {
                            ed.WriteMessage("This is a Corridor surface.\r\n");
                            break;
                        }
                    }
                }

 

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

Great !

 

Now itĀ“s a property (field) of my Surface List.

 

  public static List<toolsC3D.Surfaces> ComprobarSuperficies_sonCorridorSurfaces(List<Surfaces> listSup)
        {
                Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
             Database db = doc.Database;
             Editor ed = doc.Editor;

             using (Transaction trans = db.TransactionManager.StartTransaction())
             {

                 for (int k = 0; k <= listSup.Count - 1; k++)  //revisamos si cada superficie de la lista, es una superficie de obra lineal.
                 {
                     TinSurface tinsurf = trans.GetObject(listSup[k].Id, OpenMode.ForRead) as TinSurface;
                     if (tinsurf != null)
                     {
                         for (int i = 0; i < tinsurf.Operations.Count; i++)
                         {
                             SurfaceOperation op = tinsurf.Operations[i];
                             if (op.Enabled && op.GetType() == typeof(SurfaceOperationCreatedFromCorridor))
                             {
                                 listSup[k].IsSurfaceCorridor = true;
                                 // ed.WriteMessage("This is a Corridor surface.\r\n");
                             }
                         }
                     }

                 }
                 trans.Commit();
             }
            

            return listSup;
        }

 

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 9
Jeff_M
in reply to: joantopo

For anyone else coming across this thread, the SurfaceOperationCreatedFromCorridor type was not available in C3D2013's initial inclusion of the Surface .NET API. So the above code will only work with C3D2014 and newer.
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