Ilogic rule for Zoom all before Save

Ilogic rule for Zoom all before Save

Anonymous
Not applicable
3,997 Views
10 Replies
Message 1 of 11

Ilogic rule for Zoom all before Save

Anonymous
Not applicable

Hi,

is there any solution for automatic Zoom all drawing before save it?

I need this because thumbnails in explorer.

 

I found this code for rule:
ThisApplication.ActiveView.Fit

 

It works fine, but there is problem with Event Trigger - I use Before save document, but doesn't work. It zooms all, but i think after saving, because thumbnail is not zoomed.

 

Thanks for help!

0 Likes
3,998 Views
10 Replies
Replies (10)
Message 2 of 11

GosponZ
Collaborator
Collaborator

Try this:

ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute

0 Likes
Message 3 of 11

Anonymous
Not applicable

Thanks for advice, but it doesn't work. I need this for drawing not for part.

0 Likes
Message 4 of 11

GosponZ
Collaborator
Collaborator

'ZOOM IN
ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute
iLogicVb.UpdateWhenDone=True

Message 5 of 11

Anonymous
Not applicable

It works same as my first solution (it zooms, but after saving document, so thumbnail is not zoom all picture). Cat Sad

Message 6 of 11

Anonymous
Not applicable

Instead of using

iLogicVb.UpdateWhenDone=True

Try

Call InventorVb.DocumentUpdate

to force the document to update immediately rather than at the end of the rule.

0 Likes
Message 7 of 11

tonis_kivisild
Contributor
Contributor

This thread hasn't continued but I can't find a solution to the same problem (Inventor 2024). The thumbnail doesn't update corectly. The .Fit() or .Item("AppZoomallCmd").Execute always happen after the save even though they should run Before Save Document. The thumbnail is not centered and when I open the file, it is zoome to the place it was before the fit occurred.
I have a rule that is run by another rule with a trigger Before Save Document.

Also funnilty enough, if I have a message box pop up in the end of the rule, the Fit or Zoom doesn't happen at all.

 

ThisDoc.Document.SetThumbnailSaveOption(ThumbnailSaveOptionEnum.kActiveWindowOnSave)

'Neither don't work
'ThisApplication.ActiveView.Fit()
ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomallCmd").Execute

InventorVb.DocumentUpdate()

MessageBox.Show("If this message box is here, the Fit/Zoom isn't working at all")

 

0 Likes
Message 8 of 11

J-Camper
Advisor
Advisor

Is this giving you the result you want?

Dim oCam As Camera = ThisApplication.ActiveView.Camera

oCam.Fit()
oCam.ApplyWithoutTransition()

 

It still wants to be set to before save event trigger.

Message 9 of 11

tonis_kivisild
Contributor
Contributor
Yes, thank you!
Now it changes the correct thumbnail and next time opens to the correct "zoomall" view.
0 Likes
Message 10 of 11

_dscholtes_
Advocate
Advocate

@J-Camper

What would happen when the rule is triggered, but the document where the rule is run in, is not the active document (therefore not in the active view / not having an active view)? Think of saving an assembly and including all the modified parts.

0 Likes
Message 11 of 11

J-Camper
Advisor
Advisor

@_dscholtes_,

I believe using the "ThisDoc" iCadDoc will reference the document which is calling the rule, but if that document is not open there there probably is not an active view.  It would either do nothing or throw an error.

I think you would need to open/activate the document you wish for this to run on.  Something like this would probably do it [untested]:

If Not ThisDoc Is ThisApplication.ActiveDocument 'is the calling document the active document?
	If ThisDoc.Document.Open 'is the calling document open?
		ThisDoc.Document.Activate()
		
		'run the rule
		
	Else
		ThisApplication.Documents.Open(ThisDoc.PathAndFileName(True), True) 'Bool1 = include the extension | Bool2 = open visibly [i'm not sure if this would be necessary for the camera to be an object]
		
		'run the rule
		
		ThisDoc.Document.Close(False) 'Don't skip save
	End If
Else
	
	'run the rule as normal
	
End If 
0 Likes