HowTo : How to use FilterSelect in HTML VBScript
Article | 60000965 |
Type | HowTo |
Product | Engine |
Version | 6 |
Date Added | 9/25/2009 |
Submitted by | Ludo Blokken |
Keywords | |
Subject
How to use FilterSelect in HTML VBScript
Summary
I cannot use the FilterSelect or other methods that need a VDF object as parameter in HTML VBScript.
Solution
This problem is a "generic" issue and not a specific problem of FilterSelect and applies to ALL methods that need a VDF object (like a vdLine, vdLayer, vdBlock etc).
In VBScript all variables are Objects/Variants so when a function need a specific VDF object (like the FilterSelect which needs a vdFilterObject object) it wont work and will get errors like this. For example the code :
Set myFilter = VDraw.ActiveDocument.Selections.CreateFilter(myTypes, myLayers)
Set gripselset = VDraw.ActiveDocument.Selections.FilterSelect("GRIPSELSET", myFilter)
will raise an error. While the code :
Set gripselset = VDraw.ActiveDocument.Selections.FilterSelect("GRIPSELSET", VDraw.ActiveDocument.Selections.CreateFilter(myTypes, myLayers))
will work fine (as we pass to the FilterSelect the output of the CreateFilter which is an object)
In order to bypas this will have to use the WrapperObject which its type by default is Object (and not a vd...something..object.. object like vdFilterObject object).
So the code above should be changed to :
Set myFilter = VDraw.ActiveDocument.Selections.CreateFilter(myTypes, myLayers) ' create the filter
Set gripselset = VDraw.ActiveDocument.Selections.add( "GRIPSELSET") ' add the GRIPSELSET selection in document's selection
gripselset.WrapperObject.FilterSelect myFilter.WrapperObject ' call the FilterSelect of the WrapperObject passing the myFilter.WrapperObject which is an OBJECT type.
Note: The same problem you will face if you try to add a VDF object to a collection using AddItem, like for example :
Dim circ1
Set circ1 = VDraw.ActiveDocument.entities.AddCircle(Array(0, 0, 0), 5)
gripselset.AddItem(circ1)
Instead you should use a code like :
Dim circ1
Set circ1 = VDraw.ActiveDocument.entities.AddCircle(Array(0, 0, 0), 5)
gripselset.WrapperObject.AddItem circ1.WrapperObject