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

RE: [V8i C++] MstnElementSetTool and complex element "picking"

$
0
0

Thanks !! I'll give this a test drive.

 

A somewhat related question regarding selecting elements. When I allow DragSelect and I drag the "select" line across elements, the locate process "finds" the elements I intersected, and I can see them in FilterAgendaEntries(). However, if I datapoint/drag to begin the selection process when the cursor is currently "over" an element (i.e. the locate logic has nominated an element) and I continue to drag, nothing else is selected. Is there some way to "force" the selection/location process to NOT pick the element the cursor is over IF the mouse is down and held and use the "drag" line elements instead?


RE: tooltips in Microstation

$
0
0
the definition of point2d was the magic.
Great observation and thanks much.

RE: [V8i C++] MstnElementSetTool and complex element "picking"

$
0
0

[quote user="Bruce Reeves SRNS"]Is there some way to "force" the selection/location process to NOT pick the element the cursor is over IF the mouse is down and held and use the "drag" line elements instead?[/quote]

The first thing to understand is how drag selection works. On the data button down event, interest is registered for drag events using mdlState_setFunction with STATE_DRAG_INIT. Now if the cursor moves a sufficient distance before getting an up event for the data button, the drag is initiated.

Because our tools process the data button on the down event in order to locate elements/advance the tool state (and don't get both down and up events for data, only down), it's not possible to support initiating drag selection while over an element without the element also being located. You would have to be able to do the locate on the up event, which wouldn't be sent when/if a drag started. But as already mentioned, tools don't get sent an up event for data button currently...and it might also feel "odd" to the user doing things on up instead of down.

Anyway, this is the reason why MstnElementSetTool only registers for drag events when an element isn't located. NOTE: The user can set the locate interior preference to "never" tomake it easier to use drag selection in a rendered view, or when their are filled shapes, etc.

Now, while it would be possible to make the tool only work using drag (i.e. you never call locate in your data point function)...that would be fairly non-standard tool behavior and not very discoverable either (user might click on things and be confused why nothing is happening). There's also a user preference that disables drag selection, which would make your tool non-functional.

One approach to this problem is to add buttons for various selection modes to the tool settings like the Element Selection tool and some mesh tools do. Then you'll now to accumulate points for the selection line/box/shape, etc. in your data button method instead of calling locate.

HTH

-B

[V8i C++] MstnElementSetTool and complex element "picking"

$
0
0

I've got a question about how to develop a MstnElementSetTool that needs to be able to select text elements in order to "fill-in" an existing Data Field. I imagine the tool to work in the following manner:

 

1. User "nominates" text element containing data field with datapoint.

2. User "accepts" text element with datapoint. I save the ElementRef.

3. User now "nominates" other text elements ( 1 or more ) via single element "picks" or DragSelect. Tool also supports CTRL+/- of text elements.

4. User "accepts" the second (possibly multiple) selection.

5. I do some magic with the second group of text elements and create a single, final text string that gets put into the initial text's enter data fields. 

 

I suspect it's somehow possible to determine when I complete step 2. but I'm not sure how to "restart" the element selection process for step 3 and beyond.

 

 

Bruce

RE: [CONNECT DgnPlatformNet] Enumerate DGN Model Elements

$
0
0
ScanCriteria is overkill unless you need to filter by spatial criteria.

The only filtering mechanism provided by ModelElementsCollection is to select graphical elements, control elements, or both.
Iterating all the elements in a model should be quite fast as all of them are already loaded into memory.
You can filter according to your own criteria while iterating the collection. It would be no more efficient for us to do the filtering for you.

RE: Determine Range of elements in Reference Where Displayed

$
0
0

Hi Andrew,

[quote user="Andrew Womsley"]I have tried to use ActiveModelReference.range(True)[/quote]

It does something quite different than you want to do: It gets a range of the active model (defined by all elements), optionally including attached reference. It does not work with any specific element.

[quote user="Andrew Womsley"]I would like to be able to bring back the bottom left corner of only the displayed border.[/quote]

There are two way how to do it: To check the reference range or to check a specific element.

Find the reference range

I don't like too much this solution, because an element or reference range is potentially less exact (it's not the part of geometry), so in my opinion it's a bit risky to based any placement on the range. But it may work fine in your case.

To get the attachment range, just access a proper item in attachments list:

Dim reference As ModelReference
Set reference = ActiveModelReference.Attachments.Item(1)

Dim refRange As Range3d
refRange = reference.Range(False)

... to access the 1st element, but you can also find the attachment by e.g. name.

Check a specific element

It's about to find a proper element in the attachment, which can be done using scan criteria or anything else. To work with elements in attachement, use the same code as for active model, but don't use ActiveModelReference, but the attachment object.

With regards,

  Jan

mdlWindow_showBalloonTooltip change font to a fixed width font for aligning columns

$
0
0

Is there any way to change the font for mdlWindow_showBalloonTooltip? The proportional font used makes aligning columns impossible.

I would like to change the font to Consolas.

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

$
0
0
Hmm. They (e.g. CELL_LIB_ELM) don't appear to be in my "dgnplatform.r.h"

RE: Determine Range of elements in Reference Where Displayed

$
0
0
Thanks for your answer Jan.

I'd already tried your first suggestion. It too brings back the range of all elements regardless of display being on or off so is redundant to my needs.
So it looks as though I'll be iterating through every element in the attachment to check to see if its displayed then some how working out the lowest X, Y coordinates from all of those elements.

[v8i SS4 C#] Cannot open lots of files with print dialog open

$
0
0

We have a print addon for MicroStation that have worked on MicroStation v8i for many years. But now with ss4, if we try to select many files (10+), MicroStation crashes with the following error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 

I have tried with new empty files to make sure that it's not corrupt files that causes the crash.

It's not easy to reproduce, but the code below will crash when I run in debug. The strange thing is that it only crashes if I have the print dialog open. If I comment out the first line, the code runs fine.

BIM.Session.Instance.Keyin("MDL LOAD PLOTDLG SILENT "); // works if this line is deleted
OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "MicroStation DGN Files (.dgn)|*.dgn|AutoCAD Drawing Files (.dwg)|*.dwg|All Files (*.*)|*.*"; dialog.Multiselect = true; if (dialog.ShowDialog() != DialogResult.OK) return; foreach (string fileName in dialog.FileNames) { mainAddin.Instance.App.OpenDesignFile(fileName, false, BCOM.MsdV7Action.Workmode); }

If someone can reproduce this behaviour, its great. And if someone has a solution, it's even better.

Frode

RE: [CONNECT DgnPlatformNet] Enumerate DGN Model Elements

$
0
0

Filtering by element type also seems to be quicker with ScanCriteria.. In other cases, the ModelElementsCollection is indeed faster.


public static ScanCriteria AddElementTypes(this ScanCriteria criteria, List<MSElementType> types)
        {
            using (BitMask bitMask = new BitMask(false))
            {
                foreach (MSElementType type in types)
                    bitMask.SetBit((uint)type - 1, true);

                criteria.SetElementTypeTest(bitMask);
            }

            return criteria;
        }

public static List<Element> Scan(this ScanCriteria criteria, DgnModelRef modelRef)
        {
            List<Element> result = new List<Element>();
            criteria.SetModelRef(modelRef);
            criteria.Scan((e, m) =>
            {
                result.Add(e);

                return StatusInt.Success;
            });

            return result;
        }


Usage:
List<Element> results;

            using (ScanCriteria sc = new ScanCriteria())
            {
                DgnModel activeModel = GetActiveModel();
                results = sc.AddElementTypes(types).Scan(activeModel);
            }

            return results;

RE: [CONNECT DgnPlatformNet] Enumerate DGN Model Elements

$
0
0

[quote user="Maury"]foreach(MSElementType type intypes)

  bitMask.SetBit((uint)type - 1, true);[/quote]

Thanks for showing us how to set the ScanCriteria element type mask.

[CONNECT DgnPlatformNet] Enumerate DGN Model Elements

$
0
0

I have found two ways to enumerate the elements of a DGN model using the DgnPlatformNet...

  • Scan method, which uses a ScanCriteria object to optionally filter elements
  • ModelElementsCollection, which supplies a .NET Enumerator

What are the pros and cons of those methods?  Here are a couple of observations to start the conversation...

Scan and ScanCriteria

I can see no example that demonstrates these methods.  In particular SetElementTypeTest (bitmask) looks like a throwback to C-style MDL, where we have to figure out the bitmask that corresponds to a particular element type.

ModelElementsCollection

This conforms to the spririt of C#.  It supplies an IEnumerator<Element>.  Unlike the scan method, there appears to be no way to filter the contents of that enumeration before it's collected.  For large models, where we want to examine a sub-set of its elements, that is likely to be inefficient.

RE: Determine Range of elements in Reference Where Displayed

$
0
0

[quote user="Andrew Womsley"] It looks as though I'll be iterating through every element in the attachment [/quote]

That's simple enough: create a ScanCriteria object and set the element type to find shapes or cells or however your border is composed.

Dim oCriteria = New ElementScanCriteria
oCriteria.IncludeType msdElementTypeShape ' Or whatever
ElementEnumerator oElements = oAttachment.Scan (oCriteria)
Do While (oElements.MoveNext)
...
Loop

Determine Range of elements in Reference Where Displayed

$
0
0

I have a border file which caters for many sizes. This in turn is attached to designs.  The users control what size border they want though the use of level display on the reference file attachment.  So far so good, old fashioned and not the best but it works.  Oh and for good measure the users frequently move the border placement to suit their drawing so it's not consistently in the same place.

Now here is where my problem comes in; I have to be able to add elements to the designs to make it look as though a stamp has been applied and I need to be able to determine where in the design the bottom left corner of the border is.
The bottom left corner of the border is determined by which levels have been switched on/off in the reference file display.

I have tried to use ActiveModelReference.range(True) but unfortunately this gives me the extents of the reference regardless of the level display.

I would like to be able to bring back the bottom left corner of only the displayed border.

Could anybody give me any pointers on how to achieve this?

Thanks,

Andy


RE: mdlMeasure_elmDscrArea : is this changed in connect version

$
0
0

Please follow the MicroStation Programming forum best practices.

Identify Your Programming Language

It looks like you're writing MicroStation VBA and calling an MDL function using GetCExpressionValue?

Code Syntax Highlighting

When you post code, use the Forum advanced editor's syntax highlighting tool. That's the icon that resembles a pencil:  Syntax Highlighter

Why call MDL when VBA includes measurement functions?

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: [CONNECT MicroStationAPI] Where is the element type enum?

$
0
0

[quote user="Bruce Reeves SRNS"]They (e.g. CELL_LIB_ELM) don't appear to be in my "dgnplatform.r.h"[/quote]

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)...

#include <DgnPlatform/DgnPlatform.r.h>
enum MSElementTypes
{
    CELL_HEADER_ELM                 = 2,
    ...
    MSELEMENTTYPES_MaxElements      = 113
};



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

$
0
0

Hi Jon,

  1. WCharCP      str;
    WChar        filestr[MAXFILELENGTH];
    StringList   *strListP;
  2. The stringlist is freed at the end of the function using mdlStringList_destroy(strListP);
  3. The files themselves are fine. It is the contents of the list (file names) that get corrupted. Below are images of the list corruption with over 2,000 files where the list gets corrupted from file #2340 to #3236 (selected 3236 files) and where under 2,000 files are selected and just the last file name is corrupted:

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

$
0
0

[quote user="Loren"]WCharCP      str;
WChar        filestr[MAXFILELENGTH];
StringList   *strListP;[/quote]

Like you, I thought that MicroStation CONNECT had abandoned 8-bit character strings. I looked up the definition of StringList in the header files. It turns out that we're both wrong  8-(

First, some typedefs: read Bentley's advice note...

#include <Bentley.r.h>

// NB: Do not use WChar/wchar_t to declare stored data.
//     Store strings as UTF-16 or UTF-8.
typedef uint16_t            Utf16Char;
typedef char                Utf8Char;

The StringList definition..

#include <rtypes.r.h>

typedef struct __stringlist__
    {
    UInt32      numInfoFields;
    struct strings
        {
        UInt32      infoFields[];
        Utf8Char    string[];
        } Strings [];
    }  StringList;

So StringList uses 8-bit characters.  Your code, quite reasonably, anticipates 16-bit character strings.  You need to convert the string pointer return by mdlStringList_getMember() from 8-bit to 16-bit.

Viewing all 7260 articles
Browse latest View live


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