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!");
}
}
Solved! Go to Solution.
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!");
}
}
Solved! Go to Solution.
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.
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.
Can't find what you're looking for? Ask the community or share your knowledge.