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: 

variables (vars) from objects.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
joantopo
357 Views, 2 Replies

variables (vars) from objects.

Hi.

 

I have this:

 

  Autodesk.Civil.DatabaseServices.Surface sup = new Autodesk.Civil.DatabaseServices.Surface();

                if (checkBox_Revision.Checked == true && radioButton_RevisionPtoSup.Checked==true)
                {
                    //comprobamos si alguna superficie del dibujo coincide con el origen de datos.


                    Autodesk.Civil.ApplicationServices.CivilDocument civDoc = default(Autodesk.Civil.ApplicationServices.CivilDocument);
                    civDoc = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument; //obtener el documento de Civil

                    ObjectIdCollection SurfaceColl = civDoc.GetSurfaceIds();  //obtener la colección de superficies

                    foreach (ObjectId id in SurfaceColl)  // para cada superficie abierta para leer
                    {

                        Autodesk.Civil.DatabaseServices.Surface surface = trans.GetObject(id, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Surface;

                        if (surface.Name == comboBox_Origenes.ValueMember)
                        {
                          sup = trans.GetObject(surface.ObjectId, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Surface;
                        }
                    }
                }

 I have problems with:

 Autodesk.Civil.DatabaseServices.Surface sup = new Autodesk.Civil.DatabaseServices.Surface();

 and debugger show a message as "it´s not accessible due its level of protection".

 

I don´t want:

  Autodesk.Civil.DatabaseServices.Surface sup = trans.GetObject(surface.ObjectId, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Surface;

 because I need "sup" in other function and this function there is a loop and I don´t want read every time the same object.

 

Do I have to do this?

  Autodesk.Civil.DatabaseServices.Surface sup = trans.GetObject(surface.ObjectId, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Surface;

 for each loop?

 

 I have put this var out of all functions and void, only in the header of class but the problem is the same. I have also tried with "public static" but the message appears again.

 

Thank you in advance.

 

 

 

 

 

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

Not quite sure what you are saying by "sup is used in other function", but this is what I do to intialize a variable for use:

Autodesk.Civil.DatabaseServices.Surface sup = null;

 and then I can set it later in other places of the code.

 

 

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

ok.

It was that.

 

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

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report