Hi All, I'm trying to tick the "Invert Y and Z" checkbox with VBA in the "FBX Export Settings" dialog box.
When I close the dialog box manually, the setting is remembered next time the dialog box opens. But if I close the dialog using VBA then the setting is forgotten. does anyone know how can I get microstation to remember this setting?
I'm using the keyin "dialog fbx" to open the dialog box, and the modalhandler to check the option and then close the dialog box.
If DialogBoxName = "FBX Export Settings" Then ' Set a variable associated with a dialog box ' 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. lngTemp = Not 1 lngTemp = GetCExpressionValue("fbxExportSettings.m_flags.m_invertYZ", "FBXEXPORT") And lngTemp SetCExpressionValue "fbxExportSettings.m_flags.m_invertYZ", lngTemp Or 1, "FBXEXPORT" ' Remove the following line to let the user close the dialog box. DialogResult = msdDialogBoxResultOK End If ' FBX Export Settings
Michael Reilly said: if I close the dialog using VBA then the setting is forgotten lngTemp = Not 1 lngTemp = GetCExpressionValue("fbxExportSettings.m_flags.m_invertYZ", "FBXEXPORT") _ And lngTemp
lngTemp = Not 1 lngTemp = GetCExpressionValue("fbxExportSettings.m_flags.m_invertYZ", "FBXEXPORT") _ And lngTemp
Step through your code with the VBA debugger or add some statements to reveal the value of lngTemp...
lngTemp
lngTemp = Not 1 Debug.Print "lngTemp Initial value=" & CStr(lngTemp) lngTemp = GetCExpressionValue("fbxExportSettings.m_flags.m_invertYZ", "FBXEXPORT") _ And lngTemp Debug.Print "lngTem from fbxExportSettings.m_flags.m_invertYZ=" & CStr(lngTemp) Debug.Print "lngTemp Or 1=" & CStr(lngTemp Or 1)
Regards, Jon Summers LA Solutions
Thanks Jon, the initial value is always negative unless I manually close the dialog box (then it's positive aka checked). So I'm still stuck on how to get the dialog box to remember the setting?
Michael Reilly said: the initial value is always negative
Does the value change? Show us the results from the Immediate window.
Sorry for the image, something keeps rejecting when I paste as code or text
The Debug statements show that the value (checkv) changed from 0 to 1. That tells us that your code is doing what you expect, but something else fails to persist the value. Can you see that value in the FBX export dialog?
checkv
Hi John, I want CAD to default to have the YZ invert on when exporting FBX files. Is that possible with configs, or if I use the keyin "export fbx"?
Michael Reilly said:I want CAD to default to have the YZ invert on when exporting FBX files. Is that possible with configs, or if I use the keyin "export fbx"?
Post that question to the MicroStation Forum.
I cant work out why DialogResult = msdDialogBoxResultOK behaves differently to manually closing the dialog box either.
Hi Jon, after a bit more digging, it seems that if I add any code after the SetCExpressionValue line then the box isn't ticked. Even if I just sleep the macro for a second. The only way I can get the box to be ticked is by having no code after the SetCExpressionValue line. Any suggestions? thanks for your help so far
Michael Reilly said:The only way I can get the box to be ticked is by having no code after the SetCExpressionValue line
Wacky! I'm impressed that you discovered the problem.
Michael Reilly said:Any suggestions?
We have to tolerate the idiosyncrasies of VBA. It is, after all, a relic of the last century. Bentley Systems take the Microsoft VBA library and add bits for MicroStation. The core, which includes modal dialog handling, is as Microsoft designed it. Microsoft has declared VBA obsolete several times, but it lingers in Microsoft Office, so it's unlikely to vanish in the near future.
That said, Microsoft would prefer us all to move to .NET, which is a first-class API in MicroStation CONNECT.