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
sub_entity.LabelLocation
or
sub_entity.DimensionAnchorInfo.Location
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?

Thanks

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

@mzjensen

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
        # https://help.autodesk.com/view/CIV3D/2021/ENU/?guid=ef8424ec-f759-4826-8a86-1b97eabf710c
        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)
            # https://help.autodesk.com/view/CIV3D/2021/ENU/?guid=9078bd07-1e44-3eed-b744-381d1602f534
            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.