PointGroup.Add

PointGroup.Add

Civil3DReminders_com
Mentor Mentor
397 Views
4 Replies
Message 1 of 5

PointGroup.Add

Civil3DReminders_com
Mentor
Mentor

When creating a point group on the first run its not using the passed name, but "newNameBase". On the next run it appears to work correctly. Anyone have a fix for this? Checking the name and setting it the desired name doesn't appear to work. 

public static ObjectId GetPointGroupObjId(this CivilDocument civDoc, string name, List<string> existingPtGroupNames)
{
    if (civDoc.PointGroups.Contains(name))
    {
        return civDoc.PointGroups[name];
    }

    var newName = name.CheckNameAndIncrement(existingPtGroupNames);

    var ptGroupObjId = civDoc.PointGroups.Add(newName);

    var ptGroup = ptGroupObjId.GetObject(OpenMode.ForRead) as PointGroup;

    if (ptGroup.Name != newName)
    {
        ptGroup.UpgradeOpen();
        ptGroup.Name = newName;
    }

    return ptGroupObjId;
}

 

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
0 Likes
398 Views
4 Replies
Replies (4)
Message 2 of 5

keith_sowinski
Advocate
Advocate

I don't have a fix for you at the moment, but PointGroupCollection.Add(name) is working for me. It's taking the specified name.  I'm using C3D 2024.4.  Which version are you using?

0 Likes
Message 3 of 5

Civil3DReminders_com
Mentor
Mentor

Both 2024 and 2025, latest updates. I guess I'll delete the first one and then use the second created one. 

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
0 Likes
Message 4 of 5

hippe013
Advisor
Advisor

I am trying to recreate the issue that you are describing, but I can't seem to get a bad result and maybe I am not fully understanding what your issue even is. 

 

I don't understand why you are passing a list of existing point group names to a function that already has access to the existing point groups. 

 

You are checking if the name exists and if it does, you are returning the object id.

 

If it doesn't exist you are checking against your supplied list of "existingPtGroupNames" and, as the name suggests, incrementing the name and then creating a new point group and returning the id. 

 

What am I missing here? Could you explain your issue in further detail? 

0 Likes
Message 5 of 5

Civil3DReminders_com
Mentor
Mentor

Looks like Copilot screwed me once again and guessed wrong on what I was wanting to do and put in a string into the code.

Thanks for looking into it.

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
0 Likes