Hi fagmj,
I'm trying to solve this too. How did you select the component to run the command on? The following code doesn't work.
public void SetCompOccHiddenLines(int _viewIndex, string _occName, bool _include)
{
// Set a reference to the view's referenced model.
Document _doc = View(_viewIndex).ReferencedDocumentDescriptor.ReferencedDocument;
// Validate the document type.
if (!ValidateDocType(DocumentTypeEnum.kAssemblyDocumentObject, _doc)) return;
// Set a reference to the component definition.
AssemblyDocument _asmDoc = (AssemblyDocument)_doc;
AssemblyComponentDefinition _asmCompDef = _asmDoc.ComponentDefinition;
// Get all leaf occurrences from the assembly model.
ComponentOccurrencesEnumerator _occEnum = _asmCompDef.Occurrences.AllLeafOccurrences;
foreach (ComponentOccurrence _occ in _occEnum)
{
// Validate this occurrence matches the supplied _occName.
if (!_occ.Name.ToUpper().Contains(_occName.ToUpper())) continue;
// Validate the component is both visibile and active.
if (_occ.Suppressed || !_occ.Visible) continue;
PartComponentDefinition _definition = _occ.Definition as PartComponentDefinition;
if (_definition == null) continue;
ControlDefinition _def =
Application.CommandManager.ControlDefinitions["DrawingBodyHiddenLinesCtxCmd"];
_def.Execute();
}
}