---
title: How to obtain Profile’s LabelSetId?
description: "## Profile, Profile View, and LabelSetId When you create a Profile via [`Profile.Create` API](https://help.autodesk.com/view/CIV3D/2025/ENU/?guid=4ae959e8-6949-90dd-b393-12fd2fe14d44), you need to specify a `ProfileSetId`, so how can you obtain the `ProfileSetId` from the code? This could be important if you are creating an `Offset…"
url: "https://civilwhiz.com/docs/how-to-obtain-profiles-labelsetid/"
updated: "2025-03-27"
category: API
---

# How to obtain Profile’s LabelSetId?

## Profile, Profile View, and LabelSetId

When you create a Profile via [`Profile.Create` API](https://help.autodesk.com/view/CIV3D/2025/ENU/?guid=4ae959e8-6949-90dd-b393-12fd2fe14d44), you need to specify a `ProfileSetId`, so how can you obtain the `ProfileSetId` from the code?

This could be important if you are creating an `Offset Profile`, and you want it to have the same `LabelSetId` as its parent Profile.

The answer is that **you can’t**, because there is not such thing as *the* `ProfileSetId` for a `Profile`.

All you have is that you have a `ProfileSet` for a `Profile` *in a `Profile View`*. Yes, a `ProfileSet` ( and hence, `ProfileSetId`) is depending on both the `Profile` and `Profile View`.

Since [a `Profile View` can have multiple `Profiles`](/docs/how-to-obtain-the-elevation-at-the-precise-station-for-a-profile/#1-toc-title), you will need to set their individual `LabelSet` in the **Profile View Properties**, as shown in the following screenshot:

![Profile in Profile View](/wp-content/uploads/2025/03/profile-label-set.png)

## How to obtain the LabelSetId for a Profile in a Profile View?

To obtain the `LabelSetId` for a `Profile` in a `Profile View`, you will need to pass in both the `Profile View` `ObjectId` and `Profile` `ObjectId`. Here’s the code that you can use to do this.

```csharp
private static void Transact(Action<Transaction> action)
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    using var tr = doc.TransactionManager.StartTransaction();
    action(tr);
    tr.Commit();
}

public static T GetObject<T>(this Transaction ts, ObjectId objectId, OpenMode openMode = OpenMode.ForRead)
    where T : DBObject
{
    return ts.GetObject(objectId, openMode) as T;
}

[CommandMethod(nameof(ReadProfileLabelSets))]
public void ReadProfileLabelSets()
{
    Transact(ReadProfileLabelSetMethod);
}

private void ReadProfileLabelSetMethod(Transaction ts)
{
    var alignmentIds = CivilApplication.ActiveDocument.GetAlignmentIds();
    var lblgrpClass = RXObject.GetClass(typeof(ProfileLabelGroup));

    foreach (ObjectId alignmentId in alignmentIds)
    {
        var alignment = ts.GetObject<Alignment>(alignmentId);
        var profileIds = alignment.GetProfileIds();

        foreach (ObjectId profileId in profileIds)
        {
            var profileViewIds = alignment.GetProfileViewIds();
            foreach (ObjectId profileViewId in profileViewIds)
            {
                var allPointLabelGroup = ProfileHorizontalGeometryPointLabelGroup.GetAvailableLabelGroupIds(profileViewId, profileId);
                var lblgrpIds = ProfileLabelGroup.GetAvailableLabelGroupIds(lblgrpClass, profileViewId, profileId, true);
            }
        }
    }
}
```

So generally, you can use the `GetAvailableLabelGroupIds` static method to get the available `LabelSets` for Profiles in Profile View. So the `Count` above will not be 0 if the `LabelSet` is properly assigned.

## Acknowledgement

Thanks to [@Jeff_M](https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637) and [@hippe013](https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1633394) for the discussion.

  [![](https://civilwhiz.com/wp-content/uploads/2025/02/someoneme.jpg)](https://civilwhiz.com/author/civilwhiz/)[Ngu Soon Hui](https://civilwhiz.com/author/civilwhiz/)

My passion is in [sharing knowledge](/about/) — Civil 3D or otherwise– with the world.

I’m also the [benevolent dictator for life](https://mes100.com/about-ngu-soon-hui/) at MES Innovation Sdn Bhd.
