Profile views Show only Crossing Pipes and label it

Hi Everyone
I appreciate your help
Target : showing crossing pipes for multiple profile views with set the style overrides and label it.
Same topic with video and example

C3D_PV_SAMPLE.dwg (2.3 MB)

For Label i found this API code for labeling pipe crossing in multiple section views the same idea for Profile views.


image
C3D_PV_SAMPLE.dwg (2.4 MB)

[CommandMethod("AddPipeLabelsToSections")]
        public void LabelsToSections()
        {
            var civdoc = CivilApplication.ActiveDocument;
            var db = Application.DocumentManager.MdiActiveDocument.Database;
            double station = double.NaN, offset = double.NaN;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (ObjectId alignId in civdoc.GetAlignmentIds())
                {
                    var align = (Alignment)alignId.GetObject(OpenMode.ForRead);
                    if (align.GetSampleLineGroupIds().Count < 1)
                        continue;
                    foreach(ObjectId slId in align.GetSampleLineGroupIds())
                    {
                        var slg = (SampleLineGroup)slId.GetObject(OpenMode.ForRead);
                        if (slg.SectionViewGroups.Count < 1)
                            continue;
                        for(int i = 0; i < slg.SectionViewGroups.Count; i++)
                        {
                            var group = slg.SectionViewGroups[i];
                            foreach(ObjectId svId in group.GetSectionViewIds())
                            {
                                var sv = (CivDb.SectionView)svId.GetObject(OpenMode.ForRead);
                                foreach (var oride in sv.GraphOverrides)
                                {
                                    var section = (CivDb.Section)oride.SectionId.GetObject(OpenMode.ForRead);
                                    if (section.SourceType != SectionSourceType.PipeNetwork)
                                        continue;
                                    var alignStation = section.Station;
                                    var network = (Network)section.SourceId.GetObject(OpenMode.ForRead);
                                    var partsInView = new Dictionary<ObjectId, double>();
                                    foreach (ObjectId strucId in network.GetStructureIds())
                                    {
                                        var structure = (Structure)strucId.GetObject(OpenMode.ForRead);
                                        align.StationOffset(structure.Easting, structure.Northing, ref station, ref offset);
                                        if (Math.Abs(station - alignStation) < 0.5)//structure must be within 0.5' of section
                                        {
                                            partsInView.Add(strucId, offset);
                                        }
                                    }
                                    foreach (ObjectId pipeId in network.GetPipeIds())
                                    {
                                        var pipe = (Pipe)pipeId.GetObject(OpenMode.ForRead);
                                        //find pipes connected to 2 structures in view
                                        if (partsInView.ContainsKey(pipe.StartStructureId) && partsInView.ContainsKey(pipe.EndStructureId))
                                        {
                                            var pipeOffset = (partsInView[pipe.StartStructureId] + partsInView[pipe.EndStructureId]) / 2;
                                            partsInView.Add(pipeId, pipeOffset);
                                            continue;
                                        }
                                        //add code to find pipes with only 1 structure connected but is parallel to sample line
                                        //add code to find pipes with no structure connected but is parallel to sample line
                                    }
                                    //sort the partsInView by the offsets, this may not be needed since the index appears to always be 0
                                    var sortedDict = from entry in partsInView orderby entry.Value ascending select entry;
                                    int pipeIdx = 0, strucIdx = 0;
                                    foreach (var part in sortedDict)
                                    {
                                        if (part.Key.ObjectClass.DxfName.Contains("PIPE"))
                                        {
                                            PipeSectionLabel.Create(svId, part.Key, section.ObjectId, pipeIdx);//pipeIdx fails for any value other than 0?
                                            //pipeIdx++;
                                        }
                                        else
                                        {
                                            StructureSectionLabel.Create(svId, part.Key, section.ObjectId, strucIdx); //strucIdx fails for any value other than 0?
                                            //strucIdx++;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                tr.Commit();
            }
        }

Code above by
Jeff_M

I’m not sure
Items can be obtained The network in the profile view But It is not possible to determine which one It is crossed with alignment
There is no method at this time

Salam Alikom Alaa
Did you check the above code C#
its already done for multiple cross section , can we replace cross-sections to profile views?

I think it doesn’t work
If pipe intersects with sections No necessary
It intersects with the alignment