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

VBA and Context ACS Coordinates

$
0
0

Hi Members,

We want to automate the creation of multiple Descartes sections along a rail alignment.

I put together the following code which makes use of the point tools keyin to create a quick section. It creates the section ok but the contents are positioned outside the visible extents of the model.

Observing the way the create quick section tool works , it requires only two data points, I supply the first with correct  XYZ and a second point both global XYZ and also with relative coordinates.

Code below shows version with global coordinates for both points.

The Create Quick Section Command changes the ACS to Type - Context after the first point is selected, I think this is my problem.

After trying various methods and searching web and Bentley Forums I cannot progress this.

Here is the VBA Code I am using, It is part of a workflow I produced for V8i, but we are upgrading to Connect so would like it to work in that land as well.

Any feedback would be most appreciated.

Kind Regards

CJM

Sub Create_Sections()
Debug.Print "FileSpec: " & MdlFileOpenDialog_Create_Sections("Select a File with Profile Points", "*.*", "X:\ASSET_DATA_ESN-PCN\02_POINT OUTPUT")
End Sub
Function MdlFileOpenDialog_Create_Sections(sCaption As String, sFileFilter As String, sDefaultDir As String) As String
Const MDLNULL = 0
Const MAXFILELENGTH = 255
Dim rtc As Long, sFileSpec As String
sFileSpec = Space(MAXFILELENGTH)
rtc = mdlDialog_fileOpen(sFileSpec, MDLNULL, MDLNULL, " ", sFileFilter, sDefaultDir, sCaption)
MdlFileOpenDialog_Create_Sections = sFileSpec
If Left(LTrim(sFileSpec), 1) = "X" Then
    mypoints = mySplit(sFileSpec)
    For i = 0 To UBound(mypoints)
        On Error GoTo handler_dimerror
            Dim startPoint As Point3d
            Dim point As Point3d, point2 As Point3d
            Dim lngTemp As Long' mypoints iS array taken from inputing offsets from rail points, whaich are contained in selected file
            If mypoints(i)(0) = "Red" Then'Send a keyin for command string
            CadInputQueue.SendKeyin "pointcloudadv section createquick oriblockbyaxis"
            point.X = Round(mypoints(i)(2), 3)
            point.Y = Round(mypoints(i)(3), 3)
            point.Z = Round(mypoints(i)(4), 3)
            CadInputQueue.SendAdjustedDataPoint point, 5
            point2.X = Round(mypoints(i)(7), 3)
            point2.Y = Round(mypoints(i)(8), 3)
            point2.Z = Round(mypoints(i)(9), 3)
            CadInputQueue.SendAdjustedDataPoint point, 5'Use following to test that points are correct location for sections'            CadInputQueue.SendCommand "PLACE LINE CONSTRAINED"''            point.X = Round(mypoints(i)(2), 3)'            point.Y = Round(mypoints(i)(3), 3)'            point.Z = Round(mypoints(i)(4), 3)'            CadInputQueue.SendDataPoint point, 5''            point2.X = Round(mypoints(i)(7), 3)'            point2.Y = Round(mypoints(i)(8), 3)'            point2.Z = Round(mypoints(i)(9), 3)'            CadInputQueue.SendDataPoint point2, 5'            CadInputQueue.SendReset
            End If
handler_dimerror:
            CadInputQueue.SendReset
    Next i


Else
    Exit Function
End If

CommandState.StartDefaultCommand
End Function

[CONNECT C++] IViewDecoration

$
0
0

Interface IViewDecoration has a single implementable method virtual bool _DrawDecoration (IndexedViewportR viewport)=0.

The return value is a bool, but the MicroStationAPI documentation omits to tell us the meaning of the return value.

[CONNECT .NET ADDIN] Call keyin command

$
0
0

How do I call a keyin command from within a CONNECT .NET C# addin? Trying to set a level transparency property (one of the few level properties not exposed in .net)

disable "No workSet alert"

$
0
0

Hi,

First question, 

Marshal.GetActiveObject("MicroStationDGN.Application") as Application;

how do i specify that i want the connect  edition and not v8i loaded ??
it seems that it loads the last openend version of microstation... ?

Second
When i open a design file i get a alert "No workSet Alert"

is there ANY way to disable this? because my process is halted and waiting for user input.... 

Cheers

[CONNECT C++] Is it possible to mock DgnFiles/Models/Elements in order to unit test mdlapp functionality?

$
0
0

Hello all,

Not sure if this is the best place to ask, so I would appreciate any info or suggestions on this.

Background Info:

I created an mdlapp in C++ that allows a user to click on an element and display an arrow showing the its orientation (using the orientation property from the ISM schema). I now want to write unit tests to test and verify that my getOrientation() method works as expected. This is because the orientation of an element in the ISM schema is represented as an IGeometry struct and needs to be processed in order to get the actual DPoint3d value representing its orientation.

My problem:

I am trying out the testing framework Catch2 (https://github.com/catchorg/Catch2) and am using it to write unit tests for my mdlapp. I want to have these tests run during a build of my mdlapp so that I can always verify my code. My problem is that I'm having trouble trying to set up some mocked or fake objects/data so that I can test my methods and was wondering what's the best way to go about this?

Here's an example of a test in Catch2 (hopefully it's easy to understand):

TEST_CASE("Should return orientation vector of (0, 0, 0) when there is no EC instance data (nullptr)")
    {
    // arrange
    DPoint3d expectedOrientation;
    expectedOrientation.Zero();
    // act
    // method will return orienation of (0,0,0) if first parameter is null
    DPoint3d testOrientation = SmcApi::getOrientationOfElement(nullptr, L"Orientation");

    // assert
    REQUIRE( expectedOrientation.x == testOrientation.x );
    REQUIRE( expectedOrientation.y == testOrientation.y );
    REQUIRE( expectedOrientation.z == testOrientation.z );
    }

This is my getOrientation method which isn't set in stone as I'm open to changing things in order to get it to work:

DPoint3d MyApiClass::getOrientationOfElement(DgnECInstancePtr instance, WCharCP propertyAccessString)
    {
    DPoint3d orientationVector;
    orientationVector.Zero();

    ECValue value;
    ECValueR valueR = value;


    if (instance != nullptr && SUCCESS == instance->GetValue(valueR, propertyAccessString))
        {
        // Get the IGeometry object of the Orientation property
        IGeometryPtr testGetGeo = valueR.GetIGeometry();

        // If the geometry is a CurvePrimitive
        if (testGetGeo != NULL && testGetGeo->GetGeometryType() == IGeometry::GeometryType::CurvePrimitive)
            {
            // Since it is a CurvePrimitive, get the CurvePrimitive
            ICurvePrimitivePtr testCurvePrim = testGetGeo->GetAsICurvePrimitive();

            Bentley::ICurvePrimitive::CurvePrimitiveType testCurvePrimType = testCurvePrim->GetCurvePrimitiveType();

            // If the CurvePrimitive is a Line CurvePrimitive
            if (testCurvePrimType == ICurvePrimitive::CurvePrimitiveType::CURVE_PRIMITIVE_TYPE_Line)
                {

                // Get the line segment of the Line CurvePrimitive
                DSegment3dCP testSegment = testCurvePrim->GetLineCP();

                // Get the start and end points
                DPoint3d start, end;
                testSegment->GetStartPoint(start);
                testSegment->GetEndPoint(end);

                if (start == end)
                    {
                    // Get the orientation vector by normalizing it
                    orientationVector.Normalize(start);
                    }
                else
                    {
                    // Was trying to extend this method for other properties
                    // can ignore this within the context of my question
                    orientationVector = start;
                    }
                }
            }
        }

    return orientationVector;
    }

Some things I tried:

  • That first test case is very simple since I'm just passing in nullptr but now I'm trying to setup my own data with DPoint3d orientations so that I can test my method. In my getOrientationOfElement() method, I pass in a DgnEcInstancePtr and tried to create one from scratch in one of my unit tests but when trying to compile/run it, this fails because of a segmentation fault.
  • I tried to 'create" a DgnFile and loading an existing one following the Microstation API documentation but this also fails with a seg fault. I think this code snippet seg faults at the very first line when trying to create the DgnDocumentPtr as I tried compiling and running it with all the other lines commented out: 
    DgnDocumentPtr dgnDoc = DgnDocument::CreateForLocalFile(L"path\\to\\my\\file.dgn");
    DgnFilePtr dgnFilePtr = DgnFile::Create(*dgnDoc, DgnFileOpenMode::ReadOnly);
    
    //Load the DGN file
    DgnFileStatus dgnFileStatus = dgnFilePtr->LoadDgnFile(&openForWriteStatus);

Questions:

  • Is it possible to access the Microstation API like this without running API? I guess I'm just wondering if it's possible to create the data/objects I need so that I can run my tests during my build of the mdlapp.
    • If yes, I would appreciate any info on what I should be trying
    • If no, does this mean I need to have MicroStation running in order to get this to work?
      • Would it be possible to run MicroStation in the background or anything since I'm trying to run these unit tests as part of a build?

Thanks for taking the time to read all of this. Again, any info on this is greatly appreciated. Thank you!

[CONNECT C++] Tesselation representation for LineStyles

$
0
0

Hi, I am using CONNECT C++ to query linestyles information, but my viewer does not naturally support linestyles.

So I would like to know if there are CONNECT C++ APIs to tesselate a line with linestyles to a bunch of curves?

Thanks.

Some Versions of Microstation not available in fullfillment center. SDK for C++ Microstation API not availiable in fullfillment center

$
0
0

Where can I find MicroStation CONNECT Edition (Full) x64 Update 4 (English) Version 10.04.00.046 and its SDK for C++ MicrostationAPI development in the fullfillment center? I cannot find it. I already tried to press CTRL F5 and deleted all bentley cookies. Best Regards. Thanks for help in advance

IPrimitiveCommand not including Items attached to cells.

$
0
0

I am using MicroStation CE Update 9 and want to programmatically place a cell that has an Item attached using IPrimitiveCommand using VBA, I have the macro working and placing the cells ok, but the cells when placed, do not have the Items attached, is this a bug or do I need to add something else to add the Items. The cell contains the Item when place with the Place Cell command but not using the IPrimitiveCommand process.

Regards,

John Davidson

Class Code.

Option Explicit
Implements IPrimitiveCommandEvents

Private ocell As CellElement
Private Offset As Point3d

Private Sub IPrimitiveCommandEvents_Start()
    Dim Point As Point3d
    Dim PointScale As Point3d
    Dim transform1 As Transform3d
    Dim mView As View
    Set mView = CommandState.LastView
    transform1 = Transform3dFromMatrix3dAndFixedPoint3d(Matrix3dInverse(mView.rotation), Point)
    If ocell Is Nothing Then
        Point.X = 1
        Point.Y = 1
        Point.Z = 1
        GetScale gScale
        PointScale = Point3dScale(Point, gScale)
        Set ocell = CreateCellElement2(ActiveSettings.CellName, Point3dZero, PointScale, 1, Matrix3dIdentity)
        Set ocell.Level = ActiveSettings.Level
        'Rotate cell horizontal to view angle
        ocell.Transform transform1
    End If
    CommandState.StartDynamics
    ShowCommand "Place the RL Label"
    ShowPrompt "Reset to Exit"
End Sub

Private Sub IPrimitiveCommandEvents_DataPoint(Point As Point3d, ByVal View As View)
    Offset = Point3dSubtract(Point, ocell.Origin)
    ocell.Move Offset
    ActiveModelReference.AddElement ocell
    mod_RL_Label.Edit_RL_Item ocell, ocell.Origin
    CommandState.StartPrimitive New clsPlaceRLSymbol
End Sub

Private Sub IPrimitiveCommandEvents_Dynamics(Point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode)
    Offset = Point3dSubtract(Point, ocell.Origin)
    ocell.Move Offset
    ocell.Redraw DrawMode
End Sub

Private Sub IPrimitiveCommandEvents_Reset()
    CommandState.StartDefaultCommand
End Sub

Private Sub IPrimitiveCommandEvents_Cleanup()
    Set ocell = Nothing
End Sub


[CONNECT C++] ReportDefinitionNode::FindByPath

$
0
0

ReportDefinitionNode::FindByPath attempts to find a report definition node given a text path: Locate a report definition by its full path (including category name).  I find that it fails when the category name includes a space.

For example, ReportDefinitionNode::FindByPath (L"CategoryName\\reportName") works but ReportDefinitionNode::FindByPath (L"CategoryName\\reportName") fails.

However, if I create a report definition manually, I can include a space in the report category.  The display name appears to be distinct from the internal name, I guess.  Do I guess correctly?  If so, what do I need to do to translate programmatically the report display name to its internal representation?

Apply Display Rule based on activated Named View

$
0
0

Hey all, fairly new to writing vba and I am trying to think of a way to apply a display rule when a saved view is applied. The display rule and saved view are named the same.

I was trying to write a user form with a combo-box to do this but I am only able to populate things like levels, cells (training docs) and active file name. Any ideas on how to get the combo box to populate all the saved views available in the active model? I guess after that would be to select one and then select a go button to active the saved view and the display rule based on the same name. I thought tweaking the existing training document would work but I just cant get past the population of the combo box. I cannot post the training data as it is Bentley copyright protected but I bet some of you already have this documentation.

Mark W.

How to get the current active(open) document from Microstation CE?

$
0
0

Hi Experts,

     I am now have a addin for Microstation CE, and the addin will get loaded when user open a dgn file, now i want to get the current open/active document/model, which api should i used to get it?

thanks,

Rick

[CONNECT U8] FenceManager Class

$
0
0

Trying to utilize the FenceManager class, but the compiler complains about "use of undefined type 'Bentley::DgnPlatform::FenceManager'

#include <DgnPlatform\FenceParams.h>

...
		FenceManagerR		fenceMgr = Bentley::DgnPlatform::FenceManager::GetManager();

Is this because I'm doing this wrong, or is it just not part of the U8 API? Inside DgnPlatform.h, the type is declared as

DGNPLATFORM_TYPEDEFS (FenceManager)

Bruce

Getting user Selection with CadInputQueue.SendCommand

$
0
0

Hi all,

I am trying to build a macro that intersects a given solid with a set of contiguous smart solids.

This is where i am so far :

Sub Macro1()
    Dim oScanEnumerator As ElementEnumerator
    Dim cSmartSolidEnum As ElementEnumerator
    Dim SmartEl As SmartSolidElement
    Dim oscancriteria As New ElementScanCriteria
    Dim lngTemp As Long
    Dim startPoint As Point3d
    Dim point As Point3d, point2 As Point3d
    oscancriteria.ExcludeAllTypes
    oscancriteria.IncludeType msdElementTypeCellHeader
    Set oScanEnumerator = ActiveModelReference.Scan(oscancriteria)
    Do While oScanEnumerator.MoveNext
        If oScanEnumerator.Current.IsSmartSolidElement Then
            Set SmartEl = oScanEnumerator.Current.AsSmartSolidElement'   Start a command
    CadInputQueue.SendCommand "CONSTRUCT INTERSECTION"'   Set a variable associated with a dialog box
    SetCExpressionValue "tcb->ms3DToolSettings.smartSolid.solid.intKeep", 2, "3DMODIFY"'   Coordinates are in master units
    startPoint.X = 184462.113246156
    startPoint.Y = 399897.885906432
    startPoint.Z = 100.254825999181'   Send a data point to the current command
    point.X = startPoint.X
    point.Y = startPoint.Y
    point.Z = startPoint.Z
    CadInputQueue.SendDataPoint point, 1'   Send a data point to the current command
    point.X = SmartEl.Origin.X
    point.Y = SmartEl.Origin.Y
    point.Z = SmartEl.Origin.Z
    CadInputQueue.SendDataPoint point, 1
     End If
Loop

    CommandState.StartDefaultCommand
            

End Sub

The first data point of the command will be selected by the user(This is where i want the solid to be selected by the user) then the macro continues intersecting every smart solid in the loop with the selected one.

Any help on how to get the solid from the user then store it for use in the command ? (In this macro i just used the recorded coordinates of the solid's data point since i still haven't figured out this step yet.)

Also, when executed the macro goes through the smart solids and seems to be executing the command for each one of them but the elements remain the same at the end nothing changed. What am i missing ?

Thank you.

Best regards,
Kal

{CONNECT C++] DgnElementSetTool and the use of Fences/Selection Sets

$
0
0

I'm writing a DgnElementSetTool that (I hope) will support Fences and Select Sets. I am not seeing the _OnRestartTool() function being called when using a Fence or Selection Set. I've got _WantDynamics()=false for both, as well as _NeedAcceptPoint()=false. When I test the tool using a Fence or Selection Set, I see the calls into _OnElementModify() for each element, but I never see _OnRestartTool() being used. Once the tool process the elements thru _OnElementModify(), it goes into the ElementSelection tool. I guess this is OK for what I'm doing now, but is what I'm observing the expected behavior?

Bruce

[C# MicroStation v8i ss3] Create a table

$
0
0

Hello everyone,

        I want to create a table programmatically in Microstation v8i ss3.

 My software is vs2015 and the programming language is C#.

The content of the form is taken from the user-defined attributes. How can I implement this function?

 It is best to use the VBA method and be grateful for your generous response.


[Connect C++]How to distinguish display order for elements with same display priorities

$
0
0

I believe this is a general API question that can be asked here, and if not please let me know.

Here is the element display priority information copied from the help document: 

  • All elements in a reference with a higher Reference Display Priority will appear in front of all elements from references with a lower value.
  • Within a single model, or from references with the same reference display priority, elements on levels with higher Level Display Priority will appear in front of those with a lower value.
  • Where elements have the same reference and level display priority, then Element Display Priority determines those that will appear in front of others.
  • Where two elements have the same Reference, Level, and Element display priorities, then the one that appears later in the display order (that is, file position and update sequence) appears on top.

One issue I am not clear is the last statement marked with red color. I have created a model without setting priority (Means all elements inside the model priority is default value 0, no reference, no level priority). In this case, how can I use API to distinguish the display order? I used several ways:

1. implement _EachDisplayPriorityCallback for IQueryProperties interface.

2. call MSElementCP->hdr.dhdr.priority;

All return priority values for below elements are 0, so it can't be distinguished simply by priority values. Any suggestions?

Thanks,

Danny

Microstation Connect debugging using VS2015

$
0
0

Hi,

I have been trying to debug one of the example code in Microstation CONNECT 10.08.00.37 using Visual Studio 2015 Community Edition.  Is there any documentation on how to go about doing this.  Every document I find either is for 8i or a different version of Visual Studio.  I can't seem to be able to even locate where to specify to Visual Studio about the location of the DLL.  I also find that it needs the location of the pdb file (in the mdlApps folder).  It would be nice for Bentley to create a documentation which which outlines the whole debug process.

If anyone has this info, I would greatly appreciate it.

Thanks.

【MSTN V8i Addin C# 】How to get all the elements in the model?

$
0
0

Hello everyone:

         How to get all the elements in the model, I use the Scan method in the VBA interface but it did't work.

         Is my code wrong or there are other ways to get the elements in the model?

public void Dynamics(ref Point3d Point, BCOM.View View, MsdDrawingMode DrawMode)
{
            Element element;
            ElementEnumerator oScanEnumerator = app.ActiveModelReference.Scan();
}

When I use the above code to get the element, oScanEnumerator doesn't have any value.Thanks for any ideas.

[V8i C++] Problems with "On the fly" cell creation and Annotation Scale

$
0
0

Hi all,

I want to create some cells "On the fly" and set the Annotation Scale.

I've tried to follow the guidelines in this thread: 

https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/83654/v8i-c-on-the-fly-cell-creation-and-annotation-scale/234571

Based on this I've now got these lines:

mdlCell_setIsAnnotation(pedCellElm, TRUE);

TransformInfo addAnnotationScale;

addAnnotationScale.SetOptions(TRANSFORM_OPTIONS_AllowSizeChange | TRANSFORM_OPTIONS_ApplyAnnotationScale);
addAnnotationScale.SetAnnotationScaleAction(ANNOTATIONSCALE_ADD);
addAnnotationScale.SetAnnotationScale(mdlModelRef_getEffectiveAnnotationScale(mdlModelRef_getActive()));
EditElemHandle eeh(pedCellElm, true, false);
eeh.GetHandler().ApplyTransform(eeh, addAnnotationScale);

My problem is that MicroStation crashes in the last line (ApplyTransform)

What am I doing wrong ?

Regards, Evan

[Connect C#] element.ReplaceInModel does not work in update 9

$
0
0

Hi experts:

I use the following code to modify the cellheadelement's cellname property. it works well in update8 but give a crash in update 9, the statueInt is 32768. any changes or my code's issue, Please help me.

(element as CellHeaderElement).CellName = CellName;
StatusInt statusInt= element.ReplaceInModel(element);
Viewing all 4331 articles
Browse latest View live


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