I'm trying to access the custom properties of a sheetmetal cutlist feature like this:
"Zuschnittslistenelement1" is the german name for "Cut-List-Item1"
IModelDoc2 partModel = _solidWorks.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocPART,
(int)swOpenDocOptions_e.swOpenDocOptions_LoadModel,
string.Empty, ref loadError, ref loadWarnings);
_solidWorks.ActivateDoc2(fileName, false, loadError);
object featuresObject = partModel.FeatureManager.GetFeatures(true);
object[] features = featuresObject as object[];
Feature cutList = null;
foreach (object featureObject in features)
{
Feature feature1 = featureObject as Feature;
if (feature1.Name == "Zuschnittslistenelement1")
{
cutList = feature1;
}
}
if (cutList != null)
{
CustomPropertyManager propertyManager = cutList.CustomPropertyManager;
string resolvedRahmenLaenge;
string rahmenLaenge;
propertyManager.Get4("Rahmenlänge", false, out rahmenLaenge, out resolvedRahmenLaenge);
string resolvedRahmenBreite;
string rahmenBreite;
propertyManager.Get4("Rahmenbreite", false, out rahmenBreite, out resolvedRahmenBreite);
}
propertyManager.Count is 0.
It would be helpful if you posted the model you are testing this on. Anyway, the code below worked fine for me and you can test it out by pasting it into a VSTA C# macro called "Macro1". I would recommend you look for the cut list folder using IFeature.GetTypeName so that you're not relying on a string value that could possibly change.
Keith
SolidWorks API Training and Services