I am trying to learn VBA for microstation and finding it very difficult. There seems to be little to no documentation or tutorials online.
I have a userform that will allow the user to select a note to add to a dimension, ie TYP, CLR, etc.
I have the userform built and it displays all the notes via a listbox. The part I'm unsure how to do is add the selected note to a selected dimension.
Can someone provide an example of how to go about doing this?
Microstation SS3 08.11.09.714
ProStructures V8i SS8 v188.8.131.52
I'm using V8i.
Steve Hipp said:Are you unsure of how to move the listbox variable to some other sub/function or is it the mechanic of actually inserting the variable text into an existing dimesion?
I'm not that familiar with user forms, but that is a core functionality of vba, not unique to microstation. You should be able to find plenty of answers to that part of your query by doing a google search. As to inserting into existing dimensions, I have a small routine I have used for years you can play with. I select the dimensions I want to append, run the marco, & it inserts "ARC = " before the dimension value.
Dim oDim As DimensionElement
Dim ee As ElementEnumerator
Dim Gar As String
Dim segCount As Integer
Dim i As Long
Dim msg As String
On Error Resume Next
Set ee = ActiveModelReference.GetSelectedElements
If ee Is Empty Then
msg = "No dimensions were selected."
Gar = "ARC= *"
Do While ee.MoveNext
If ee.Current.IsDimensionElement Then
Set oDim = ee.Current
segCount = oDim.SegmentsCount 'returns number of segments of a dimension chain
For i = 1 To segCount
oDim.PrimaryText(i) = Gar
Steve Hipp said:oDim.Redraw
From MicroStation V8 XM Edition (where enhancement like display priority etc. were introduced), no element redraw is required anymore. I see it in many VBA code posted here, but in fact there are only a few situations where VBA code has to take care about element redraw (e.g. during dynamic).
If element is rewritten, MicroStation takes care about redraw automatically if it's necessary.
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point