I have been able to retrieve the custom properties from the Summary Information dialog for the current drawing (See code snippet below).
I am having trouble accessing the same properties for a part defined in a named view existing in a sheet of the drawing. What I have noticed is that the Summary Information dialog appears to be context-sensitive.
If the drawing is active, the drawing custom property values are available from the File->Properties menu. If one of the parts is active then the part's custom properties are available via the File->Properties menu. The automation tool I am building needs to be able to fetch the part custom properties from the context of an active drawing.
How do I get the custom properties for a part when the drawing is the active document?
Code: Select all
Dictionary<string, string> customProperties = new Dictionary<string, string>
{
{ "Description", "" },
{ "Description2", "" },
{ "Drawn By", "" },
{ "Date", "" }
};
ModelDoc2 swModel = default(ModelDoc2);
IModelDocExtension swModelDocExt = default(IModelDocExtension);
CustomPropertyManager swCustProp = default(CustomPropertyManager);
string val = "";
string valout = "";
swModel = (ModelDoc2)App.ActiveDoc;
swModelDocExt = swModel.Extension;
swCustProp = swModelDocExt.get_CustomPropertyManager("");
foreach (KeyValuePair<string, string> entry in customProperties.ToList())
{
if (swCustProp.Get4(entry.Key, false, out val, out valout))
{
customProperties[entry.Key] = val;
}
}
return customProperties;