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

IF-THEN-ELSE Step 2

$
0
0

I have a working IF-THEN-ELSE, could I request a little help on the messages in the msgbox I have read and read thought they wanted 

ASCII Chr 13 in the help file I saw (Chr(*)) thevalue for ascii 13 which when I use Alt numeric 13 I get the question Mark I am attaching the working code and a few ways I tried the Message to get more in the box. I have learned about the 0 - 5 and the options it gives.

The first code works, not message box like I want with 3 lines. Then next section of code is what I have tried and failed on

Loosing a lot of time if I could get someone in the know to help. Tried from 12:18am to 3:47am finally got the IF then working

but could never get the message Box.

Private Sub SeletRoutine()' 050419 - This is working need to know how to enter multi-Line Message____________________________________RJB
Dim Message, Title, Default, ValSel

ShowStatus "              "
Title = "Enter Selection to RUN"    ' Set title. 060419 Modified_______RJB
Message = "Enter a value between 1 and 3"    ' Set prompt.'Message = "Selection 2 Set View Attributes "    ' Set prompt.
Default = "1"    ' Set default.
ValSel = InputBox(Message, Title, , , , "DEMO.HLP", 10)' Display message, title, and default value.

If ValSel = 1 Then
      'MsgBox "User pressed Yes!"
      ShowStatus " 1 was selected"
   ElseIf ValSel = 2 Then'MsgBox "User Pressed No!"
      CadInputQueue.SendKeyin "Macro SetDesignFileView"
      ShowStatus "View Set w=985 H=723"
    ElseIf ValSel = 3 Then'MsgBox "User Pressed No!"
            ShowStatus "3 was selected"
   Else'MsgBox "User Pressed Cancel!"
      ShowStatus "Cancel was selected"
   End If

End Sub

Private Sub Selections()' 060519 - Trying again
Dim Message, Title, Default, ValSel
    Title = "InputBox Select Feature:    'Set title."'Message = "Enter 1 for yellow Magenta ? Enter 2 for green magenta.? Enter 3 for Cyan Magenta?"'Message = "Enter a value between 1 and 3?", 2 "Second row of questions"    ' Set prompt. this failed
    Message = "Enter 1 for yellow Magenta ?',(Chr(?)), "Enter 2 for green magenta.?",(chr(?)), "Enter 3 for Cyan Magenta?"

THE ABOVE SECTION IS WHERE I WAS TRYING TO SET THE MESSAGE BOX INFORMATION
Above code is another working macro. Did not want to mess it up 
so started another with different name. Trying to figure out a multi-line message box

[V8i] AreaAnnotator Area formatting

$
0
0

Question for Jon

I recalled downloading this years ago and have configured it for use tonight. I don't want to use the sqm formatting however I notice that upon changing the area formatting variable to ANNOTATOR_FORMAT_AREA= Area %.0lf m² , this displays as the following undesirable result in a dgn file. Is there anyway to avoid the character before the squared symbol?

OpenBuilding Designer SDK available to download

$
0
0

As a BDN member, has the SDK for OpenBuilding Designer been released for download?

[CE] How to debug or log ribbon definition evaluation process?

$
0
0

Hi,

ribbon content, structure and layout can be defined in several different ways (using GUI and stored in dgnlib, in XML or compiled to .rsc format).

Especially when visbility expressions are defined e.g. using Named Expression(s), it's very simple to make a mistake. In such situation it requires a huge amount of time to discover what is wrong, especially when configuration is good enough that ribbon components are displayed, but expressions are not evaluated (se evaluated as false).

Is there any way how to debug or display / write to file a log, how the ribbon data structure is built and how and in what order individual definitions are read and evaluated?

With regards,

  Jan

[CE U12] How to "unset" AccuDraw LockAngle programmatically?

$
0
0

In my tool, I use AccuDraw::GetInstance().SetContext() to enable an angle lock (ACCUDRAW_LockAngle) at various angles, depending on user tool settings. I have one particular case however, where I need to "remove" that angle lock. In the dynamics function, I use:

				AccuDraw::GetInstance().SetContext((AccuDrawFlags)(ACCUDRAW_LockAngle), nullptr, nullptr, nullptr, nullptr, &angle, nullptr);

where "angle" is the desired lock angle for AccuDraw. I have tried to disable the angle lock by doing this:

				AccuDrawFlags			accuDrawFlags;
				memset(&accuDrawFlags, 0, sizeof(AccuDrawFlags));
				AccuDraw::GetInstance().SetContext(accuDrawFlags, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);

but it has no affect - the angle lock remains. Any recommendations on how to free that Angle Lock? Is my only option to totally deactivate AccuDraw?

Thanks,

[CONNECT C#] DgnECManagedCrudExample

$
0
0

The DgnECManagedCrudExample delivered with the SDK has a redundant variable.

private List<string> m_allSchemas;

m_allSchemas is initialised in the constructor but subsequently never used.  Please remove from that example.

[Connect C#] How to iterate through child elements of a SharedCellElement?

$
0
0

My code so far:

		private StatusInt Process(SharedCellElement sharedCell)
		{
			if (sharedCell == null)
			{
				throw new ArgumentNullException(nameof(sharedCell));
			}

			Debug.WriteLine($"sharedCell.GetChildren().Count() => {sharedCell.GetChildren().Count()}");
			Debug.WriteLine($"sharedCell.ExposeChildren() => {sharedCell.ExposeChildren(ExposeChildrenReason.Query)}");
			Debug.WriteLine($"sharedCell.GetChildren().Count() => {sharedCell.GetChildren().Count()}");

			// sharedCell.GetChildren().Count() => 0
			// sharedCell.ExposeChildren() => False
			// sharedCell.GetChildren().Count() => 0

			CellQuery cellQuery = sharedCell.AsCellQuery();
			Debug.WriteLine($"cellQuery.GetChildren().Count() => {cellQuery.GetChildren().Count()}");
			Debug.WriteLine($"cellQuery.ExposeChildren() => {cellQuery.ExposeChildren(ExposeChildrenReason.Query)}");
			Debug.WriteLine($"cellQuery.GetChildren().Count() => {cellQuery.GetChildren().Count()}");

			// cellQuery.GetChildren().Count() => 0
			// cellQuery.ExposeChildren() => False
			// cellQuery.GetChildren().Count() => 0

			SharedCellQuery sharedCellQuery = sharedCell.AsSharedCellQuery();
			Debug.WriteLine($"sharedCellQuery.GetChildren().Count() => {sharedCellQuery.GetChildren().Count()}");
			Debug.WriteLine($"sharedCellQuery.ExposeChildren() => {sharedCellQuery.ExposeChildren(ExposeChildrenReason.Query)}");
			Debug.WriteLine($"sharedCellQuery.GetChildren().Count() => {sharedCellQuery.GetChildren().Count()}");

			// sharedCellQuery.GetChildren().Count() => 0
			// sharedCellQuery.ExposeChildren() => False
			// sharedCellQuery.GetChildren().Count() => 0

			bool hasChildren = false;

			foreach (Element childElement in sharedCell.GetChildren())
			{
				hasChildren = true;

				Process(childElement);
			}

			return hasChildren ? StatusInt.Success : StatusInt.Error;
		}

[CONNECT C#] Get Item Type Schema

$
0
0

My goal is to collect instances of a given Item Type in a DGN model.  To achieve that I must first get an EC schema from the active DGN file or model.  My attempts in C# fail...

FindInstancesScope scope = FindInstancesScope.CreateScope(Session.Instance.GetActiveDgnModel(), new FindInstancesScopeOption ());
IECSchema schema = DgnECManager.Manager.LocateSchemaInScope(scope, schemaName, 1, 0, SchemaMatchType.Latest);

schemaName is something like MasterPlanner, where MasterPlanner is the name of an Item Type library defined in the active DGN file. What am I doing wrong?


[V8i VBA] Reassign Default ModelReference?

$
0
0

I have written a project which automates the creation of Sheet Models in a sheet seed file however in the projects current state, the user must have open the DGN file in which the sheet models are to be created (this I intend to change in due course once all other functionality is working as intended). Once the code completes and all sheet models are created, I am also left with an empty design model which is also the DGN file's default model. I am wondering if it is programmatically possible to designate another model to become the default model to allow me to delete this design model? I couldn't see anything obvious in the VBA help and I have no idea if such functionality exists in MDL that could be harnessed from VBA? Of course the other alternative is to modify the default reference to become the 1st sheet however I don't wish to go down that route if it can be avoided.

Programming with MicroStation SDK in C#

$
0
0

I have a customer who wants me to rewrite some VBA code used with MicroStation into C# and using Windows Forms. My customer has a copy of MicroStation installed but I don't so I understand that they will be responsible for testing the code that I develop.

I have downloaded and installed the MicroStation SDK from Bentley but I can't find the relevant references to add to Visual Studio that will allow me to develop against this SDK using C# and .NET.

In Microstation v8 2004 VBA, to convert Cartesian x, y, z coordinates to Latitude, longitude, elevation using WGS 84

$
0
0

Hi Sir,

I am using Microstation v8 2004, I want to know, how to convert Cartesian x, y, z coordinates to Latitude, longitude, elevation using WGS 84 in Micristation v8 2004 VBA

I am using IPrimitiveCommandEvent DataPoint to get my x,y,z points need to convert to lat, long, elevation using WGS84, I searched online for the formula with no success

can you provide formula for the conversion to use in VBA or any other option in ustn v8 2004 VBA?

Thanks & Regards

(mmk)

Microstation Vba to MDL C++

$
0
0

https://translate.google.it/?sl=bg

Good morning
I make a premise, I'm not a programmer, I've never studied computer science, I don't know English. Despite this with the help of:
- store.bentley.com/.../WAD00781A10001--Learning-MicroStation-VBA- http://www.la-solutions.co.uk

with suggestions from Jon Summers and Jan Slegr and Yongan.Fu
I managed to develop some VBA macros that help me in my work.
My dream would be to be able to develop or bring my vba macros into C # or C ++ or MDL,
but maybe they are a dream since I miss a lot of things.
My question is this:
how can one learn little by little how to program with these languages
​​considering that I cannot access the BDN.
Users who are less experienced like me will never be able to learn.

Grazie


[CONNECT C#] IDgnECInstance properties

$
0
0

IDgnECInstance Properties

I can write code like this to display the value of a named property of an IDgnECInstance...

int i = 0;
foreach (IDgnECInstance instance in instances)
{
  s.Clear();
  s.AppendFormat("Instance [{0}] ID {1}", ++i, instance["ID"].StringValue);
  MessageCenter.Instance.ShowMessage(MessageType.Debug, s.ToString(), s.ToString(), MessageAlert.None);
}

If I don't know the name (a.k.a. access string) of a property, can I get an iterable list of properties? I can't use an integer indexer (instance[0].StringValue) because it's not part of the IDgnECInstance interface.  What I'm asking about is a possibly fictional interface like this...

int nProperties = instance.GetPropertyCount ();
for (int i = 0; i != nProperties; ++i)
{
  Property prop = instance.Properties [i];
}

Documentation

Documentation about IDgnECInstance is terse. It inherits from IECInstance, which has no documentation whatsoever.

[CONNECT .NET] XML Command Table

$
0
0

An AddIn built with .NET has an XML command table.  It uses XML schema http://www.bentley.com/schemas/1.0/MicroStation/AddIn/KeyinTree.xsd, but the schemas/1.0 folder doesn't exist.

Where is the XML command table structure defined?  I can find nothing in the help files.

When I define a CommandTable resource file for a native app., there are a number of macros available for option and command class. They are defined in the SDK header file Mstn/MdlApi/cmdclass.r.h.  How can I achieve the something similar in an XML command table?

Can not new Bentley.GeometryNET.Viewport()

$
0
0

CS1729 C# does not contain a constructor that takes 0 arguments

how to new Viewport?


V8i PowerDraft SS4 VBA - Calling Print Organizer, opening PSETs error handling?

$
0
0

Hi Guys,

I'm using Excel VBA to call Microstation and then from a list of directories open .pset files (previously created manually) contained within each directory. The intention is to open each pset, print to PDF and move onto the next PSET until all in the list are completed.

I have gotten the code to do exactly what I want, however the issue comes when the printorganizer attempts to print a PSET which references corrupt files/folders (in other words it hasn't been setup properly) . From what I can tell this causes a complete failure and the program hangs indefinitely, the message 'waiting for OLE automation etc.' comes up, in the end the excel application has to be closed through the task manager.

What form of error handling will manage this? Print organizer is called using key-in as I don't believe there are objects I can access and therefore I am unable to predict the error state.

Code below:

Sub RunPSets()

Dim myDGN As New MicroStationDGN.Application
Dim nFile As DesignFile

Dim i As Integer
Dim ws_FH As Worksheet
Dim rngPSETs As Range
Dim openPSETDIR As String
Dim outputDir As String
Dim userWarningList As String
Dim answer As Integer

Set ws_FH = Application.Worksheets("Fill History")
Set rngPSETs = ws_FH.Range("M12:O100")

Dim j As Integer

outputDir = Main_Form.lblOutputDir.Caption

If outputDir <> "" Then

    For j = 1 To rngPSETs.Rows.Count
    
        If rngPSETs.Cells(j, 1) <> "" Then
        userWarningList = userWarningList & rngPSETs.Cells(j, 1) & " " & rngPSETs.Cells(j, 2) & vbNewLine
        End If
    Next j
Else
        MsgBox "Select output directory first!"
        Exit Sub
End If

answer = MsgBox("Print to PDF the following Isolations to:" & vbNewLine & outputDir & vbNewLine & vbNewLine & userWarningList, vbYesNo, "Print Isolations")

If answer = vbYes Then

    Const PrintDriver As String = "MTM-PDF-Plotdrv.plt"'Const PrintDriver As String = "pdf.pltcfg"'myDGN.CadInputQueue.SendCommand "printorganizer exit"
            Set nFile = myDGN.OpenDesignFile("J:\Engineering Division\15 Design Production\Signalling\Isolations\- Source Files\Isolation Template.dgn", True)
            Main_Form.lblStatus.ForeColor = &H40C0&
            myDGN.CadInputQueue.SendKeyin "mdl load bentley.microstation.printorganizer.dll"'myDGN.CadInputQueue.SendCommand "printorganizer new"
            Debug.Print "PRINTING STARTED"
            For i = 1 To rngPSETs.Rows.Count
                If rngPSETs.Cells(i, 1) <> "" Then
                openPSETDIR = rngPSETs.Cells(i, 3)
                Main_Form.lblStatus.Caption = "Printing....TBA: " & rngPSETs(i, 1) & " " & rngPSETs.Cells(i, 2)
                myDGN.CadInputQueue.SendKeyin "printorganizer open " & openPSETDIR
                Debug.Print "PSET OPENED: " & openPSETDIR
                myDGN.CadInputQueue.SendKeyin "printorganizer printerdriver " & PrintDriver
                myDGN.CadInputQueue.SendKeyin "printorganizer printdestination " & outputDir & "\" & rngPSETs.Cells(i, 1) & " " & rngPSETs.Cells(i, 2) & ".pdf"
                myDGN.CadInputQueue.SendKeyin "printorganizer print all"
                Debug.Print "Printed PSET: " & rngPSETs(i, 1)
                Main_Form.lblStatus.Caption = "TBA: " & rngPSETs(i, 1) & " " & rngPSETs.Cells(i, 2) & " printed."
                End If
            Next i

        nFile.Close
        Debug.Print "Printing FINISHED"
        Set myDGN = Nothing
        myDGN.Quit
        MsgBox "Printing has finished!"


Else

Exit Sub

End If

End Sub

Does anyone have any ideas how I can safe proof this automation from errors of this type?

Thanks


Regards

Boris

[CONNECT C++] CurveCurve::CollectFilletArcs()

$
0
0

Trying to get a fillet generated between 2 lines with a common vertex, The returned FilletDetail <bvector> always has a size of zero:

		// create my "fillet" arc
		CurveVectorPtr						previousCurve = ICurvePathQuery::ElementToCurveVector(eeh1);
		CurveVectorPtr						currentCurve = ICurvePathQuery::ElementToCurveVector(eeh2);
		ICurvePrimitivePtr					&previousSegment = previousCurve->front();
		ICurvePrimitivePtr					&currentSegment = previousCurve->front();

		bvector<CurveCurve::FilletDetail>			arcs;
		CurveCurve::CollectFilletArcs(*previousSegment,*currentSegment,SRS::SRSConvert::InchToUOR(1.5), false, arcs);

		wprintf(L"%d arcs \n",arcs.size());

I have also used 'true' to allow the extension of the lines, but still, it seems no arcs (fillets) are created...

Bruce

[CONNECT .NET] ECQuery

$
0
0

I'd like to compose a query to use with DgnECManager.FindInstances using an ECQuery.  Unfortunately, the MstnPlatformNet documentation continues to ignore that class.  The SDK examples help little, using the catch-all SelectAllProperties.

ECQuery query = new ECQuery(GetSearchClasses());
query.SelectClause.SelectAllProperties = true;

How can one write a query, say, to select Item instance properties having a certain value?   That is, I'd like to know about ECQuery.SelectClause. If Item Types supported SQL, I would write something like...

SELECT * FROM MyItemType
WHERE ID='abc'

Since DgnECManager.FindInstances returns IQueryable<> it's tempting to ignore the MstnPlatformNet  API and use LINQ to compose a query.  Which approach would you make your strategy?

[CONNECT .NET] EncodeToValidName unavailable

$
0
0

Various EC classes have a name and a label.  The label is what you and I might write: e.g. Area Feature.  The name is what the API uses internally e.g. Area__00x20__Feature.  The MicroStationAPI provides C++ static method ECNameValidation::EncodeToValidNameMicroStationAPI tells us: Encodes special characters in a possibly invalid name to produce a valid name.

I can't see a similar class or method in the MstnPlatformNet.  How can I conjure the internal name of a class in C#?  Once you've created a class, you can use its InternalName property, but to get or find a class you must use its internal name.  Catch 22 applies here.

TransientElementContainer failing to initialize. VBA, Connect

$
0
0

VBA code that used to work in V8i fails in Connect:

    Dim tec As TransientElementContainer
    Set tec = CreateTransientElementContainer1(Nothing, msdTransientFlagsOverlay, msdViewAll, msdDrawingModeHilite)

Error message is:

What has changed? 

Viewing all 7260 articles
Browse latest View live


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