How to execute ControlDefinition with pre-defined settings?

How to execute ControlDefinition with pre-defined settings?

Anonymous
Not applicable
687 Views
2 Replies
Message 1 of 3

How to execute ControlDefinition with pre-defined settings?

Anonymous
Not applicable

Hi, i am making Add-In in C# with Visual Studio.

I need to execute "PartPromoteCmd" command, but with different settings.

When i click button which executes this command in Inventor, it opens small window with settings.

I need to skip this window, set given settings and execute it without any user interaction at all.

How can i achieve this?

 

 

 

 

DocumentTypeEnum docType = app.ActiveDocumentType;
CommandManager oCom = app.CommandManager;
ControlDefinitions oConDefs = oCom.ControlDefinitions;

if (docType == DocumentTypeEnum.kAssemblyDocumentObject) {
  AssemblyDocument doc = (AssemblyDocument) app.ActiveDocument;
  AssemblyComponentDefinition oDoc = doc.ComponentDefinition;
  ComponentOccurrences occurrences = oDoc.Occurrences;

  var selected = app.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Component");

  if (selected is ComponentOccurrence) {
    ComponentOccurrence _selected = (ComponentOccurrence) selected;

    // Editing Mode
    _selected.Edit();

    foreach(ControlDefinition cd in oConDefs) {
      if (cd.InternalName == "PartPromoteCmd") {
          // here i need to set things ... but how
          
          cd.Execute();
      }
    }
  }
  else {
    MessageBox.Show("You need to select some Component!");
  }
}

 

 

 

 

0 Likes
Accepted solutions (1)
688 Views
2 Replies
Replies (2)
Message 2 of 3

CattabianiI
Collaborator
Collaborator

That window it's not just about settings, it allows you to select the input geometry to copy.

In general working directly with commands it's not always the best approach to achieve something via api, check this forum if you find something useful about object copy via api which is what PartPromoteCmd does.



0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution
0 Likes