Document functions in iLogic

Use Document functions to access the Inventor part, assembly, or drawing document. Document functions allow you to perform tasks such as getting the filename and updating the model.

In Document functions, ThisDoc refers to the Autodesk Inventor document in which the rule is written. It is often the active document, but it can also be a part within an assembly. Wherever the rule is stored, ThisDoc gives you access to that document.

To access the Document functions, expand the Document node under the System tab in the Snippets area.

Path

Returns the document path (folder name) as a text string.

Syntax

ThisDoc.Path

FileName

Returns the filename of the document.

Syntax

ThisDoc.FileName(False)

The file extension is not included when False is provided as an argument. If you want the file extension, substitute True as the argument.

PathAndFileName

Returns the path and the file name of the document.

Syntax

ThisDoc.PathAndFileName(False)

The file extension is not included when False is provided as an argument. To include the file extension, substitute True in the parentheses.

ChangeExtension

Creates a filename using the filename of the document and a changed extension.

Syntax

changedName = ThisDoc.ChangeExtension(“.new”)

WorkspacePath

Returns the path (folder name) of the active Autodesk Inventor project workspace. If no workspace is defined, this function returns an empty string (a string with no characters, with length = zero).

Syntax

ThisDoc.WorkspacePath()

Launch

Launches a file based on the path and filename (including extension) provided. If a data file is specified, it opens in its native application. If an executable file (.exe) is specified, it runs the program. If you do not specify a complete path, iLogic looks for the file in the same folder as the Inventor document. You can also specify a relative name and path to the document folder.

Syntax

ThisDoc.Launch(“path\file.ext”)

Save

Saves the currently active document. This function does not work in a rule triggered by a parameter change event.

Syntax

ThisDoc.Save

UpdateWhenDone

Updates the document that the rule is in, after the rule (and any rule it triggers) finishes running. This update is the same as clicking the Update button in the user interface.

Syntax

iLogicVb.UpdateWhenDone = True

RuleParametersOutput

If your rule has changed any parameter values, this function applies new rule values to the Inventor model. If this function is not used, the values are not applied until the rule has finished running. Use this function if you must perform an Update using DocumentUpdate. Also use this function if you are using the iLogicVb.RunRule function, so that the other rule gets the new values of the parameters.

Syntax

RuleParametersOutput()

DocumentUpdate

Performs an immediate update in the current document (the document that the rule is in) and updates the display. Use this function if you require that the geometry be rebuilt (for example, you are calculating mass using iProperties.Mass). If the rule fires other rules (by changing parameters), enable the Fire dependent rules immediately option for the rule in the Edit Rule dialog box. This option ensures that the other rules have finished running when you perform the update.

Syntax

InventorVb.DocumentUpdate()

DocumentUpdate(False)

Performs an immediate update in the current document (the document that the rule is in) without updating the document display. The function InventorVb.DocumentUpdate updates the display as well as the model. If you do not want the display to update, use this function instead.

Syntax

InventorVb.DocumentUpdate(False)

Display Only Update

This Inventor API function updates only the display, and not the model.

Syntax

ThisApplication.ActiveView.Update()

CheckParameters

Verifies parameter values but does not change any values.

Use this function for situations such as the following:

Suppose your parameters are linked to a base part, and in the base part they are linked to an external spreadsheet. It is possible to change parameter values in the spreadsheet and save it without those changes showing up in the main part. Use this function in a rule within the main part before using GoExcel to change values in the spreadsheet. This function ensures that the base part is loaded (in the background) and that changes propagate through to the main part of the assembly.

Syntax

InventorVb.CheckParameters(“”)

File Save As

Saves the document under a new filename and, optionally, a new extension.

Syntax

ThisDoc.Document.SaveAs(NewFileNameAndExtension , True)

True

Set to True to perform a Save Copy As operation, or set to False to perform a Save As operation.