Quantcast
Channel: MicroStation Programming - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 1677

Re: Export coordinates from elements (cells)

$
0
0

There are two questions here...

  1. How do I export cell origin coordinates?
  2. How do I convert MicroStation XY coordinates to another representation?

Divide and conquer!  Write a macro to export cell coordinates to CSV (or whatever).  Write another module to read that CSV and convert XY coordinates to your chosen style.  That second module doesn't even have to be a MicroStation application — you could write a VBA macro for Excel, for example, if that's where you plan to use the information.

For the first task, use MicroStation's XYZ Text export tool.  If you want to write some code, then the scan idiom  VBA provides the ModelReference.Scan method to scan a model for elements.  Search VBA help, which also provides some examples.  There are some more examples on our web page here.

The second task is simple numeric manipulation.  Given the origin of your grid and its spacing, it's straightforward to convert XY coordinates to grid labels.  Here's a crude attempt...

' ---------------------------------------------------------------------
Function GetXLocation(ByVal x As Double, ByVal origin As Double, ByVal width As Double) As String
    GetXLocation = vbNullString
    Dim column As Long
    column = CLng((x - origin) / width)
    GetXLocation = CStr(column)
End Function
' ---------------------------------------------------------------------
Function GetYLocation(ByVal y As Double, ByVal origin As Double, ByVal height As Double) As String
    GetYLocation = vbNullString
    Dim row As Long
    row = CLng((y - origin) / height)
    If (0 <= row And row < 1) Then
        GetYLocation = CStr("A")
    ElseIf (1 <= row And row < 2) Then
        GetYLocation = CStr("B")
    ElseIf (2 <= row And row < 3) Then
        GetYLocation = CStr("C")
    ' ...
    End If
End Function




Viewing all articles
Browse latest Browse all 1677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>