If I Save As manually, and invoke the Options to set a fence filter, things progress as expected. I end up with a new DGN file whose default model contains elements copied from the contents of the fence in the original file.
When I record that same process using the VBA macro recorder, then replay the recording, the fence is not processed. The playback creates a new file of the correct name but its contents are the entire contents of the original. In other words, it ignores (or rather, fails to record) the fence filter setting.
Has anyone experienced this problem? Has anyone solved this problem?
I've noticed one error in the recording. The recording creates a procedure (Macro1 or similar) and declares variable lngTemp As Long in that procedure. But lngTemp is not used there. The recording creates a class that Implements IModalDialogEvents. The _OnDialogOpened event of that class uses, but fails to declare, variable lngTemp. What else may have been missed?
Here's the code from the class that deals with the filter settings. I don't see where it records that I want a fence filter...
If DialogBoxName = "Save As V8 Options" Then ' Set a variable associated with a dialog box SetCExpressionValue "gFilterGlobals.subset", 1, "SAVEASFILTER" ' This only modifies a few bits of the variable it changes. It first ' creates a mask for clearing the bits it will change. Then it gets ' the variable and uses the mask to clear those bits. Finally ' it sets the desired bits in the value and saves the updated value. Dim lngTemp As Long ' Declaration inserted manually lngTemp = Not 1 lngTemp = GetCExpressionValue("gFilterOptions->flags.filterACS", "SAVEASFILTER") And lngTemp SetCExpressionValue "gFilterOptions->flags.filterACS", lngTemp Or 1, "SAVEASFILTER" lngTemp = Not 1 lngTemp = GetCExpressionValue("gFilterOptions->flags.filterNamedViews", "SAVEASFILTER") And lngTemp SetCExpressionValue "gFilterOptions->flags.filterNamedViews", lngTemp Or 1, "SAVEASFILTER" lngTemp = Not 1 lngTemp = GetCExpressionValue("gFilterOptions->flags.filterSharedCellInstances", "SAVEASFILTER") And lngTemp SetCExpressionValue "gFilterOptions->flags.filterSharedCellInstances", lngTemp Or 1, "SAVEASFILTER" lngTemp = Not 1 lngTemp = GetCExpressionValue("gFilterOptions->flags.filterUnusedSharedCellDefs", "SAVEASFILTER") And lngTemp SetCExpressionValue "gFilterOptions->flags.filterUnusedSharedCellDefs", lngTemp Or 1, "SAVEASFILTER" lngTemp = Not 1 lngTemp = GetCExpressionValue("gFilterOptions->flags.filterTags", "SAVEASFILTER") And lngTemp SetCExpressionValue "gFilterOptions->flags.filterTags", lngTemp Or 1, "SAVEASFILTER" lngTemp = Not 1 lngTemp = GetCExpressionValue("gFilterOptions->flags.filterFrozenLevels", "SAVEASFILTER") And lngTemp SetCExpressionValue "gFilterOptions->flags.filterFrozenLevels", lngTemp Or 1, "SAVEASFILTER" lngTemp = Not 1 lngTemp = GetCExpressionValue("gFilterOptions->flags.filterNamedGroups", "SAVEASFILTER") And lngTemp SetCExpressionValue "gFilterOptions->flags.filterNamedGroups", lngTemp Or 1, "SAVEASFILTER" CadInputQueue.SendCommand "LOCK FENCE INSIDE" ' Remove the following line to let the user close the dialog box. DialogResult = msdDialogBoxResultOK End If ' Save As V8 Options
Unknown said:g_remapOptions.destDwg
Thanks, but I'm not sure that twiddling DWG flags will help. I want to save to a DGN file.
I concluded that VBA can't solve my problem. It has no built-in methods to perform a fence save and relies on key-in recordings that are incomplete. Fortunately, I'm in a position to write MDL, and a small MDL app. does exactly what I want.
Regards, Jon Summers LA Solutions
My original question included this: "it ignores (or rather, fails to record) the fence filter setting". There's more besides, but I kept the question simple. I don't want to remap levels or filter levels.
My goal was to perform a file fence including the tags attached to elements within that fence. My options were:
It was easier to write an MDL app. than to figure out how it might be possible to do the above with VBA.
Unknown said:I am glad that you found a MDL solution
Thanks for your kind support. However, the solution wasn't just lying around, waiting to be discovered, so I didn't just "find" it.I had to specify, write, build and debug the MDL code. The specification includes the requirement to be usable from a VBA application.
An MDL app. can provide a command table, unavailable in VBA (a .NET AddIn can also provide a command table). That makes the MDL app. easy to use from VBA because you can simply use CadInputQueue.SendKeyin "MY APP COMMAND" as if it were a built-in MicroStation command.
You might like to add to your Communities personal biography and tell us a little more about yourself and how you use VBA.