Fellow Microstation VBA users,
I neeed some basic code to add/modify Xdata for an element, in a cell, in a design file, opened with OpenDesignFileForProgram. I'm uncertain how to do this. My guess would be to utilize the Appplication.ObjectConnector or the mdlModelRef_loadReferenceModels?
Thanks in advance,
Okay so back to the question at hand.
I have two files named File1.dgn and File2.dgn. Both files have a cell named "ABC" which contains a line and a circle. I want a macro that will assign the following xdata to the line:
.SetXData "Reference1", "L1"
.SetXData "Reference1", "C1"
to the circle. I want to be able to run this code via a "batch process".
Here is a quick attempt at solving this issue.
This application will add xdata on to a line and an ellipse that
are in a cell named simplecell. The
process can then be driven from the MicroStation batch processor. The zip file contains:
Adddata.bprc – the batch process control file,
this file can be built from the MicroStation user interface
Addxdata.txt – the commands to run, this file
will load and run the VBA module
Newsgroupdemo.mvba – the vba macro that will
loop through all models in a file and look for a cell and add xdata to lines
and ellipses. For demo only…
Celllibrary.dgn – a cell library with one cell
that has an ellipse and line
File1, file2.dgn – two sample files that have
already processed models.
Steps to run and test:
Open the file file1.dgn remove the current
Attach the cell library celllibrary.dgn to the
file and place the cell from the library.
Repeat for file 2
Edit the addxdata.bprc file to point to your
locations of the file1 and file2 dgn files.
Edit the addxdata.bprc file to set the
cmdfilename to the fully qualified locatioin to the addxdata.txt file.
Place the newsgroup.mvba file to a location on
the default VBA search path.
Run msbatch batchprocess “fully qualified path
to the addxdata.bprc file”
Open the file(s) in MicroStation to check the
xdata on the elements.
mark anderson [Bentley]
Visit me at https://communities.bentley.com/communities/other_communities/bentley_innovation/default.aspx
Thanks for all of your input on this subject. As I've said throughout this thread my codes seemed to work on a file by file basis, but not as a batch process. I did "pretty much" as Mr. Anderson directed me to above. His code exhibited the exact same behavior as mine always has. The code worked for individual files, but not as a "batch process". Turns out my programming capability IS adequate, however, my knowledge of Microstation is NOT. Bentley software is new to me and I obviously didn’t understand the nuances of “Batch Process”.
Turns out I needed to pay closer attention to his "6. Place the newsgroup.mvba file to a location on the default VBA search path." As it turns out none of my batch processes for this Xdata topic have ever executed. In fact if you totally delete the .mvba files the “batch process” still appears to "run". I expected a more noticeable error message box. However, I now see a whole slew of errors in the Microstation message center about not being able to load projects.
The only other favor I would like to have is for someone to modify Mr. Anderson’s code to utilize the “OpenDesignFileForProgram” method rather than the “Batch Process” method?
I have lots of code to write and if I need any assistance I will start a new thread and look forward to your future comments and/or suggestions. Thanks to all of you so VERY MUCH!
Since we are writing this for you ... How do you want to get the list of files into the application. Should the application run in MicroStation or outside of MicroStation (a COM based exe written in VB or VB.NET).
Ok I added a sub for processing outside of the current design file. you just need to give it the path that you want to process.