Understanding the CorelDRAW object model : Working with import filters and export filters : Working with import filters |
To ensure the portability of a file-import script, you must use the default ImportFilter object (rather than the filter-specific object DSFImport), as in the following VBA example:
Sub OpenRectangle() |
Dim FilterObject As ImportFilter |
'Initialize FilterObject |
Set FilterObject = ActiveLayer.ImportEx("C:\devo\rect.dsf", _ |
cdrDSF) |
'Set the advanced features of the filter |
FilterObject.DefaultLinestyle = 1 'Dashed |
FilterObject.DeleteInvisibleObjects = True |
'Invoke the filter |
FilterObject.Finish |
End Sub |
For best results, use the filter-specific object DSFImport only to learn the specific interfaces that are supported by a filter. For example, the following screenshot demonstrates that the ImportFilter object exposes only generic interfaces in Microsoft® IntelliSense® because the ImportFilter interface is generic (and not filter-specific). The ImportFilter object does not contain the DefaultLinestyle and DeleteInvisibleObjects properties; however, you can still set these properties in the ImportFilter interface if they are supported by the specified import filter.
As previously discussed, using the ImportFilter object (rather than the filter-specific object DSFImport) ensures that a file-import script can be used on any other workstation running the same version of the application. To reference the properties, methods, and enumerations for a specific filter, locate that filter in the Object Browser. For example, the following screenshot demonstrates that the line-style dsfDashed2 can be specified by assigning a value of 7 to the DefaultLinestyle property.
To access the object model for a filter, click Tools } References from within the Macro Editor. In the References dialog box that appears, click Browse, and navigate to the Filters folder of the installed software. Select the dynamic-link library (DLL) file for the desired filter, and then click OK. When the References dialog box reappears, enable the checkbox that corresponds to the desired filter, and then click OK. You can now access the object model for the filter, as in the following VBA example:
Sub OpenRectangleDSF() |
Dim FilterObject As DSFImport |
Dim Style As DsfLinestyle |
'Initialize FilterObject |
Set FilterObject = ActiveLayer.ImportEx("C:\devo\rect.dsf", _ |
cdrDSF) |
'Set the advanced features of the filter |
Style = dsfDashed |
FilterObject.DefaultLinestyle = Style |
FilterObject.DeleteInvisibleObjects = True |
'Invoke the filter |
FilterObject.Finish |
End Sub |
Working with an import filter is made much easier by having the script access the object model for that filter; however, as discussed, this technique reduces the portability of the script. When used at another workstation, the script must first be updated with the correct location of the DLL file for the filter.
Copyright 2013 Corel Corporation. All rights reserved.