Learning MicroStation VBA

Users can select elements in their files through a variety of methods. Once selected, we can make modifications to the selected elements by using the GetSelectedElements method.
Sub <b class="bold">TestSelectionSetA</b>() Dim myElement As Element Dim myElemEnum As ElementEnumerator Set myElemEnum = ActiveModelReference.GetSelectedElements While myElemEnum.MoveNext Set myElement = myElemEnum.Current myElement.Level = ActiveModelReference.Levels( _ "A-FURN-FREE") WendEnd Sub<a name="639"></a><a name="beginpage.341FC313-8B8A-4C4E-8603-B2020EB17B3E"></a>
We used the ElementEnumerator in a previous chapter. In this example, we get the selected elements and change the level of each element one-by-one. Let's look carefully at the code. Are we missing anything?
Sub <b class="bold">TestSelectionSetB</b>() Dim myElement As Element Dim myElemEnum As ElementEnumerator Set myElemEnum = ActiveModelReference.GetSelectedElements While myElemEnum.MoveNext Set myElement = myElemEnum.Current myElement.Level = ActiveModelReference.Levels("A-FURN-FREE")<b class="bold"> myElement.Rewrite</b> WendEnd SubIf we do not rewrite the element to the design file, element modifications are not persistent. This is critical. You could spend a great deal of time debugging code only to find that changes made to elements are not reflected in your files. Any changes made to elements in files must...