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

RE: mdlMeasure_elmDscrArea : is this changed in connect version

$
0
0

Hi,

[quote user="djeten"]Correct, i'm using that getcexpressionValue in vba. [/quote]

May I ask why do you use GetCExpression? C expressions are usefull (better to say they were useful as they are connected with C API), but in my opinion there is no reason to use them in your situation.

Why you don't call mdlMeasure_elmDscrArea directly? If it works in VBA (see code bellow) it can be used the same way in C#.

Option Explicit

Declare PtrSafe Function mdlMeasure_elmDscrArea Lib "stdmdlbltin.dll" (ByRef area As Double, ByRef perimeter As Double, ByVal edP As LongPtr) As Long

Public Sub CalculateArea()

    Dim elem As Element
    Set elem = ActiveModelReference.GetElementByID(DLongFromLong(602))
    
    Dim elemRefP As LongPtr
    elemRefP = elem.MdlElementDescrP
    
    Dim area As Double
    Dim perimeter As Double
    
    Dim result As Long
    result = mdlMeasure_elmDscrArea(area, perimeter, elemRefP)
    
    If (0 = result) Then
        MsgBox "Area: " & CStr(area) & ", perimeter: " & CStr(perimeter)
    End If

End Sub

In fact a better solution would be to find a proper method in DgnPlatformNet, but I am not sure if such class / method exists.

With regards,

  Jan


Viewing all articles
Browse latest Browse all 7260

Trending Articles



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