Rule works when "run rule" but throws error when triggered "After open document"

Rule works when "run rule" but throws error when triggered "After open document"

Eide.N
Advocate Advocate
332 Views
5 Replies
Message 1 of 6

Rule works when "run rule" but throws error when triggered "After open document"

Eide.N
Advocate
Advocate

Hi All,

 

This simple rule does what I want when I right-click and "run rule" but I get errors when I set it to a triggered run "After Open Document" on drawings. 

 

EideN_1-1697488057650.png

 

I want it to activate sheet 1 and zoom to fit. Any ideas?

 

'open sheet 1
ThisApplication.ActiveDocument.Sheets.Item(1).Activate

'zoom to fit
ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute
0 Likes
333 Views
5 Replies
Replies (5)
Message 2 of 6

Eide.N
Advocate
Advocate

I discovered that this only fails when I right-click from the browser and "Open Drawing from Vault". 

0 Likes
Message 3 of 6

bradeneuropeArthur
Mentor
Mentor
Use .execute2 instead

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

Message 4 of 6

Eide.N
Advocate
Advocate

This is such a weird thing. Still not working when right-clicking on the browser and Open Drawing from Vault. But, when I run it after opening it works just fine.

 

Oh well. No more time to spend on this at the moment.

0 Likes
Message 5 of 6

WCrihfield
Mentor
Mentor

Try switching from the 'ThisApplication.ActiveDocument' reference, to the 'ThisDoc.Document' reference.  If some other type of document is currently visible on the screen when that document gets opened invisibly in the background, it will cause an error.  The ThisDoc.Document term will refer to the document that the event was triggered from, not necessarily the document that is currently showing on your screen.  But that drawing document may need to be 'activated' (could use the DrawingDocument.Activate method) before you can activate one of its sheets.

 

Edit:  Also, that process of right-clicking on the top node of a model document's browser tree, then choosing 'Open Drawing' (I do not have Vault), does not always work anyways.  That process only works for me when the drawing is saved in the same location as the model file, and has the same file name (with different file extension) as the model file.  If the drawing either simply does not exist, or is located somewhere else, and / or is named different than the model, that process will fail for me.  Not sure if it would be the same when you have Vault or not though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 6

Eide.N
Advocate
Advocate

Thanks for the suggestions, although none of them appeared to change the behavior. It works when I open a file directly from the vault, from Inventor, and "Open Drawing" from RtCl on the browser tree.

 

It still doesn't work when RtCl "Open Drawing from Vault" on the browser tree. But it's such a small thing that I will stop worrying about it!

0 Likes