Add note to Dimension VBA (Beginner)

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? 

Parents
  • Can you tell us what version of microstation you are using?
    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?

    Microstation SS3 08.11.09.714

    ProStructures V8i SS8 v8.11.14.238

  • I'm using V8i.

    Unknown 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?

    Exactly that!

  • I forgot to fully edit the quote. I'm not sure how to move the listbox variable to another function and insert it into an existing dimension.
  • 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.

    HTH...

    Sub ArcEquals()
    
    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."
        MessageCenter.AddMessage msg
    End If
    
    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           
                oDim.Rewrite
                oDim.Redraw
            Next i
        End If
    Loop
    
    End Sub

    Microstation SS3 08.11.09.714

    ProStructures V8i SS8 v8.11.14.238

  • Hi Steve,

    small comment:

    Unknown 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.

    With regards,

      Jan

Reply Children