You are here: About application links > Understanding the AutoCAD links > Synchronizing multiple blocks per drawing > Synchronizing using custom VBScript functions

Synchronizing using custom VBScript functions

Synchronizing using custom VBScript functions is the most useful when you want to automate much of how the multiple title block attribute values are set. This method of synchronization uses two custom VBScript functions. The implementation of these functions is entirely up to you. The functions can have any valid names. The link simply calls the functions at the appropriate moment during standard title block synchronization. The functions should contain all of the logic necessary to read and write the appropriate attribute values in the drawings, such as with Visual Basic for Applications.

Both of the functions will be called by the AutoCAD link with one parameter. The parameter is an array of arrays that each contain strings in the following order:

  1. Attribute name
  2. Title block name
  3. Layout name or tab number
  4. Attribute value

Recommended logic for both functions to iterate through the parameter array is shown in the following example.

Function UpdateFromDoc(PropList)
   On Error Resume Next
   
   If IsArray(PropList) Then
      iSize = UBound(PropList)
      For i = 0 To iSize
         CurProp = PropList(i)
         If IsArray(CurProp) Then
            If UBound(CurProp) = 3 Then
               'Read the corresponding attribute value or write
               'the corresponding vault property here.
            End If
         End If
      Next
   End If

   UpdateFromDoc = True
End Function

The title block reading function may return any value, the value is not checked by the link.

If the return value of the title block writing function is True, the link will check all new values provided by the function and will set the corresponding attributes. To set an empty value, use an empty string (""). When the function is called, all parameter elements are Empty.

To synchronize multiple title blocks per drawing using custom VBScript functions:

  1. Implement the title block reading and title block writing functions in the vault's VBScript block. For more information on the Meridian Enterprise VBScript API and modifying a vault's event script block, see the BlueCielo Meridian Enterprise VBScript API Reference.
  2. Modify the AutoCAD link settings as described in Configuring standard title block synchronization.
    1. In the [Settings] section, specify the name of the title block reading function in the UpdatePropertiesFromDocument setting.
    2. In the [Settings] section, specify the name of the title block writing function in the UpdatePropertiesToDocument setting.
    3. NEW If the drawings to be synchronized do not use standard layout names and it is more convenient to refer to the layout tabs by their ordinal number in your custom functions, set the UseTabOrderForScript setting to 1. The Layout parameter ( CurProp(2) of PropList(i) in the preceding example) of the VBScript functions will then contain the tab number instead of the tab name. Setting this setting to 0 will disable this feature.
    4. In the section for each block, specify the keyword UseScriptFunction for each attribute that should use the script functions. Specify read/write flags the same as if a property name was specified, if necessary.

Following is an example of the preceding settings.

[Settings]
UseTabOrderForScript=1
UpdatePropertiesToDocument=UpdateToDoc
UpdatePropertiesFromDocument=UpdateFromDoc
[BLOCK_1]
PROJECT_NM=Custom.Projectname
FIELD1=UseScriptFunction
FIELD2=UseScriptFunction,WO
FIELD3=UseScriptFunction,RO

In this example, layout tabs are referred to by their number in the custom script functions instead of by their names. The script function UpdateToDoc will be called to update the attributes FIELD1 and FIELD2 for all instances of the block BLOCK_1. Those two attributes are controlled by the default and the WO flag. The script function UpdateFromDoc will be called to update the properties that correspond to attributes FIELD1 and FIELD3 for all instances of the block BLOCK_1. Those two attributes are controlled by the default and the RO flag.


www.bluecieloecm.com