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: 

About "SectionSource"

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
joantopo
583 Views, 6 Replies

About "SectionSource"

Hi.

I´m trying to get all sources of one sample line group.

 

Now, I have this:

 using (DocumentLock docLock = doc.LockDocument())
                {
                    using (Transaction trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
                    {
                        SampleLineGroup glm = trans.GetObject(grupsColl[pos2], OpenMode.ForWrite) as SampleLineGroup;
                        //obtenemos los grupos de líneas de muestreo de la alineacion seleccionada.

                        SectionSourceCollection origenes = glm.GetSectionSources();


                        foreach (SectionSource fuente in origenes)  // para cada alineación abierta para leer
                        {

                          //  string name = fuente.ToString();
                          //  OrigenesNames.Add(name);
                        }

                        trans.Commit();
                    }
                }

 I have to had put as "OpenMode.ForWrite" because the debugger show exception if that was only por Read.

 

My trouble is that I want the source´s names I can´t get it.

 

SectionSource object has this properties:

-IsSampled.

-SourceId.

-SourceType.

-StyleId.

-UpdateMode.

 

I have seen that this object has this method: ".getSectionsIds()" that returns a ObjectIdCollection, but I only want secctions of this source and belongs to the sample line group that I have selected.

 

For example:

I have 3 combobox:

First combobox= select alignment.

Second combobox= select sample line group of this selected alignment.

Third combobox= select one of source belong of selected sample line group.

 

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

SourceId doesn´t have Name or Description Property.

 

I could use SourceType.ToString() but I would like to show within combobox  the source´s name.

 

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

If you refer to Civil 3D .NET API Ref document, you will see
SectionSource doesn't have any Name prop.

 

I think you will need to look into the SectionSourceType and then knowing the type get the actual object (say 'TinSurface' ) and get it's name. I haven't tried it yet, but if I, I will try this path.

 

Thanks,
Partha

Message 4 of 7
joantopo
in reply to: Anonymous

ok.

 

But you can have two or more sources with the same sectionSourceType in the drawing.

 

 

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

property "IsSampled= =True" it´s when this source has been used (added as source for sample line group), =false  this source is available but we  haven´t used it yet.

 

However, we can this case:

 

- two alignments.

-one sample line group for each alignment.

-two tinSurface.

 

First sample line group uses Surface1  and Second sample line group uses Surface2.

 

Then, we have 2 sources, and both are "IsSampled", however, we only want the source of the first sample line group.  How do you Know which surface is used by the first sample line group?

 

 

 

 

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

Get the Source object from the SourceId (which is an ObjectId), then get tname from the object. Although, in the case of Corridor Surface sections, this returns the name of the Corridor, not which surface of the corridor (Top, Datum, etc.). Using the tutorial drawing Sections-Grade-Label, here is the result of the code to follow:

 

Section source type & name is: TinSurface, EG
Section source type & name is: Corridor, Corridor - (1)
Section source type & name is: CorridorSurface, Corridor - (1)
Section source type & name is: CorridorSurface, Corridor - (1)

 

        [CommandMethod("SourceTest")]
        public void sourcetest()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            CivilDocument civdoc = CivilApplication.ActiveDocument;
            using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
            {
                Alignment align = (Alignment)civdoc.GetSitelessAlignmentId("Centerline (1)").GetObject(OpenMode.ForRead);
                SampleLineGroup slg = (SampleLineGroup)align.GetSampleLineGroupIds()[0].GetObject(OpenMode.ForWrite);
                foreach (SectionSource src in slg.GetSectionSources())
                {
                    CivDb.Entity ent = (CivDb.Entity)src.SourceId.GetObject(OpenMode.ForRead);
                    ed.WriteMessage("\nSection source type & name is: {0}, {1}", src.SourceType.ToString(), ent.Name);
                }
                tr.Commit();
            }
        }

 

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

Perfect. 

 

I usually use it only for TinSurfaces.

 

 

 

 

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