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

[CONNECT C++] WhereCriterion::CreateRegexFilter

$
0
0

WhereCriterion::CreateRegexFilter () accepts a regular expression to create a filter.  Is it safe to assume that the RegEx engine is that supplied by C++ 11 <regex>?


Microstation V8i get tags element crushes Excel macro

$
0
0

Hi,

I have been trying to write an Excel VBA macro which:

1. opens all .dgn files from selected location

2.scans for all cell elements in active model

3. builds an array with found cells

4. checks if cells have tags

5. if 4 true then builds arrays with tag elements for each cell

The code below works fine until I try to access any array with tag elements. Any operation like reading or writing of any tag element array causes Excel crash every time. Excel stops working and restarts with any other error message. The tag element arrays are created correctly because I can see them in watch window while I stop program before the "crashing" program line. There are some suspicious value in the tag element array like "Subtype- attempting to perform a non-graphical operation on graphical element". Any help would be appreciated.

Thanks,

Darius

Option Explicit
Dim directory As String, fileName As String

Sub ImportStart_Click() 'PROGRAM START
  ExportTexts
End Sub

Sub ExportTexts()
'On Error Resume Next
directory = GetFolder("c:\") & "\"
fileName = Dir(directory & "*.dgn")
Do While fileName <> ""
    obslugaDGN (directory & fileName)
    fileName = Dir
Loop
MsgBox "Done", vbOKOnly
End Sub

Sub obslugaDGN(plik As String)
Dim myDGN As DesignFile
Dim oAL As ApplicationObjectConnector
Set oAL = New MicroStationDGN.ApplicationObjectConnector
Set myDGN = oAL.Application.OpenDesignFile(plik, False)
Dim ee As ElementEnumerator
Dim es As ElementScanCriteria
Dim elArray() As element
Dim i, j As Integer

Set es = New ElementScanCriteria
es.ExcludeAllTypes
es.IncludeType msdElementTypeCellHeader
es.IncludeType msdElementTypeSharedCell
Set ee = ActiveModelReference.Scan(es)

elArray = ee.BuildArrayFromContents

For i = LBound(elArray) To UBound(elArray)
    If (elArray(i).HasAnyTags) Then
        Dim oTags() As TagElement
        oTags = elArray(i).GetTags()
        For j = LBound(oTags) To UBound(oTags)
            If oTags(j).TagDefinitionName = "TAG" Then  'here Excel stops working and restarts'procedure....
            End If
        Next j
    End If
Next i
myDGN.Close
Set myDGN = Nothing
Set ee = Nothing
End Sub


Function GetFolder(strPath As String) As String ' function gets folder picked by user
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
    .Title = "Select a Folder"
    .AllowMultiSelect = False
    .InitialFileName = strPath
    If .Show <> -1 Then GoTo NextCode
    sItem = .SelectedItems(1)
End With
NextCode:
GetFolder = sItem
Set fldr = Nothing
End Function

[CONNECT C++] WhereCriterion::CreateNumberFilter

$
0
0

Method WhereCriterion::CreateNumberFilter takes a string filter.  Presumably that string must be a number in text form (e.g. L"1234.56")?

Can it also include a comparison operator (e.g. L"< 1234.56") or should that be supplied separately using CreateComparison()?  If the latter, how should we compose or link together CreateNumberFilter and CreateComparison?

[connect c++] Example circuit mdlCnv_bufferToFileFormat error

$
0
0

Hello,

I'm migrating a v8i App to connect.

My App is using a Typ 66 Element to store information in the dgn.

The connect example circuit is using the same function.

mdlCnv_calcFileSizeFromDataDef + mdlCnv_bufferToFileFormat

I have compiled the circuit example, but the function mdlCnv_bufferToFileFormat returns the error code -1103 (mdlCnv_bufferToFileFormat).

Is there something wrong in the example?

Best Regards

Martin

MicroStation Connect 10.6.0.38 (Update 6)

SDK (mssdk10060040en)

Using scan criteria on selected elements only

$
0
0

I've been creating a tool in vba to quantify the bid items for construction drawings. Basically, it counts things and does some math. I can get the tool to work in the basic case, which is to scan all elements in the file, but I am trying to create an option to scan only selected items. I could not figure out how to scan only within a selection set. I eventually opted to create a named group with the selected items hoping to utilize the msdElementTypeNamedGroupComponent in scan criteria, but that does not work. Any guidance into using msdElementTypeNamedGroupComponent or scanning within a selection set would be helpful. I've included a simplified version of my code (as is) below:

 Sub main()
    Dim nCells As Integer
    Dim nArrows As Integer
    Dim nBikes As Integer
    Dim nOnlys As Integer
    Dim nSchoolSMs As Integer
    Dim nSchoolLGs As Integer
    Dim nXings As Integer
    Dim nCrossings As Integer
    Dim nRRs As Integer
    Dim nNRRs As Integer
    Dim nBRRs As Integer
    Dim nHOVs As Integer
    Dim nBus As Integer
    Dim nCattles As Integer
    Dim nHCs As Integer
    Dim npark As Integer
    Dim nylds As Integer
    Dim nXwalk As Integer
    Dim groupname As String
    Dim mygroup As NamedGroupElement
    Dim ee As ElementEnumerator
    Dim n As Integer
    n = 0
    Const levName As String = "P_TRAF_ROAD_LEGENDS"
    Select Case True
        Case ActiveModelReference.AnyElementsSelected
            Debug.Print "TRUE"
            groupname = "Selected"
            Set mygroup = ActiveModelReference.GetNamedGroup("Selected")
            If (mygroup Is Nothing) Then
                Set mygroup = ActiveModelReference.AddNewNamedGroup(groupname)
                Debug.Print "set new group"
            Else
                ActiveModelReference.RemoveElement mygroup
                Set mygroup = ActiveModelReference.AddNewNamedGroup(groupname)
                Debug.Print "Didn't work"
            End If

            Set ee = ActiveModelReference.GetSelectedElements

            Do While ee.MoveNext
                n = n + 1
                mygroup.AddMember ee.Current
            Loop
            Debug.Print n
        Case Else
            groupname = "none"
    End Select
    mygroup.Rewrite

    nCells = CountCells(levName, nArrows, nBikes, nOnlys, nSchoolSMs, nSchoolLGs, nXings, nCrossings, nRRs, nNRRs, nBRRs, nHOVs, nBus, nCattles, nHCs, npark, nylds, nXwalk)
    Debug.Print nCells
    'Debug.Print "Arrow: " & arrowcount & "; Bike Stencil: " & bikecount & "; Onlys: " & nOnlys & "; SM Sch: " & schoolSMcount & "; LG Sch: " & schoolLGcount & "; X-ing: " & nXings & "; Crossing: " & nCrossings & "; RR: " & nRRs & "; Narrow RR: " & nNRRs & "; Bike RR: " & nBRRs & "; HOV: " & nHOVs & "; BUS: " & nBus & "; Cattle: " & nCattles & "; Handicap: " & nHCs & "; Parking: " & npark & "; Yields: " & nylds & "; Sq Ft CW: "; nXwalk'MsgBox "Found " & nElements & " elements, measuring " & Format(outcome, "###,##0.00") & " feet of elements with that linestyle.", vbInformation Or vbOKOnly, "Scanned Elements"
End Sub' --------------------------------------------------------------' Get Counts of Cells' --------------------------------------------------------------
Function CountCells(ByVal levName As String, _
ByRef nArrows As Integer, ByRef nBikes As Integer, ByRef nOnlys As Integer, ByRef nSchoolSMs As Integer, ByRef nSchoolLGs As Integer, ByRef nXings As Integer, ByRef nCrossings As Integer, ByRef nRRs As Integer, ByRef nNRRs As Integer, ByRef nBRRs As Integer, ByRef nHOVs As Integer, ByRef nBus As Integer, ByRef nCattles As Integer, ByRef nHCs As Integer, ByRef npark As Integer, ByRef nylds As Integer, ByRef nXwalk As Integer) As Integer
    Dim pos As Integer
    Dim olevel As Level
    Set olevel = ActiveModelReference.Levels("P_TRAF_ROAD_Legends")
    Dim olevel2 As Level
    Set olevel2 = ActiveModelReference.Levels("P_TRAF_ROAD_Striping")
    Dim nCells As Integer
    nBikes = 0
    nArrows = 0
    nOnlys = 0
    nSchoolSMs = 0
    nSchoolLGs = 0
    nXings = 0
    nRRs = 0
    nNRRs = 0
    nBRRs = 0
    nHOVs = 0
    nBus = 0
    nCattles = 0
    nHCs = 0
    npark = 0
    nylds = 0
    nXwalk = 0'   Set up scan criteria
    Dim oScanCriteria   As New ElementScanCriteria
    oScanCriteria.ExcludeAllLevels
    oScanCriteria.IncludeLevel olevel
    oScanCriteria.IncludeLevel olevel2
    oScanCriteria.ExcludeAllTypes'oScanCriteria.IncludeType msdElementTypeCellHeader
    oScanCriteria.IncludeType msdElementTypeNamedGroupComponent
    oScanCriteria.IncludeType msdElementTypeNamedGroupHeader'   Perform the scan
    Dim oEnumerator     As ElementEnumerator
    Set oEnumerator = ActiveModelReference.Scan(oScanCriteria)
    Do While oEnumerator.MoveNext
        nCells = nCells + 1
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "BIKE")
        If pos > 0 Then
            nBikes = nBikes + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "SHARED")
        If pos > 0 Then
            nBikes = nBikes + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "ARROW")
        If pos > 0 Then
            nArrows = nArrows + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "ON")
        If pos > 0 Then
            nOnlys = nOnlys + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "SCH")
        If pos > 0 Then
            pos = InStr(oEnumerator.Current.AsCellElement.Name, "SCH-LG")
            If pos > 0 Then
            nSchoolLGs = nSchoolLGs + 1
            Else
            nSchoolSMs = nSchoolSMs + 1
            End If
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "CROSSING")
        If pos > 0 Then
            nCrossings = nCrossings + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "XING")
        If pos > 0 Then
            nXings = nXings + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "RAILROAD_RR")
        If pos > 0 Then
            nRRs = nRRs + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "RAILROAD_NRR")
        If pos > 0 Then
            nNRRs = nNRRs + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "RAILROAD_BRR")
        If pos > 0 Then
            nBRRs = nBRRs + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "HOV")
        If pos > 0 Then
            nHOVs = nHOVs + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "CATTLE")
        If pos > 0 Then
            nCattles = nCattles + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "HC")
        If pos > 0 Then
            nHCs = nHCs + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "PLUS")
        If pos > 0 Then
            npark = npark + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "TEE")
        If pos > 0 Then
            npark = npark + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "YLD")
        If pos > 0 Then
            nylds = nylds + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "BUS")
        If pos > 0 Then
            nBus = nBus + 1
        End If
        pos = InStr(oEnumerator.Current.AsCellElement.Name, "CW_SC")
        If pos > 0 Then
            nXwalk = nXwalk + 18
        End If'Debug.Print oEnumerator.Current.AsCellElement.Name & " " & pos
    Loop
    CountCells = nCells
End Function

[CONNECT .NET] PolyfaceBuilder

$
0
0

The documentation for PolyfaceHeader.AddPolygon has this comment: Add a polygon by direct coordinatees. Implementation is NOT required to detect duplicates. (Use a PolyfaceBuilder !!!) 

I can't find PolyfaceBuilder anywhere in the documentation.  Does it exist?

Bentley Products and External Databases

$
0
0

I am curious as to how Bentley supports an external database when it is deemed to be needed.

Noticed that ProjectWise, Promis-e, SewerGEMS, Bentley Facilities, BRCM and Openplant etc make use of SQL Server. Aecosim Electrical makes use of MS Access for some things.

But, PLANSTUDIO's Progenio seems to use SQL Server and AB_DATE appears to have come up with their own version of Aecosim's DataGroup System.

It seems curious that a vertical developer would need to develop something that does the nearly same thing already in a Bentley product. Can't be good if you are trying to grow an ecosystem.

1. Is there an API for DGS? or the Trifoma Family and Parts system which Aecosim uses for display/symbology. I suppose they will be both eventually replaced by Item Types and Element Templates at platform level... and potential developers will be able to avoid having to roll their own and focus on their domain-related code.

2. ODBC MSLINK, UDL etc seems pretty limited. Comms via OLE, ADO also seems tenuous and probably too slow for a lot of purposes. What about Bentley's investment in SQLite? Will all those Bentley devs hunkered down in their garages switch to the Secret Sauce and provide the beginnings of an SDK (both C# and C++) for general use? SQL Server is apparently expensive, so SQLite to start with would be good for kickstarting apps? Bentley's hydraulic verticals seems have taken this step.

I like the fact that most of SQLite's code is for testing. Anyone who is developing apps on top of that must be re-assured. Maybe, Bentley should also sell itself to potential developers as having the best debugging and performance profiling tools?

 3. Bentley's 'federated' file-based appoach to handling and storing data has served it well. But, I think the increasingly data-centric needs in the BIM market place seems to point to the need for database support... at all levels. See ShipConstructor's DDROM, Openplant's ModelServer and Bentley Facilities. Progenio also highlights the PDM aspects that intelligent manufacturing will require... that will require big database tools.

4. It would also enable future 'companion' app combos and re-use. Look at Aecosim, Speedikon and Prostructures.  They all have tools for generating steel members, but save their information using different systems. This must be expensive to support, and pointless.

[CONNECT C++] mdlDialog_fileOpen and friends: when is a bool an int?

$
0
0

 mdlDialog_fileOpen(), mdlDialog_fileCreate() and the like return an integer to indicate what the user clicked.  When MDL had a BoolInt #defined, this three-state result made some sort of sense:

TRUE if the CANCEL button is pressed, FALSE if the OK button is pressed, and ERROR if an error occurred while the Dialog Box was being created.

These days, those functions return an int.  This MicroStationAPI documentation comment makes less sense, at least to those of us who consider bool to have only two values...

true if the CANCEL button is pressed, false if the OK button is pressed, and ERROR if an error occurred while the Dialog Box was being created.

I make this point because the following code snippets may work differently, depending on how the C++ compiler interprets the integer values of true and ERROR...

// Order false, true, ERROR
int result = mdlDialog_fileSomething ();
switch (result)
{
  case false:
  //OK
  break;
  case true:
  break;
  case ERROR:
  break;
}
// Order false, ERROR, true
int result = mdlDialog_fileSomething ();
switch (result)
{
  case false:
  //OK
  break;
  case ERROR:
  break;
  case true:
  break;
}

If user cancels the file open/close dialog, or an error occurs while creating the dialog, what line in the switch statement is reached?


Microstation Connect

$
0
0

Hi Everyone,
I have an MDL that was made for older versions of Microstation before Connect and I want to build it to work with Microstation Connect.
Please provide me the link to download the connect sdk and would like to know the command to compile
Additonally, I have very little experience with MDLs and I did not make the one I am trying to upgrade so that makes this even tougher for me.

[CONNECT C++] mdlLevelList_handleLevelNameSetState

$
0
0

The documentation for the mdlLevelList_handleLevelNameSetState() function is muddled.  The function is declared void, yet the documentation has this …

Returns a list model pointer of level names.

There's also this comment …

Use this function if using the ~?mdlLevelList_getLevelNamesListModel function.

With no further explanation. When is it appropriate to call that function? In a hook function _SETSTATE event handler?

I'm also uncertain how to pronounce ~?.

[CONNECT C++] DataSheet Example

$
0
0

I've updated Mark Anderson's DataSheet project for CONNECT.

DataSheet shows how to create cell editors that modify a ListModel displayed in a ListBox.  Each of five columns uses a different editor:

  • simple text
  • combo box
  • binary choice
  • color chooser
  • level chooser

I've replaced the MDL hook functions with hook handler classes that inherit from DialogItemHandler.  Those handler classes help to simplify the spaghetti code that you may recall, or prefer to forget, from your days of MDL programming.  You can download the complete project: it includes source code and a bmake file.

Importing Excel data into Microstation

$
0
0

Hi,

I want to build an application that imports data into MicroStation from an excel file. The data should be imported  in the form of MicroStation elements(not as an image like in case of Paste/Special Paste). The data should maintain to the input excel,so that if there are any updates in the input file, they are reflected back into MicroStation.

Please do not suggest any related Product.

Any help is appreciated!

Thanks.

VBA itemtype

$
0
0

Hey all,

I try to write a macro and the problem is: the run time error 451.

I’m an absolute beginner in vba in microstation. I need your help.

So, I got a dgn file (3D) made by ORD 10.01.00.15. I added extra properties by using “Item Types”.

“Objetosc2” stands for volume of element.

Next step is to find every mesh in model and copy its value of volume and paste it Objetosc2.

This is my code:

 

Sub ScanForElemsv2()'g_10.51
Dim oEnumerator As ElementEnumerator
Dim oScanCriteria As New ElementScanCriteria
Dim ee As ElementEnumerator
Dim l() As String
Dim found As Boolean

Set ee = ActiveModelReference.GraphicalElementCache.Scan
Do While ee.MoveNext

    If ee.Current.Type = msdElementTypeMeshHeader Then

        Set oProp = CreatePropertyHandler(ee.Current)

        ' All out by name:
        l = oProp.GetAccessStrings

        found = False
        For i = LBound(l) To UBound(l)
            Debug.Print l(i)   ' Lists all names in the VBA EDitor
            If l(i) = "Volume" Then found = True'GoTo ziomski
        Next'ziomski:
        If found Then
            oProp.SelectByAccessString("NowaVolume2") = l
        End If
    End If
Loop

End Sub

Any advice?

Regards

Paweł

VBA application.ontime

$
0
0

Hey guys,

Do you know how works application.ontime in vba microstation? I got problem with it.

I added "Excel ...." in Tool/ References.

Example:

Sub macro1()'do sth

End Sub

Sub macro2()
TimeT=Now + TimeValue("00:00:01")
Application.onTime TimeT, "macro1"
End Sub

Compilation stops in Line: "Application.onTime TimeT, "macro1""

I have never had problem with Application.OnTime in Excel.

Regards,
Paweł

CONNECT: The use of ItemTypes in stead of Tags

$
0
0

Hi all,

I have often used tags in V8i in combination with C# or mVBA (create taglibrarys, tagsets, tags). With CONNECT is it recommended to use Item Types. I want to create (with a C# add-in) my own ItemType library with its own ItemTypes and properties to attach this to an element. In the MicroStation CONNECT SDK there are some examples (eg DGNECExample), but not easy to understand. On the internet I didn't found much that helps me further.

So my question is: why should I use ItemLibrarys as the only advantage (for me) is that in the (far) future Tags go out? By then, there will be hopefully more and user-friendly documentation...;-)

Whta do you think?

Regards, Aart

Map Enterprise V8i SS4, Decartes Connect Edition Update 2 (10.02.00.22), Visual Studio 2015 C#


MDL using C++code convert to .mke file etc.

[CONNECT C++] MicroStationAPI BeFileName Recursive Documentation

$
0
0

I got stuck in an endless loop again …

BeFileName.h File Reference

Go to the source code of this file.


BeFileName.h

Go to the documentation of this file.

[CONNECT C++] Item Types Report Integration

$
0
0

I've persuaded AreaAnnotator™ to create searches and aggregate reports...

Behind that dialog are some EC queries that gather information from DGN elements that have Item instance data.  Independently of that dialog we can create an Item Type report based on those same instances.  Right now there's no connection between the calculated aggregates and the Item Type schema.  I'm looking for suggestions about how I might feed those aggregate measurements into a report.  Do I need to create another schema for aggregates, attach Item instances to a DGN element (but what DGN element?), then link to the report?

using mdlAssoc_createLinear to create an assocPoint to associate with line element in the reference file

$
0
0

I am creating an dimension element. The inserted points  associate with start and end point of the line element  in the reference file. When I use mdlAssoc_createLinear to create an assocPoint,it fails. I have tested if the line element is in the activemodel,it always successes. The code is as follows:

                    EditElemHandle eeh(edP,true,false);
                    DPoint3d startPt;
                    DPoint3d endPt;
                    mdlElmdscr_extractEndPoints(&startPt,NULL,&endPt,NULL,edP,eeh.GetModelRef());
                    DisplayPathP path = mdlDisplayPath_new(eeh.GetElemRef(),eeh.GetModelRef());
                    AssocPoint point1;
                    if (SUCCESS == mdlAssoc_createLinear(&point1,&startPt,0,0,0,path,0))
                    {
                        printf("SUCCESS\n");
                    }
                    else
                    {
                        printf("UNSUCCESS\n");
                    }

How to read Number of ED fields in the Text C# .Net

$
0
0

How to read Number of ED fields in the Text C# .Net. while reading am getting text alone ED fields are missing while reading text. for examlpe _ _ _ 10, while reading am getting only 10. ED fields _ _ _ are missing.

ile reading this text my getting only . ED fields are m issing. How to read this ED fields as well  in .NET, C#.

if (oEl.Text != string.Empty)
            {
                DgnText Text = new DgnText();
                Text.Origin = oEl.get_Origin();
                Text.strText = oEl.Text;
                Text.Judification = oEl.TextStyle.Justification;
                double dsize; double dHeight;
                oEl.GetTotalTextSize(out dsize, out dHeight);

                Text.Height = dHeight;
                Text.isUnderLined = oEl.TextStyle.IsUnderlined;
                MicroStationDGN.Matrix3d Shapepts = oEl.get_Rotation();

                if (Shapepts.RowX.X == -1 || Shapepts.RowX.Y == -1 || Shapepts.RowY.X == -1 || Shapepts.RowY.Y == -1)
                    Text.Rotation = 90;
                else
                    Text.Rotation = 0;

                DgnTexts.Add(Text);
            }
Viewing all 7260 articles
Browse latest View live


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