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.
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
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.
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
ok.
But you can have two or more sources with the same sectionSourceType in the drawing.
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?
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(); } }
Perfect.
I usually use it only for TinSurfaces.