Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ilogic rule for Zoom all before Save

10 REPLIES 10
Reply
Message 1 of 11
nicomajstr
3295 Views, 10 Replies

Ilogic rule for Zoom all before Save

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!

10 REPLIES 10
Message 2 of 11
GosponZ
in reply to: nicomajstr

Try this:

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

Message 3 of 11
nicomajstr
in reply to: GosponZ

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

Message 4 of 11
GosponZ
in reply to: nicomajstr

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

Message 5 of 11
nicomajstr
in reply to: GosponZ

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
jvaughn8XF7X
in reply to: nicomajstr

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.

Message 7 of 11
tonis_kivisild
in reply to: nicomajstr

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")

 

Message 8 of 11
J-Camper
in reply to: tonis_kivisild

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
in reply to: J-Camper

Yes, thank you!
Now it changes the correct thumbnail and next time opens to the correct "zoomall" view.
Message 10 of 11
_dscholtes_
in reply to: J-Camper

@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.

Message 11 of 11
J-Camper
in reply to: _dscholtes_

@_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 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report