i have a MVBA from a client. The person that wrote it is no longer with them. (This program is considered proprietary by the client, so I can't share it)
The issue:
In CU13 the program placed a cell with a text node in it . If only one object was identified the cell was placed and the text was centered in the cell. If two objects were selected the cell was placed with both objects identified two items two lines of text centered in the cell.
In CU14 the program works as it did in CU13 when two objects are selected but not when only one object is selected. The text is not centered as it was in CU13.
What I want to do is to open the code, and then watch as line by line it executes and see where the issue for it not centering the text for one object is.
I am not a programmer and I would contact the originator if I could but he is not available.
Can anyone point me in the right direction?
Version 10.14.00.109
I have tested this in CU 15 and the problem persists there as well.
I have not tested this in CU 16 but would expect it will persist.
I have the book LEARING MICROSTATION VBA First edition published in 2006.
Any suggestions would be greatly appreciated.
I would suggest reading chapter 3 in the Learning MicroStation VBA book that discusses how to use the IDE (including loading and debugging)
This appears to deal with errors. I am not getting an error just an undesired result.
It does not address watching the code execute line by line as I think to find the code that is providing the result is the only way to see what is actually happening.
What I want to do is execute the command, watch it go from one line of code to the next and not proceed until I send it to the next line.
I have tried using several of the commands under the Debug tab but they do not seem to accomplish this.
BTW Chapter 3 section in the edition I have refers to Chapter 9, what version are you using?
Brian MacCartney
Senior Designer, Electrical
Brian MacCartney said:What I want to do is to open the code, and then watch as line by line it executes
That's termed debugging. Because of the similarity between MicroStation VBA and VBA on other platforms, such as Office, you can generally search all websites that deal with VBA for help and tips. For example, here's an Excel website that discusses debugging.
Regards, Jon Summers LA Solutions
Hi Brian,
as Jon wrote, you have to set the breakpoint into VBA code and start macro. When VBA interpreter reaches the breakpoint, it stops and you can go through the code line by line.
Of course, it leads to a question where to place the breakpoint. You have to find, what method (sub in code) is called, when the macro is started. It should be clear from the used key-in, or maybe there is only one public subroutine in the macro. Without knowing the code, it's hard to defined it more exactly.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
okay think I got that to work now just have to find the code that places the cell...seems to be caught in a loop using the F8 key tho...
Brian MacCartney said:seems to be caught in a loop using the F8 key
If you're stuck in a loop that's nothing to do with the F8 key.
Brian MacCartney said:just have to find the code that places the cell
Search the code (Ctrl-F) for one of the cell creation methods, probably CreateCellElement2 or CreateCellElement3. Place a breakpoint on that line and run the code afresh.
CreateCellElement2
CreateCellElement3
The "loop" effect that you see might be the code's waiting for a user input (perhaps datapoint?)
Tuan Le said:The "loop" effect that you see might be the code's waiting for a user input (perhaps datapoint?)
Even though the idea makes sense, such loop should never exist in MicroStation VBA code, because every interaction with mouse (data point, reset...) must be implemented using IPrimitiveCommandEvents and ILocateCommandevents objects.
Regards,
Brian MacCartney said:okay think I got that to work now just have to find the code that places the cell
It's great :-)
You can go through the code "from top to down", because from the code snippet you shared (and probable removed, because I do not see it now), the tool is called from VBA form, so you have to check what code is called by this button "Click" method.
To use opposite direction is also useful, and as Jon wrote, to search for CreateCellElement method helps.
Brian MacCartney said:seems to be caught in a loop using the F8 key tho...
It's weird, because there is no reason why there should be any loop. The only loop can be scanning model content, using ElementScanCriteria. But it is rarely used when element is created (placed).
Hi Brian MacCartney,
You may find some of these topics to be helpful to make more progress quickly:
HTH,Bob