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

[V8i] and [CONNECT] mdlFileList_edit OR mdlStringList_getMember bugs with too many files

$
0
0

1) When over 1,000 files are selected with  mdlFileList_edit() and mdlStringList_getMember() is used to extract the file names, the last file in the list is corrupt.

2) When over 2,000 files are selected .... the last N file names are corrupt

3) When under 1,000 files are selected the list is fine

Notes:

- This is repeatable in v8i and CONNECT

- The numbers given (1,000 and 2,000) are approximate, I dont have the time to figure out exact numbers but have repeated the 3 above issues multiple times with several different machines

- I will also be opening a SELECT service ticket for this if Bentley does not respond to this here.

Code to reproduce:

CONNECT code (v8i almost identical except WChar functions)

#define EXIST(fname) (!_waccess(fname,0))
strListP = mdlFileList_edit(&fileInfo, NULL, FILELISTATTR_FILES | FILELISTATTR_OPEN | FILELISTATTR_UNIQUE | FILELISTATTR_SORT | FILELISTATTR_MULTIPLE | FILELISTATTR_CASESENSITIVE, title, L"files to process:", L"*.fpt", curdgn); if (fileInfo.lastAction == ACTIONBUTTON_CANCEL) return; for (i=0;i<mdlStringList_size(strListP);i++) { //print the contents out in the message window mdlStringList_getMember(&str, NULL, strListP, i); wcscpy(filestr, str); swprintf(szBufferW, L"[%d of %d][%s]", i+1, mdlStringList_size(strListP), filestr); Msg(szBufferW); if (!EXIST(filestr)) // We know the list is corrupt because we just selected valid files { swprintf(szBufferW, L"Error importing Footprint File\nFile %d of %d does not exist\n[%s]", i+1, mdlStringList_size(strListP), filestr); MsgBox(szBufferW); return; } ...

RE: [CONNECT MicroStationAPI] Where is the element type enum?

$
0
0

[quote user="Jon Summers"]You picked the one value (CELL_LIB_ELM) that is not defined any more.  Cell libs haven't been an element type since V8.0. I found the enum where Brien indicated (in the SDK for Update 2)...[/quote]

That figures....

 

So, why is it still used as part of DgnElements.h ???? History?

RE: How to make a ComplexShapeElement from BSplineCurves

$
0
0

[quote user="D C"]I am able to use CreateComplexShapeElement1 with LineElements, but when I include a BSpline this fails[/quote]

Does your code create the two helices OK?  Can you use MicroStation's tools to create a complex shape from those helices manually?

RE: [CONNECT MicroStationAPI] Where is the element type enum?

$
0
0

The macro you cited (TMSK0_CELL_LIB) actually exists in mselems.h in V8i.  Since it is never used, I suppose that nobody was provoked to remove it.

I don't know why the macro in CONNECT doesn't cause a pre-processor error.  Presumably CELL_LIB_ELM collapses to nothing because it's no longer defined?

[CONNECT MicroStationAPI] Where is the element type enum?

$
0
0

I can see where element types are used in DgnElements.h.  For example...

#define TMSK0_CELL_LIB          ELMBITMSK (CELL_LIB_ELM)
etc.

However, I can't see where those values are defined.  Is there an enum that hasn't been published?

RE: How to make a ComplexShapeElement from BSplineCurves

$
0
0
Hi,

complex shape has to be closed, but you are creating two B-splines that don't create closed element. But I am not sure if it's correct and you should se CreateComplexString or the B-splines are created wrongly and should create closed element.

With regards,

Jan

RE: How to make a ComplexShapeElement from BSplineCurves

$
0
0

[quote user="Jan Slegr"]But I am not sure if it's correct and you should se CreateComplexString or the B-splines are created wrongly and should create closed element[/quote]

Thanks, changing to CreateComplexString fixed the issue

How to make a ComplexShapeElement from BSplineCurves

$
0
0

I am able to use CreateComplexShapeElement1 with LineElements, but when I include a BSpline this fails, even though IsChainableElement returns true. The code below demonstrates the problem. 

I am using V8i version 08.11.09.459

Sub CompoundElementTest()

    Dim oStringElements(1) As ChainableElement
    Dim oBsplineCurve As New BsplineCurve
    Dim axis As Segment3d
    Dim startPt As Point3d
    Dim radius0 As Double
    Dim oElement1 As Element
    
    startPt = Point3dFromXYZ(1, 0, 0)
    axis = Segment3dFromXYZXYZStartEnd(0, 0, 0, 0, 0, 1)
    oBsplineCurve.helix 1, 1, startPt, axis, 1, False, 0.000000000001
    Set oElement1 = CreateBsplineCurveElement1(Nothing, oBsplineCurve)
    Set oStringElements(0) = oElement1
    
    startPt = Point3dFromXYZ(1, 0, 1)
    axis = Segment3dFromXYZXYZStartEnd(0, 0, 1, 0, 0, 2)
    oBsplineCurve.helix 1, 1, startPt, axis, 1, False, 0.000000000001
    Set oElement1 = CreateBsplineCurveElement1(Nothing, oBsplineCurve)
    Set oStringElements(1) = oElement1
        
    Dim oComplexShape As ComplexShapeElement

    Set oComplexShape = CreateComplexShapeElement1(oStringElements, msdFillModeFilled)
    ActiveModelReference.AddElement oComplexShape

End Sub

RE: [V8i] and [CONNECT] mdlFileList_edit OR mdlStringList_getMember bugs with too many files

$
0
0

Thanks Jon,

 I see your logic but the mdlStringList_getMember() function returns a WCharCP *, which is totally valid for the first 1,000 lines when treated as a pointer to a WChar array (perhaps the 8bit is converted to WChar within the funtion) . Here's the API Doc:

If you are suggesting that its actually a pointer to a 8bit Multibyte string then would not sending that string to mdlOutput_message which is expecting WCharCP produce garbage and not a valid file name string for the first 1000 lines?

Additionally, the 32bit implementation in v8i produces the exact same corruption and the v8i API returns char** to the string (8bit). Following is the 32bit code in v8i that displays the exact same corruption and does not use WChars:

    char         filestr[MAXFILELENGTH];
    char         *str;

   for (i=0;i<mdlStringList_size(strListP);i++)
    {
    mdlStringList_getMember(&str, NULL, strListP, i);
    strcpy(filestr, str);
    //Msg(filestr);
    if (!EXIST(filestr))
        {
        //file name is corrupt here
        ...


I did try to use MultiByteToWideChar with the returned pointer in CONNECT but a valid filename string was not produced.



RE: [V8i] and [CONNECT] mdlFileList_edit OR mdlStringList_getMember bugs with too many files

$
0
0

[quote user="Loren"]Here's the API Doc[/quote]

If a StringList stores 8-bit chars internally, then mdlStringList_getMember can't give you a pointer to a 16-bit string, because there is none.  It could convert the 8-bit to a 16-bit internally, but the pointer it hands to you would point to an out-of-scope internal variable (which, come to think of it, would lead to the sort of corruption you observe).

Try the new function mdlStringList_getMemberString, which gives you a 16-bit string wrapped in a WString object.  Whether or not I'm right about the internal storage, that guarantees you a wide string to use.

RE: [V8i] and [CONNECT] mdlFileList_edit OR mdlStringList_getMember bugs with too many files

$
0
0

Thanks Again Jon,

However new code:

WString      wStr;

for (i=0;i<mdlStringList_size(strListP);i++) { //mdlStringList_getMember(&str, NULL, strListP, i); //wcscpy(filestr, str); mdlStringList_getMemberString(wStr, NULL, strListP, i); wcscpy(filestr, wStr.GetWCharCP()); if (!EXIST(filestr)) { swprintf(szBufferW, L"Error importing Footprint File\nFile %d of %d does not exist\n[%s]", i+1, mdlStringList_size(strListP), filestr); MsgBox(szBufferW); return; } ...

Results in same corruption, as with previous code when >1,000 files selected, the last file name is corrupt):

And when >3,000 files in the list:

RE: [V8i] and [CONNECT] mdlFileList_edit OR mdlStringList_getMember bugs with too many files

$
0
0

I suggest that you put together a small project that is self-contained and illustrates this behaviour (like the MDL examples).  Then submit a SR to Bentley to fix either mdlFileList_edit or the StringList implementation.

RE: [V8i] and [CONNECT] mdlFileList_edit OR mdlStringList_getMember bugs with too many files

$
0
0
Will do Jon,
Thanks again for your time on this.
Loren.

RE: mdlMeasure_elmDscrArea : is this changed in connect version

$
0
0

Correct, i'm using that getcexpressionValue in vba.  

A bit of background : this function is part of old vba code (aprox 10 years old), that I'm trying to rework to c# (the program we writing is collecting data from microstation, office, illustrator, etc and store that in a database - kind of a program that holds all technical documentation in our company) .

 The information i need from microstation is the area, perimeter, ix, iy , ...  from profile drawings and send this to the database.    this code needs to be running without user interaction (only one click on a button) but also needs to run in batch over a bunch of drawings.  the old code to calculate works fine in select, but give's me errors in connect version. (when it calling that getcexpressionvalue function)

I'm not aware of vba functions that calculates these kind of information ?

RE: mdlMeasure_elmDscrArea : is this changed in connect version

$
0
0

DgnPlatformNet API for C# Developers

[quote user="djeten"]A bit of background : this function is part of old vba code (aprox 10 years old), that I'm trying to rework to c# [/quote]

MicroStation CONNECT provides the C# DgnPlatformNet API.  Having said that, I don't see any mention in the DgnPlatformNet help of a method to measure area or volume properties.  Perhaps someone from Bentley Systems can suggest how to achieve that.

VBA ClosedElement Interface

[quote user="djeten"]I'm not aware of VBA functions that calculates these kind of information ?[/quote]

VBA provides the ClosedElement interface.  If an element implements that interface then you can take measurements.

There's also the Property Handler API, which may be useful to you.

C Expressions in CONNECT

You're not the first to notice that C Expressions don't work in CONNECT VBA.  C Expressions rely on some internal book-keeping where MDL functions were published in a way that they could be interpreted by the C Expression handler.  That internal book-keeping seems deficient.

Reports, Tables and Item Types

You should investigate Reports in CONNECT.  The report tools let you gather element information.  Once created, a report can be used to build a Table or sent to an external file such as CSV or XML.  By defining your own Item Types for business data, and attaching item data to graphical elements, you can add custom information to those reports.  In other words, you may not need to write any code.


[CONNECT DgnPlatformNet] How do I measure dimensional properties?

$
0
0

If I'm writing a C# AddIn using the DgnPlatformNet, how do I get planar properties such as area & perimeter?  How do I obtain volumetric properties such as volume & centroid?

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

[CONNECT VBA] GetCExpressionValue

$
0
0

A couple of posters have noted that VBA's GetCExpressionValue doesn't work in CONNECT as it worked in earlier versions of MicroStation.  Are C expressions fully-functional in CONNECT?  Are all MDL functions published?

[CONNECT][C++][.NET] Custom Ribbon Programmatically?

$
0
0

Has anyone created a custom ribbon in CONNECT programmatically yet? If so are you willing to share the code?

RE: [CONNECT][C++][.NET] Custom Ribbon Programmatically?

$
0
0

[quote user="Loren"]Has anyone created a custom ribbon in CONNECT programmatically yet?[/quote]

Bentley tell us that the user customisation tools, which create a UI in a DGNLib, should be our first port of call.

If you look in the \MicroStation\Telerik folder, you will see a heap of DLLs in the Telerik namespace.  Visit Telerik to find more about that.  I think their stuff is .NET rather than C++.

Viewing all 7260 articles
Browse latest View live


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