Skip to main content
1-Visitor
February 12, 2020
Question

Group features using VB api

  • February 12, 2020
  • 1 reply
  • 1518 views

Hello, 

 

I'm trying to create a method that can group any number of UDFGroups in a part. What i have below can find the correct UDFGroups, but once the .Append(feature) is run it returns an error. Have i thought about this the wrong way? 

 

featureType: a string that specifies the wanted UDFgroup name.

nrOf: an int that specifies how many of the instances that should be appended.

 

 

public static void CreateGroup(string featureType, int nrOf)
 {
 IpfcFeatures selectedFeatures = null;
 IpfcFeatures features;

 features = componentModel.ListFeaturesByType(true,EpfcFeatureType.EpfcFEATTYPE_GROUP_HEAD);
 //For each point
 for (int i = 0; i <= nrOf; i++)
 {
 //Search in features
 foreach (IpfcFeature feature in features)
 {
 if (feature.Group.GroupName == $"{featureType}{i}".ToUpper())
 {
 selectedFeatures.Append(feature); //<--- Error here
 break;
 }
 }
 }
 componentModel.CreateLocalGroup((CpfcFeatures)selectedFeatures, $"{CatiaTreeModel.pointSet}");
}

 

 

Thanks for the help!

Regards

1 reply

Joey1-VisitorAuthor
1-Visitor
February 13, 2020

In general, if anyone has a solution or example on using the CreateLocalGroup function it would be much apprechiated if that could be shared. 

RPN
18-Opal
February 13, 2020

I donβ€˜t know your model structure but the ids must be contiguous.

 

Input Arguments:
solid - The part or assembly.
feat_ids - The Array of feature identifiers to be grouped.
They must be a contiguous set of features.
n_feats - The number of features to be grouped.
local_gp_name - The name to be assigned to the created local group.