Internal Error when getting profile label location in profile view (Civil 3D)

I’ve been trying to get the profile label anchor and location information in a profile view using Python in Civil 3D Dynamo.
I first get the label group object, and then for each LabelGroupSubEntity I use
to get the location and anchor info, this works fine when all the labels are in the same profile view. But when I created sheets, the BVC and EVC and PVI may be in different views, and in this case, when I try to get the location info, it always gives me an internal error. Is there a way to get the location in this case?


@tzL6PRM tough to tell without seeing the Python code. Can you share?


Thank your for the reply, here is the code

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
doc = CivilApplication.ActiveDocument

with adoc.LockDocument():
with adoc.Database as db:

    with db.TransactionManager.StartTransaction() as t:
        # Place your code below
        # get the alignment and profile and profile view
        # there is only one alignment in the drawing
        # the profile view I'm having trouble with is index 6
        alignment_id = doc.GetAlignmentIds()[0]
        alignment = t.GetObject(alignment_id, OpenMode.ForRead, True)
        profile_view_id = alignment.GetProfileViewIds()[6]
        profile_view = t.GetObject(profile_view_id, OpenMode.ForRead, True)
        # FG profile index is 1
        profile_id = alignment.GetProfileIds()[1]
        profile = t.GetObject(profile_id, OpenMode.ForRead, True)

        # get all the label groups
        label_groups = ProfileCrestCurveLabelGroup.GetAvailableLabelGroupIds(profile_view_id, profile_id)
        for label_group_id in label_groups:
            label_group = t.GetObject(label_group_id, OpenMode.ForWrite, True)
            # get the sub-entities (the individual labels in each label group)
            for sub_entity in label_group.SubEntities:
                sub_entity_xy = sub_entity.LabelLocation

Profile View Number 6 is the one I’m having trouble getting the label location, as you can see, the labels are separated into 2 profile views. But I don’t have a problem with the one left on view 7, because the PVI is left in the same view.