Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to execute ControlDefinition with pre-defined settings?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Anonymous
582 Views, 2 Replies

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

How to execute ControlDefinition with pre-defined settings?

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!");
  }
}

 

 

 

 

Labels (5)
2 REPLIES 2
Message 2 of 3
CattabianiI
in reply to: Anonymous

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

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.



Message 3 of 3
Anonymous
in reply to: CattabianiI

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report