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

mdlMeasure_elmDscrArea : is this changed in connect version

$
0
0

if have this function that works in V8i version :

Private Function CalculateArea(ByRef area As Double, ByRef perimeter As Double, ByRef desc As Long) As Boolean
Dim cExpression As String
cExpression = "mdlMeasure_elmDscrArea(" & VarPtr(area) & "," & VarPtr(perimeter) & "," & desc & ")"
CalculateArea = (0 = GetCExpressionValue(cExpression))
End Function

when I try this in Connect version, it gives me the error "method 'getcexpressionvalue of object _application failed.

what can be wrong here ?


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

$
0
0
This function is definitely bugged and Bentley need to fix or replace it. I often get an exception error if I try to reuse a StringList via the second argument, and I've noticed memory corruption straight after using it.

[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; } ...

[V8i C++] Getting the Visible Edges setting for a reference file

$
0
0

I've had a look at the the ReferenceFile C structure, the mdlRefFile_getParameters() function and also the newer DisplayStyleManager C++ class, but I can't seem to find the correct API function to extract the following info:

  1. Where the 'Reference > Presentation > Display Style' options are stored
  2. Where the 'Reference > Visible Edges > Cached / Legacy / Dynamic' column option is stored

Is this exposed anywhere in any of the APIs? Or is this another undocumented linkage ID on the reference element?

RE: [MVBA]How to let the text string to move with cursor when place text elment ?

$
0
0

[quote user="Changsong Ling"]I want the text string move with cursor[/quote]

Write a class that Implements IPrimitiveCommandEvents.  There are examples in VBA help.

[quote user="Changsong Ling"]CadInputQueue.SendCommand[/quote]

When you sequence commands, you don't have as much control over events as you want.  Writing a primitive command gives you that control.  Your Place Label tool will behave more like a built-in command.

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

$
0
0

[quote user="Piers Porter"]I often get an exception error if I try to reuse a StringList via the second argument, and I've noticed memory corruption straight after using it[/quote]

Preferably, dump the StringList and move into the 21st century...

StatusInt FindFilesFunction (std::vector<std::wstring>& files, ...);

RE: [MVBA]How to let the text string to move with cursor when place text elment ?

$
0
0
Hi Changsong,

as Jon wrote, the right way is to implement IPrimitiveCommandEvent class that ensures your command can behave quite the same way as standard MicroStation tools (element selection and acceptance, dynamics etc.). There are several examples how to use this class in MicroStation VBA help. I recommend to check e.g. Line Element Creation Command, because it's close to what you need (an element is created and displayed dynamically).

My second advice is "Don't use command sending mechanism ... never". In some situations it's right (very rare) or the only possible (because there is no equivalent API available), but let say in 90% of situations a solution can be implemented in better way using VBA API. I agree with Jon that one from the biggest problem is that commands are black boxs and there is no control over them, also it's not simple to monitor when and how (data point or reset for example) they were finished.

With regards,

Jan

[MVBA]How to let the text string to move with cursor when place text elment ?

$
0
0

Hello All,


I'm creating codes to place label. I have already succeed to get all necessary information except the location, which I'm going to let the user to pick up in the drawing manually. I don't know how to let the text move with cursor, my currnt solution is to create the text at another point (MyPoint), then move it to stimulate my requirement.


CadInputQueue.SendCommand "move;xy=" & MyPoint1.x & "," & MyPoint1.y & "," & MyPoint1.Z

But in this way I don't know where my text is moved to. I'm going to place a line to the new location. Any one have some suggestions?


1. I want the text string move with cursor.


2. If have to use my "move" mothod, how to let MS stop running the codes behind CadInputQueue.SendCommand until the user input the destination point?


RE: [V8i VBA] Cell Creation and Annotation Scale

$
0
0
Thanks for the suggestion Jan, I was wondering how one was able to target a cell after it is written to the designfile and that method sounds exactly what I was looking for. I'll give it a try later if I get the time.

Thanks again

RE: mdlMeasure_elmDscrArea : is this changed in connect version

$
0
0
Finally found time again to work on this project. This works. Don't know why the old code contained the GetCExpression, I just copied the old code and found this not working. I don't even think about it to call directly the function. Will try to get this into c#. thanks for the help.

RE: mdlMeasure_elmDscrArea : is this changed in connect version

$
0
0
Hi jon, thanks for the tip, but yes, i'm using Jan's suggestion.

RE: mdlMeasure_elmDscrArea : is this changed in connect version

$
0
0
Sorry, I meant to say " I had not thought to call the function directly." :-)

RE: [V8i MDL C++] Getting a BSIColorDescr from an element colour

$
0
0
BSIColorDescr and BSIColorPalette are legacy concepts from the days before 32 bit displays. BSIColorDescr remains for use with some gui items. For example mdlTreeCell_getColorDescr.

There isn't any "table" of BSIColorDescrs for element colors managed by MicroStation. mdlColorPal_getElemColorDescrByModelRef seems to return a BSIColorDescr that you don't have to free, but it's not actually a "real" BSIColorDescr, it's just something that can be treated as one to keep legacy api happy. But you are correct, we don't provide a way for you to create a BSIColorDescr yourself...

What exactly do you need a BSIColorDescr for, because other than some gui controls that provide "get" functions to access the item's BSIColorDescr pointer (and manage it's memory!), they are best avoided.

-B

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

$
0
0

[quote user="Jon Summers"]

Preferably, dump the StringList and move into the 21st century...

StatusInt FindFilesFunction (std::vector<std::wstring>& files, ...);
[/quote]
Is this the world where my PowerDraft / PowerCivil / PowerMap / PowerSurvey users complain I didn't release a version of my software for them, or a world where all of my other customers complain about a DLL crash from an unresolved function named FindFilesFunction(). ?
:-)
Seriously though, I only use mdlFileList_edit() because there isn't any replacement for it that does the same thing on all Bentley platforms.

RE: [V8i MDL C++] Getting a BSIColorDescr from an element colour

$
0
0

Hi Brien, thanks for your reply.

I am only using a BSIColorDescr because it's the only way I can see to create a symbology preview in a list model. I want to show the colour of design elements in a report, as shown in the attached screenshot below. 

I do this by creating a ListModel with both text and icons, The code I use currently is a bit like this:


lIcon = ICONID_ColorBoundary;
if ( ( iColour >= 0 ) && iColour < 256 )
{
    if ( ( mdlColorPal_getElemColorDescrByModelRef ( &fgColourDSP, iColour, modelRef, 0 ) == BSISUCCESS ) &&
         ( mdlColorPal_getElemColorDescrByModelRef ( &bgColourDSP, 255, modelRef, 0 ) == BSISUCCESS ) )
    {
        mdlListCell_setIconColorOverrides ( listCellSP, fgColourDSP, bgColourDSP );
    }
}
else if ( iColour >= 256 )
{
    ... // What to do?
}


This creates an icon preview for the colour in my ListModel, but it doesn't work for 24-bit colours. In the screenshot above I have just inserted the generic colour swatch icon (ICONID_TrueColorTabIcon) to indicate that the last row is a 24-bit RGB value, but it would be more useful to show the actual colour used. It looks like there are icons to allow this, e.g. ICONID_ColorPatch12Pt if you had a BSIColorDescr set up with the correct colour.

If there is some way to specify colours without resorting to using a BSIColorDescr then I am happy to do so, but it looks like this is a limitation imposed upon the public MDL SDK.


[V8i MDL C++] Getting a BSIColorDescr from an element colour

$
0
0

I need to get a BSIColorDescr for a given element colour. If the element colour is 0-256 then this is trivial with mdlColorPal_getElemColorDescrByModelRef(), but of course MicroStation allows the symbology colour to be any RGB colour these days, and this function won't work with colours above 256. 

To achieve 24-bit colours, it seems MicroStation uses some internal colour map that stores these RGB colours as required. For example, creating a new shade of mauve from the colour swatch might assign an element colour of 780.

Now I can easily get the RGB of this value using mdlColor_elementColorToRGB(); however I don't know how to get the corresponding BSIColorDescr from this RGB. There must be some hidden colour table that MicroStation keeps of all of these assigned colours (above 256) within the DGN file, but I can't see any such table exposed in the SDK.

Since the BSIColorDescr is opaque, I can't allocate one for myself on the fly as required, as these pointers usually refer back to a colour table. The colour table APIs all expect a 256 entry colour table, so I can't really use these, and I won't know in advance how many of these allocated colours are in use in any model, since this is also missing from the SDK.

So how do I get a persistent BSIColorDescr pointer for any arbitrary RGB colour used in a model? It really seems the SDK is sorely lacking in exposing this to the programmer. If I want to display one of these colours in a dialog, then I need a persistent BSIColorDescrP for every arbitrary colour defined beyond the attached colour table.

Cheers.

RE: VBA support in the future

$
0
0

Hi minion,

I agree you are probably safe for at least several years. If talking about VBA and VBA apps future, in my opinion 3 different aspect exist: Support of VBA as language itself, support of VBA in MicroStation and your app code quality and flexibility:

VBA language is a kind of mythical animal with many news, rumors and (more or less) serious information published. It's important to realize that VBA is Microsoft proprietary technology and Microsoft own all infrastructure / environment (comparing to ISO standardized languages like C++ or if talking about Microsoft, like C# or CIL). Microsoft tried to drop VBA about 10 years ago and to replace it by VSTO (Visual Studio Tools for Office) and when Office 365 and Office Store was introduced, by Office apps.

But the reality is that VBA is still there. It's bad development language that allow to write ugly dirty code with old dev environment and lack of modern features (e.g. robust security), but it suits perfectly every day automation requirements. Despite of it's not actively developed for a decade (only maintained - migration from 32bit version 6 to 64bit version 7), it's still actively used. There is a steady decline of VBA usage (probably because of web based app grow and growing popularity of Python as app extension tool), but it seems it's quite slow and the main ecosystem (Windows + Office) will be there for long time, so I assume VBA will live for many years.

MicroStation VBA is mature scripting and macro tool and as written by Jon, it's still supported in MicroStation CONNECT Edition. Bentley are quite an exception, because both AutoCAD and ESRI ArcView don't provide standard VBA support now (but it can be added) and even for user customization and scripting they prefer tools like VB.NET or Python.

You should be aware that as Jon wrote, VBA code compatibility between 32bit V8i and 64bit CE is pretty high with only a few changes required by migration from 32 to 64bit. But it's correct for MicroStation VBA only (!), not for VBA ecosystem. Microsoft does not offer the same libraries (DLL, OCX...) in VBA 6 and 7. And it's not the case of Microsoft only, many libraries that can be used in VBA 6 are not available in 64bit version of VBA 7.

Application code: In my opinion this is a crucial issue, because you cannot control VBA life cycle and its support in MicroStation, but you can write your code in such way that it will be easier (or vice versa impossible) to migrate the code from V8i to CE or in a distant future to rewrite it into another language. If your code does not depend (too much) on external libraries and it has clear structure, the code is clean and not written in spaghetti staly, you are well prepared for migration to CE and also to hand-over the code to other rmaintainer.

With regards,

 Jan

VBA support in the future

$
0
0

Hi Guys and Gals,

Okay, now that I've written my Microstation VBA programs.  I am wondering how long they will be able to be used.  I probably should have wondered that first, but when I started in 2014 I was on V8.  In 2015 they upgraded me to V8i SS2.  Okay great, I only need it to last until 2021 when I retire, then it does not matter so much.  I figured they only upgrade us every eight or ten years.  Well now I heard they want to upgrade us to SS4 in a few months.  Maybe my thoughts about how often they upgrade us are wrong.  Oh and now since I've shared my programs with my colleagues and they finally tried them out, they seem to really love them.  I see my programs loaded on all the workstations now!  So, it would be fantastic if my programs would last beyond my time here.  Does it look like MVBA will be supported in future versions?  If not was there a language that would be more likely supported into future versions?

Thanks,

Minion

 

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

$
0
0

[quote user="Piers Porter"]I only use mdlFileList_edit() because there isn't any replacement for it that does the same thing on all Bentley platforms.[/quote]

On re-reading my comment, I see that you could have taken it as a criticism, which wasn't intended (I've edited my post).  I attempted to suggest that Bentley Systems should replace the existing mdlFileList_edit with something that doesn't depend on the ancient C-style StringList.  For example...

StatusInt                   mdlFileList_edit  
( 
FileListInfo const&         listInfo,     //  =>  required
std::vector<std::wstring>&  fileList,     //  <=> contents replaced by new list
long                        attributes, 
MSWChar const*              dialogTitle,  //  =>  all pointer params are optional
MSWChar const*              listLabel, 
MSWChar const*              fileFilter, 
MSWChar const*              defaultDirectory  
); 

That gets both Bentley and the programmer off the memory-management hook as std::vector<> takes care of its own memory management.  Consequently, neither would  the user have to remember to free() the StringList.

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

$
0
0
7 foot joke for a 6 foot bloke! Never mind, I agree that a replacement for this function would be grand.
Viewing all 7260 articles
Browse latest View live


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