Automatic Save & replace?

Automatic Save & replace?

e2000773
Enthusiast Enthusiast
859 Views
2 Replies
Message 1 of 3

Automatic Save & replace?

e2000773
Enthusiast
Enthusiast

So I found this code floating in this forum:

 ' Get the CommandManager object.

Dim oCommandMgr As CommandManager oCommandMgr = ThisApplication.CommandManager

' Get control definition for the line command.

Dim oControlDef As ControlDefinition oControlDef = oCommandMgr.ControlDefinitions.Item( _ "AssemblyBonusTools_SaveAndReplaceComponentCmd")

' Execute the command.

oControlDef.Execute

This code essentially is the Save & Replace feature in Inventor and makes you manually choose the placed part. I was wondering if it's possible to make it automatic everytime I place a part in assembly without me selecting the placed part from the assembly tree? If that is not possible then the next best thing would be to include the file name in the code and it would be custom to every part I have. Like the part name is for an example: part-1123.ipt and in the code it is determined to find part in assembly with that name -> save and replace.  Any ideas? The important thing is to preserve the ability to rename it and have a custom save directory.

So when I place a part in assembly my form pops up and there is the rule integrated to the form as a button. Pressing that does the save and replace.

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

A.Acheson
Mentor
Mentor
Accepted solution

Hi @e2000773 

To work with the save and replace command through command manager you will need to use post private event and the filename event type enumerator see API help here.

Syntax

CommandManager.PostPrivateEventDataType As PrivateEventTypeEnumData As Variant )

 

This will pass a fullfilepath to the dilaogue much the same as if you pasted the path there manually. It will suppress the dialog so you either make a dialog to browse for a location or supply a constant path. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3

e2000773
Enthusiast
Enthusiast
Accepted solution
0 Likes