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

[CONNECT .NET] ElementPropertiesGetter

$
0
0

I'm using an ElementPropertiesGetter.  I can get a colour...

ElementPropertiesGetter propertiesGetter = new ElementPropertiesGetter (el);
uint colour = propertiesGetter.Color;

So far, so good. But, if the element's colour is ByLevel, then how do I extract that info?  I tried comparing to SpecialColor.ByLevel, but that's a negative number and Viz Studio complains about non-compatible types. Should I just cast my way out of trouble, or have I missed something?

Similar questions apply to element weight and line-style.


Batch process to change color of part of a text in Micro station with VBA code.

$
0
0

Suppose I have a text " Not to Scale" in 100 sheets. I need to change color only to "Scale". Finally the output should be "Not to Scale". Is there any solution for this in V8i version

Bentley.GeometryNET.Common.IPlacement

$
0
0

Hi, 

I am new to Programing in Microstation. I am currently working on a test add-in for ORD which does basic stuff (from C#.net). just gonna create CircularCylinder  from 2 points but will I use 

"CircularCylinder cylinder = new CircularCylinder();"

It required an "IPlacement". So how do I get Iplacement from to 2 points? and what is Iplacement Mean?

Thanks,

Jason

[CONNECT .NET] User Interface Icons for Element Symbology

$
0
0

Does the .NET API offer any public icons that we can use in an app's user interface (UI)?  The Element Properties dialog, for example, displays icons for element symbology and level...

Element Properties dialog

[CONNECT Update 12 VBA], [V8i SELECTseries 3 VBA] VBA Function "ShowOpen" works in V8i but not in CONNECT

$
0
0

Hello. My first post, so please be patient!
I have problems using vba Function "ShowOpen". My vba runs fine on MicroStation V8i (SELCTseries 3), but it will not open Dialogbox for selecting file in a newer MicroSration version.
Why don't this work in a newer MicroStation?

I have created a VBA UserForm "frmGPS_indlas"
In this form I have a push-button "Browse" (name) "cmdBrowseFile"
In the code to this form I include a call to Function "ShowOpen":

Private Sub cmdBrowseFile_Click()
        Dim msg      As String
    txtGPSfile = ShowOpen("Select GPS file", "CSV filer (*.csv)" + Chr$(0) + "*.csv", "All files (*.*)" + Chr$(0) + "*.*", "")
    If (Len(txtGPSfile) > 0) Then
          msg = "GPS fil '" & txtGPSfile & "'"
    Else
          msg = "No GPS file selected (Cancel)"
    End If
    ShowMessage msg, msg, msdMessageCenterPriorityInfo
    End Sub

And here we have "ShowOpen":

    Public Function ShowOpen( _
        strTitle As String, _
        Optional strFilterDescr As String = "All files (*.*)", _
        Optional strFilterSpec As String = "*.*", _
        Optional strInitDir As String = vbNullString) As String
        On Error GoTo Proc_Error

        Dim OFName          As OPENFILENAME
        Dim strFileFilter   As String, strFileSelected As String

        strFileFilter = strFilterDescr & Chr$(0) & strFilterSpec & Chr$(0)
        With OFName
            .lStructSize = Len(OFName)
            .hWndOwner = 0&
            .hInstance = 0& 'App.hInstance'Select a filter
            .lpstrFilter = strFileFilter ' "Text Files (*.txt)" & Chr$(0) &"*.txt" & Chr$(0) & "All Files (*.*)" & Chr$(0) & "*.*" & Chr$(0)
            .lpstrFile = Space$(254)
            .nMaxFile = 255
            .lpstrFileTitle = Space$(254)
            .nMaxFileTitle = 255
            If (vbNullString <> strInitDir) Then _
                .lpstrInitialDir = strInitDir
            .lpstrTitle = strTitle ' "Select File"
            .flags = OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST
        End With
        If GetOpenFileName(OFName) Then
            strFileSelected = Trim$(OFName.lpstrFile)
            If (InStr(strFileSelected, Chr(0)) > 0) Then
                strFileSelected = Left(strFileSelected, InStr(strFileSelected, Chr(0)) - 1)
            End If
            ShowOpen = Trim$(strFileSelected)
        Else
            ShowOpen = vbNullString
        End If

    Proc_Exit:
        Exit Function
    Proc_Error:
        ShowOpen = vbNullString
        MsgBox Err.Description
        Resume Proc_Exit
    End Function

[CONNECT MS Update 14, OpenRoads 2020 R2 VBA] Return text element intersected by a line

$
0
0

Hi, Is it possible to return the text element that has been intersected by a line element as shown below -

[C# COM MSCEU14] COM Interop from X86 process

$
0
0

Having trouble getting a x86 program to work with Connect.

using System;
using System.IO;
using MicroStationDgn;

namespace ComInteropTests
{
	class Program
	{
		private const string SeedFile = @"C:\Program Files\Bentley\MicroStation CONNECT Edition\MicroStation\Default\Seed\2D Metric Design.dgn";
		private const string WorkFile = @"D:\WorkFile.dgn";

		[STAThread]
		static void Main()
		{
			try
			{
				File.Delete(WorkFile);
				File.Copy(SeedFile, WorkFile);

				var connector = new ApplicationObjectConnectorClass();
				Application application = connector.Application;
				DesignFile designFile = application.OpenDesignFile(WorkFile);
				ModelReference model = application.ActiveModelReference;

				var lines = new ChainableElement[4] 
				{
					(ChainableElement) application.CreateLineElement1(null, new Point3d[] { new Point3d { X = 100, Y = 100 }, new Point3d { X = 100, Y = 200 } } ),
					(ChainableElement) application.CreateLineElement1(null, new Point3d[] { new Point3d { X = 100, Y = 200 }, new Point3d { X = 200, Y = 200 } } ),
					(ChainableElement) application.CreateLineElement1(null, new Point3d[] { new Point3d { X = 200, Y = 200 }, new Point3d { X = 200, Y = 100 } } ),
					(ChainableElement) application.CreateLineElement1(null, new Point3d[] { new Point3d { X = 200, Y = 100 }, new Point3d { X = 100, Y = 100 } } )
				};

				ComplexShapeElement complexShape = application.CreateComplexShapeElement1(lines); // ComInteropTestCE throws Exception from HRESULT: 0x80010105 
				model.AddElement((_Element) complexShape);

				designFile.Save();
				application.Quit();
			}
			catch (Exception ex)
			{
				Console.Error.WriteLine(ex);
			}
		}
	}
}


Program is using a TlbImp-generated interop assembly:


C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\TlbImp.exe" /machine:X86 /namespace:MicroStationDgn /unsafe /verbose /out:"%CurrentDir%\MicroStationDgnCE" "C:\Program Files\Bentley\MicroStation Connect Edition\MicroStation\MicroStation.exe


Same code is working fine with MicroStation V8i SS4. Any hints how to get this to work with Connect?

communities.bentley.com/.../ComInteropTests.zip

[C# Connect U14] Transient-Element not working for Parametric Elements

$
0
0

I used the COM Functions CreateTransientElementContainer1(null, MsdTransientFlags.Overlay, MsdViewMask.AllViews, MsdDrawingMode.Hilite); and AppendCopyOfElement(element); but this doesn't work for Parametric Elements. I tested it with Parametric Volumes and Parametric Cells. I didn't tested every Element Type but non Parametric Elements do work.
Is there an easy fix to this or do I need to use a different function now?


MDL V8 tool to CONNECT EDITION Migration

$
0
0

Dear Team,

We are migrating old MicroStation V8 tools(.ma) to CONNECT EDITION 14.

Our old v8 tools contains .rsc resources only but for migration we need .r files it seems.

can i migrate my old v8 tool with .rsc file or i need .r file as mandatory ?

Thanks in advance.

[CONNECT .NET] Get Line Style Name from Level

$
0
0

I want to get the name of the line style that is applied to a DGN element when its style is ByLevel.

Thanks to a hint from Maury, I can determine if a line style is ByLevel, but what next?

name = LineStyleManager.GetStringFromNumber(propGetter.LineStyleId, Ms.GetActiveDgnFile());
if (name == "STYLE_ByLevel")
{
  ???  How do I get the style name from the level?
}

LevelHandle.GetByLevelLineStyle() returns a LevelDefinitionLineStyle, but that class doesn't contain a style name.  There's an integer property LevelDefinitionLineStyle.Style— can I get a style name from that?

[C++ Connect U14] Placing parametric cells takes long time

$
0
0

Hi

I've made some code to place parametric cells and edit the ItemType property values. I've realized that when I work with parametric cells that are just a little complex it takes quite some time.

        auto& cellHandler = ParametricCellHandler::GetInstance();
		EditElementHandle defCellEeh;
		if (ParameterStatus::Success != cellHandler.CreateCellElement(defCellEeh, *defaultInfo))
			return ERROR;

		lifalib_eehSetLvAndActiveCoWtSt(defCellEeh, levelID, false, false, false, true);

		lifalib_log("lifalib", 2, 1, "lifalib_placeParametricCellWC - Before addToModel");
		defCellEeh.AddToModel();
		lifalib_log("lifalib", 2, 1, "lifalib_placeParametricCellWC - After addToModel");
		lifalib_log("lifalib", 2, 1, "lifalib_placeParametricCellWC - Before updateItemTypes");

		std::vector<WString> params;
		std::vector<WString> values;
		if (!splitParams(strParams, strValues, params, values))
			return false;
		for (int paramIndex = 0; paramIndex < (int)params.size(); paramIndex++)
		{
			double value;
			if (swscanf(values[paramIndex].c_str(), L"%lf", &value) == 1)
				//lifalib_updateItemTypePropertyOnElm3(defCellEeh, L"LIFA", L"Rectangle", params[paramIndex].c_str(), NULL, NULL, &value, NULL);
				lifalib_updateItemTypePropertyOnElm3(defCellEeh, L"Symboler", L"Tree", params[paramIndex].c_str(), NULL, NULL, &value, NULL);
			else
				return false;
		}
		lifalib_log("lifalib", 2, 1, "lifalib_placeParametricCellWC - After updateItemTypes");

I've attached a cellibrary with 3 cells.

When I use this code with the cell "Rectangle" - (very simple) it goes quite fast - something between 2 and 3 seconds to place 10 cells.

When I use the cell "Tree" it takes about 11 seconds to place 10 cells. When I remove half of the elements in this cell (see "Tree2" the time is approx. halved.

How can that be ?

TIA, Evan

communities.bentley.com/.../ParametricSymbols.cel

[CONNECT .NET] LsDgnFileMap.Resolve does not exist

$
0
0

The documentation for LsDgnFileMap has this: If the line style map is a LsDgnFileMap then the LsEntryP that is returned may be a pointer to a stub used to translate from element style number to name. Call LsDgnFileMap::Resolve to find the LsEntry that is used to stroke the element.

However, as far as I can see, LsDgnFileMap.Resolve does not exist. 

[CONNECT .NET] Text Handler Classes

$
0
0

The DgnPlatformNet help documents the TextHandlerBase class.  It has this note: Base class for text element handlers; should NOT be sub-classed directly (see TextNodeHandler and TextElemHandler).

Unfortunately, neither TextNodeHandler nor TextElemHandler exists.

[CONNECT .NET] What does ElementId (ref long value) Do?

$
0
0

The .NET ElementId constructor requires a long value.  But that value is passed by ref.  To me, ref implies that the value may be changed inside the ElementId.  Why is ref in the constructor?

[CONNECT C++] How do I get the functionality of mdlElmdscr_readToMaster() in the new SDK?

$
0
0

I am trying to update some existing code to Connect. The code simply zooms the active view to show an element. In the past I used mdlElmdscr_readToMaster() to read the element from any model and used the element range returned to pass to the view extents.

Now in V8i I have tried rewriting this code to use elementRef's instead of MSElementDescr's, except my code doesn't work in reference files because it is not handling the differences in scale, rotation, units, etc. The old V8i code worked fine because mdlElmdscr_readToMaster() did all of the coordinate transforms for me. What is the new recommended method of doing the same thing using the Connect SDK? In other words how do I translate the element range from an element read in from a reference file into the active model coordinates I can use in my call to mdlView_fitViewToRange() ?

I presume the old  mdlCurrTrans_() functions are no longer recommended?

Cheers.


[MStn CE U14 C#] How to obtain SmartFeaturesSchema?

$
0
0

Hi,

I need to create ECQuery using classes from SmartFeaturesSchema.

My problem is that this schema is not stored in DGN file and is in not delivered with MicroStation installation as extrinsic too, but seems to be generated dynamically in memory when relevant element is queried.

It leads to Catch-22 situation: To find such element(s), I need the schema to be available to add classes to q query, but I am not able to obtain the schema until I have element described by this schema.

What is recommended way how to obtain this schema?

With regards,

  Jan

[CONNECT .NET] TextElement.Description: too much information!

$
0
0

I'm extracting element information from various kinds of element that contain text.  I want to describe the element (e.g. Note Element, Text Element, Text Node Element).

Element.Description does what I want, except for TextElement.  With TextElement, the description includes the element type and its text content...

Text Element Description

I don't want the text content in the element description.  Note that a TextNodeElement doesn't add the text content to its description; why does TextElement perform that additional unwanted step?

How can I get just the description of a TextElement, without additional information?

Finding a rounded coordinate in a rotated view along Element, MST8i SS4, VBA

$
0
0

Dear All,

I'm drawing a square in rotated View and want to create horizontal lines every X-m. But i'am getting a not rounden X-Cooordinate on the Start of Lines.
So I have perhaps to calculate more Distance, because each line must start with a rounded X-Coordinate.
Only Rounding the coordinate moves the point along the other axis.How can this problem be solved if there is a view rotation angle, a point of displacement of the axes.

I'am Using a Method form John Summers with IPrimitiveCommandEvents for Creating a of Square and other Elements.

Thanks for your Ideas.

CONNECT C# Addin Element Template

$
0
0

Is there a way to set attributes to Element according Element Template from attached dgnlib  (C#) ?
In 2016 Jan Šlegr wrote: "I guess there is no documented NET API available", may be after time...

I expect something like this:

ElementTemplateCollection elementTemplates = model.GetDgnFile().GetElementTemplates();
ElementTemplate elementTemplate = elementTemplates.FindByName(<template group name>\<template name>);
LineElement element = new LineElement(.....
elementTemplate.Apply(element);

...or similar...

IT

$
0
0

开发环境VS2013,配合CE Update 4进行MDL开发。手工建立VS项目时,需要建立批处理文件MakeMa.bat,内容为 CALL "%MSV8i%mdl\bin\mstndevvars.bat" "%MSV8i%" "%MSV8i%" CD /D "%ProjectDir%" bmake,但是在CE SDK Update 4中找不到mstndevvars.bat文件,请问该怎么解决?

Viewing all 4331 articles
Browse latest View live


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