Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to execute ControlDefinition with pre-defined settings?

Anonymous

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
Reply
Accepted solutions (1)
630 Views
2 Replies
Replies (2)

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

Anonymous
Not applicable
Accepted solution
0 Likes