(v8i SS3 VBA) Trying to bring in contours from ArcMap to MS but elvations are coming in incorrectly

The issue is that I the contours I have came from a .shp file and the line elevations are not being stored as elevations.  Instead they are being stored as string values in a property called "ELEVATION".  I have tried many different ways to get these come in with elevation so I can create a surface, but so far with no luck.  I was thinking that I could write a macro to get each line in my selection and pull the value from the property and set it as the line elevation.

 

What I have so far:

Public Sub ImportElevations()
Dim oElEnum As ElementEnumerator
Dim oEl As LineElement
Dim oPropHand As PropertyHandler
Dim getElevationFromCustom As String

Set oElEnum = ActiveModelReference.GetSelectedElements
oElEnum.Reset
While oElEnum.MoveNext
    Set oEl = oElEnum.Current
    Set oPropHand = CreatePropertyHandler(oElEnum.Current)
   
    If (oPropHand.SelectByAccessString("ELEVATION")) Then
    getElevationFromCustom = oPropHand.GetDisplayString
   
    ' Write getElevationFromCustom to line elevation
   
    End If
Wend
    oEl.Redraw msdDrawingModeNormal
    oEl.Rewrite
End Sub

Has anyone dealt with this before?

Thanks,

Matt

  • When dealing with MicroStation based applications and Element attributes/properties it is best to include a very simple design file having one (1) element (more only if necessary) to allow the programmers to review the element and its associated data and format that it is stored in.  There are several ways to get/set element data and a sample will save a lot of time and effort trying to identify what format the data is stored in.  Please feel free to post a sample so the community can review it and make a prompt recommmendation.

    Thank you,

    Bob



  • Here is a simple .dgn with a single line string in it.  All I want to do is take the [ELEVATION] Property and convert it to a double and use it as the Z elevation of the contour line.  I think my code is close, but I cant find any information on the parameter for elevation.

    ~Matt

    testfile.dgn
  • Hi Matt,

    I have two question before an investiagation your code:

    • You have not told what is the source format of your data. I assume it's shp, but because it's important for my second question, I'd like to be sure.
    • If the source format you reference is shp, did you try to use MS_ELEVPROP_AS_Z configuration variable? You can use it to tell MicroStation in what shp attribute an elevation is stored and if defined, MicroStation uses this information to place shp graphics into proper z elevation. If used, it's often set to MS_ELEVPROP_AS_Z=ELEVATION.

    With regards,

      Jan

  • Jan,

      You are correct the source is a .shp file.  I am unfamiliar with that variable.  Can you explain this a little further? 

    I just read http://communities.bentley.com/products/road___site_design/f/5922/p/78214/214008.aspx and it would lead me to think that you can change the elevation of each point along the line segment of the element to from the elevation set in the property. i.e.

    MS_ELEVPROP_AS_Z=ELEVATION.

    How exactly would I implement this? I previously used the Bentley Map to set the elevation of each line the the elevation property and create labels.  I was able to create a dtm from the text labels using GEOPAK, but the contours are not nearly as clean as the starting point.

    Matt

  • Hi Matt,

    MS_ELEVPROP_AS_Z is MicroStation configuration variable, which as far as I know works with SHP reference/import only and its usage is quite simple.

    The workflow is:

    1. Prerequisities: You have contours stored in SHP file as 2D linestring. If the file is referenced to MicroStation, it's displayed as 2D reference. In SHP file also elevations are stored for each contour. Usually it's in ELEVATION attribute, but it can be any name in general.
    2. In MicroStation, create a new configuration variable named MS_ELEVPROP_AS_Z (it doesn't exist by default), set its value to the name of elevation attribute. So if it's ELEVATION, set the variable to ELEVATION. Be careful, I think it's case sensitive, so it cannot be e.g. Elevation.
    3. Attach SHP as reference as usually. If the setting is correct, contours are not displayed as 2D graphics in Z=0, but are automatically moved to their Z elevations.

    I have not tested it, but I think you don't have close design file or to restart MicroStation after the variable is set, I think MicroStation checks for the variable setting every time SHP file is referenced or imported.

    With regards,

      Jan

    Answer Verified By: maat7043 

  • Matt,

    The ELEVATION element properties value you provided within the sample .dgn file can be get and set the property without any problems.  Presuming that you are not encountering any problem in doing so, to set an element's elevation (z depth points) you may want to refer to the MicroStation VBA Help file topic: "Flattening Elements" that provides some sample code to "flatten" an element to the current view depth setting.

    If Jan's suggestion does not help with your specific workflow/goal's end results maybe you could provide some additional details describing what your overall workflow would be.  And let us know if the goal is to modify elements elevation directly in the .shp file/project or creating elements at a desired elevation stored in a seperate output .dgn file having no further requirements to synchronize with the original .shp file/project elements.

    Bob