Detecting "Replace Model Reference" (in drawings) through an event in VBA?

Detecting "Replace Model Reference" (in drawings) through an event in VBA?

bshbsh
Collaborator Collaborator
662 Views
4 Replies
Message 1 of 5

Detecting "Replace Model Reference" (in drawings) through an event in VBA?

bshbsh
Collaborator
Collaborator

Hi,

does anyone know what events fire that I could catch from a VBA macro to detect a model reference replacement? (Using the command on the ribbon)

Couldn't find an obvious one. OnInitializeDocument doesn't tell what triggered this event.

Thanks.

0 Likes
663 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor
 Private Sub UI_OnActivateCommand(CommandName As String, Context As Inventor.NameValueMap) Handles oUI.OnActivateCommand
            'MsgBox(CommandName)
            If CommandName = "Name Name" Then

but that isn't easy in VBA.

with vb.net it is easy to implement. 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 5

philip1009
Advisor
Advisor

I think this can be achieved in iLogic with a couple of rules.  One rule to activate whenever a drawing is open take the model part number or something specific to the model file and save it in a Shared Variable, which is basically making a variable or object visible to other rules in Inventor.  Then another rule to activate on either iProperty Change or Drawing View Change to check the part number of the replaced view against the part number in the Shared Variable.  If the comparisons are different then continue with the rule.

 

If this sounds like what you're looking for, let me know and I'll see if I can come up with a sample of this code.

0 Likes
Message 4 of 5

bshbsh
Collaborator
Collaborator

My macro already does handle and depend on events, so this is just another, not difficult at all. 

The problem with this is, it does fire before that command is started, there's no before or after trigger, nor any feedback if the command actually ran or has been cancelled. (I could work around this however.)

0 Likes
Message 5 of 5

bradeneuropeArthur
Mentor
Mentor

You can create your before and after event. I will let you know how as soon as I am back in office, ok?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes