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

[CONNECT .NET] System Event Handlers

$
0
0

System Event Callbacks in .NET

In C++ we can write system event handlers...

SystemCallback::SetUnloadProgramFunction (OnUnload);
SystemCallback::SetReloadProgramFunction (OnReload);
SystemCallback::SetNewDesignFileFunction (OnNewDesignFile);

Where, for example, OnNewDesignFile is called asynchronously by MicroStation when the user opens a new DGN file.

Are similar event observers available for .NET developers?


Call Excel VBA function from MVBA

$
0
0

I have seen lots of posts addressing how to call MVBA from an excel VBA; however, I am trying to achieve the other way around. I hope that someone can help with this.

I am using Microstation V8i & my operating system is x64

Below is the code I'm using to achieve this:

Dim value As string

Dim Exl As New Excel.Application
Dim wb As Excel.Workbook

Set wb = Exl.Workbooks.Open("MyExcel.xlsm")

' below is is the line that gives me an error

Exl.Run "'" & wb.Name & "'!" & Function_name, value

Thanks in advance for the support.

[CONNECT CE] How to obtain all (EC) relationship for an element at once?

$
0
0

Hi,

this my question focuses to API usage and best practices:

Is there a simple (or not simple, but recommended) way how to obtain an information whether any relationship exists from/to the element or the list of these relationships (e.g. as IList<IECRelationshipClass>)?

In this discussion it was demonstrated how to create ECQuery that will search particular relationship (represented by specific EC relationship class). It's fine when it's known upfront that e.g. tags or Design Links are attached to the element. But in some situations it would be nice to know "a dependency or relationship exists" so when element will by modified or removed, there will be some extra consequences. Using ECQuery, the question is how to (and whether it's possible) to configure the query to include any relationshio class found at queried element(s).

I have not tested it, but I can imagine I will read DgnContentRelationshipSchema schema (or all schemas used in model) for all available relationship classes and will search for them one by one. It does not look elegant and efficient. I see QueryRelatedClassSpecifier method in NET API is overloaded (in native, there seems to be just one static constructor available), but it's not clear whether their functionalities are different and if some can be used to find all relationships.

With regards,

  Jan

Excel Macro to draw lines in Microstation based on coordinates

$
0
0

Good Morning,

Im new to Excel Macros so looking for some advice on how to complete the following.

I know theres a way to plot lines in Microstation based on coordinates using the Microstation Script process.

I want to improve this so I can reduce time in copying over data, putting xy= and ensuring no spaces.

What is the best way to create a macro in excel, which will allow me to highlight the coordinate data, press a button and it will draw smart lines etc in microstation for me?

Looking for a macro to attach a .dgn reference to a .dwg with the same file name

$
0
0

I have several hundred .dwg files that I need to open and attach a .dgn file of the same name into.

I tried batch exporting but that did not work and it was mentioned that I can do it with a VBA script. I have very little knowledge of VBA, batch processing has been able to do everything I needed, until now

Does anyone have a script for this purpose?

example

open buidling1.dwg and attach reference building1.dgn then open next file and do the same

Thanks!

[MStn CE U12 C#]SearchClass ignored when ECQuery is run on DgnECHostType.DesignLink?

$
0
0

Hi,

I have this simple test code:

DgnFile file = Session.Instance.GetActiveDgnModel().GetDgnFile();

FindInstancesScopeOption designLinkScopeOption = new FindInstancesScopeOption(DgnECHostType.DesignLink, false);
FindInstancesScope scope = FindInstancesScope.CreateScope(file, designLinkScopeOption);

IECSchema designLinksSchema = DgnECManager.Manager.LocateDeliveredSchema("BentleyDesignLinksPresentation", 1, 0, SchemaMatchType.LatestCompatible, file);

List<SearchClass> searchClasses = new List<SearchClass>();
searchClasses.Add(new SearchClass(designLinksSchema["URLLinkProperties"], false));
searchClasses.Add(new SearchClass(designLinksSchema["ModelLinkProperties"], false));

ECQuery query = new ECQuery(searchClasses);
query.SelectClause.SelectAllProperties = true;
DgnECInstanceCollection ecInstances = DgnECManager.Manager.FindInstances(scope, query);

I would expect DgnECInstanceCollection instance contains only the specified EC classes (representing DesignLinks created by a user), but for every DesignLink class also another LinkTreeProperties class exists in the result.

It's not a big issue, because classes can be filtered easily later ...

var result = from r in ecInstances
             where
             r.ClassDefinition.Name.Equals("ModelLinkProperties", System.StringComparison.Ordinal) ||
             r.ClassDefinition.Name.Equals("URLLinkProperties", System.StringComparison.Ordinal)
             select r;

... but I would like to understand API better:

  • Is it expected behaviour, so when DesignLink is set as a host type, all classes are reported regardless how ECQuery is configured...
  • ... is anything is missing in my code...
  • ... or it's a bug?

With regards,

  Jan

[V8i] Only some tools have their attributes exposed via toolsettings

How to get the correct mesh range(coordinates, and points) from a shared cell?

$
0
0

Hi Experts,

   I have a very simple dgn file, and i try to get the mesh data from the cell,

I use the ElementGraphicsProcessor::Process() and ElementGraphicsProcessor::_ProcessFacets(PolyfaceQueryCR facets, bool isFilled) to get the the facet range data,

and my code works correctly for most dgn model, until i run this model(attached), i found the mesh range i get from the PolyfaceHeaderPtr is very small, 

     low = {x=-0.0055878386544380137 y=-0.0081490121159178940 z=-0.00058207660927359203 }  
     high = {x=0.0055880322435498137 y=0.0081491329436476877 z=0.00058207660927420796 }

i get the range from the mesh directly:        

       auto range = pMesh->PointRange();   // where pMesh is a PolyfaceHeaderPtr 

but if i  get the basis range, the range is correct, i use below code to get the base range of the element,

     high = { x=24000.500000000000 y=35000.500000000000 z=2501.0000000000000 }
     low = { x=-24000.500000000000 y=-35000.500000000000 z=-2501.0000000000000 }

        Bentley::DgnPlatform::ElementHandle m_eh;

       ...............................

        DRange3d rangeBox;
        m_eh.GetDisplayHandler()->GetBasisRange(m_eh, rangeBox);

and the modelInfo.UorPerMeter is 100000.

 

  i check the properties in Microstaion CE(update 12), it as below,  the range value is much bigger, so my question is how i can get the correct range of the mesh as well as the points?

the original mode is :

communities.bentley.com/.../_EA819A5B494E216A8B575E5C2760_TESTID_2D00_v2.dgn

I am runing with Microstation CE Update 12. and my code works fine for most of other models, except this one.


[CONNECT C++] Field validation issue

$
0
0

The maximum LevelCode value is 4294967295. How to add field validation in dialog so it allows values from 0-4294967295?

For example using MDL basic Dialog:

DialogBoxRsc DIALOGID_Basic =
    {
    DIALOGATTR_DEFAULT | DIALOGATTR_SINKABLE,
    25*XC, 7*YC,
    NOHELP, MHELP, HOOKDIALOGID_Basic, NOPARENTID,
    TXT_BasicDialogBox,
{
{{X1,GENY(1),XW,0}, LEVELID,	      LEVELID_Basic, ON, 0, "0", "4294967295"},
{{X1,GENY(2),XW,0}, OptionButton, OPTIONBUTTONID_Basic, ON, 0, "", ""},
{{X2,GENY(4),BTN_WIDTH,0}, PushButton, PUSHBUTTONID_OModal, ON, 0,"",""},

It only works with values 0-2147483647 but if set 2²³ as maximum then it allows only negative values and shows message "Field must be between 0 & 4294967295".

LevelID decalared as unsigned int.

MicroStation/PowerDraft Connect VBA INTERFACE ERROR: 135/140

$
0
0

When loading VBA applications in MicroStation/PowerDraft Connect (V10.12.00.40) I get either VBA INTERFACE ERROR: 135 or VBA INTERFACE ERROR: 140.  The applications seem to run fine but I would like to get rid of these errors to keep users from thinking there is a problem.  I have searched for an explanation of these errors but so far have not had any luck finding anything.  Any insight on this would be appreciated.

[CONNECT C++] DependencyManager - How to obtain the "current" Viewport when DependencyManager handles and Event?

$
0
0

I'm writing a DependencyManager handler and I need to know the RotMatrix of the view where my element modification caused the DependencyManager to act. Specifically, when my Root element alters it's rotation, I need to also modify the rotation of any dependent items. I am trying to use GetCurrentDgnButtonEvent(), but I don't have any type of DgnTool active, so the compiler doesn't like me using it....

Not sure of any other way to obtain the Viewport of the cursor operation. Do I need to set up a view monitor as well in order to get this information? Might it be available from the tcb?

Scan the elements without open the file.

$
0
0

Dear All,

     I'm using Microstation V8i (Select series 4) with c# language. I'm trying to scan the elements without opening the dgn files. I used the following function, but i observed co-ordinates are not matching with the actual element coordinates. Could anyone correct me, or else if any other method is available to scan elements without opening the dgn files. Thanks in advance

BCOM.DesignFile dgnfile = app.OpenDesignFileForProgram(_strfile);
int modelint = dgnfile.MdlModelRefP();
BCOM.ModelReference modref = app.MdlGetModelReferenceFromModelRefP(modelint);
List<BCOM.Element> _eles = modref.Scan(esc).BuildArrayFromContents().ToList();
foreach (BCOM.Element ele in _eles)
{
    if (!ele.IsLineElement()) continue;
    List<BCOM.Point3d> _lstPts = ele.AsLineElement().GetVertices().ToList();
    //something as per requirement............ :-)
}
dgnfile.Save(); 

Thanks & Regards,

Karthik Keyan

[C# Connect] Attach POD-files without dialog

$
0
0

Hi everyone!

I want to attach point cloud to model.

I know path to POD-file.

I am trying to use for attach cloud this code:

DgnDocumentMoniker moniker = DgnDocumentMoniker.CreateFromFileName(podFile, "");
PointCloudProperties prop = new PointCloudProperties(moniker, modelRef);
PointCloudElement pE = new PointCloudElement(model, prop, DRange3d.InfiniteRange);
pE.AddToModel();

Cloud is displaying in viewport, but in Attach manager it is not visible.

I use ORD ver: 2019 release 1 update 7 (10.07.00.56).

How can do it? Where am I wrong?

CONNECT Update 12 VBA: duplicate dimensionstyles after ActiveSettings.DimensionStyle =

$
0
0

This is my first mVBA in Microstation CONNECT update 12 (version 10.12.00.40) and my first post in this forum.

The purpose of the mVBA is to make it easier to select a dimensionstyle. The user selects parameters like the textpurpose, texttype and elementstatus. The VBA then activates the matching textstyle and dimensionstyle from a .DGNLIB belonging to our CAD-standards.

The mVBA-code to activate the dimensionstyle from the dgnlib is:

 If oDim.IsFromLibrary = True Then
      Dim TempElement As DimensionElement
      Set TempElement = CreateDimensionElement1(Nothing, Matrix3dFromAxisAndRotationAngle(2, 0), MsdDimType.msdDimTypeCenter)
      TempElement.DimensionStyle = oDim
      ActiveModelReference.AddElement TempElement
      ActiveModelReference.RemoveElement TempElement
      Set oDim = ActiveDesignFile.DimensionStyles.Find(dStijl)
 End If
    Set ActiveSettings.DimensionStyle = ActiveDesignFile.DimensionStyles.Find(dStijl)

The value for dStijl= "NLCS-ANNOTATIEF-T25-BOL" (without quotes)

(oDim as Dimensionstyle, dStijl as String)

Everything seems to work without errors... but:

1. The element properties of the dimensionelement show a dimensionstyle "none"

2. The Dimension Styles dialog shows multiple dimensionstyles with the name "NLCS-ANNOTATIEF-T25-BOL"

example frmo dimensionstyle dialog

After some testing, it seems that the active dimensionstyle is overwritten by the mVBA, when executing "Set ActiveSettings.DimensionStyle = ActiveDesignFile.DimensionStyles.Find(dStijl)". Thus causing multiple problems in the dgn with dimensionstyles and elementproperties.

Should it even be possible for dimensionstyles with duplicate names to exist in the same dgn?

So I must be doing something very wrong.

I use similar code to activate a textstyle from the dgnlib without problems.

I'm lost... Any ideas on this?

Thank you for reading my post.

[V8i SS3 VBA WIN10 64]

$
0
0

Hi Everoyone

Recently I was obliged to move to brand new machine (Dell 5530/Quadro320/I9..Windows10 v1809).

For me and company we have lots of VBA extensions (some pretty much developed and complicated).

I've tried to run one of it on my brand new PC and whole ustation crashed (without error code).

To be more compatible with whole company, we are using ustation V8 ss3/ss4 + Office 2013 (same VBA code is used even by V8 2004)

But right now I cannot start none of VBA code.

At the end of the day, I tried to:

1) record macro (silly) - SUCCESS - it was working

2) start very simple 'msgbox "hello world"' in VBA module - SUCCESS - it was working

3) add FORM, place a button and display 'msgbox "hello world"'  - NOT SUCCEED - it has crashed with error "Run-time Error -2147417848 (80010108)"

So - I'm lost. 

in C:\Program Files (x86)\Common Files\microsoft shared\VBA, there are both VBA6 and VBA7.1 folders. 

Can someone give me advice - what is the reason, and what is more important, how to solve it?

Thanks in advance.


[CE] How to work with Display Styles in multilanguage environment?

$
0
0

Hi,

this is another "about best practices" question not specific to particular API (C++ or NET):

With MicroStation default installation, a set of display styles - with English names like "Smooth:Shadows" is delivered. These names are overriden in national versions, so using e.g. Czech language pack, the same style is named "Hladké:Stíny". Question is: How original "English name / style" can be identified using localized name, or vice versa how for English name I can find corresponding localized name?

As far as I understand Display Styles API (few tests done, but mostly from reading API documentation), it is based primarily on the names, which makes sense in general (the name is unique in DGN file by default), but when the files are processed in different language environments, it this approach does not work.

Let's discuss more practical example: An application needs to apply a display style (e.g. Smooth:Shadows) to automatically generated view. Using DisplayStyleList::FindDisplayStyleByName(name) a proper style can be found easily in English MicroStation. But the same code will not work when it will be run with any localized MicroStation (Czech, German, Italian...), because the style with the same name will not exist.

Is there any recommended strategy / approach how to solve this situation? I thought about:

  • "Hard-coded" styles are mentioned in MicroStationAPI documentation, but it's not clear what styles are they. Maybe all style delivered with default MicroStation installation can be retrieved using such hard-coded name/value?
  • Or is there any translation mechanism, something like "for this MicroStation, tells me what is localized name for Smooth:Shadows style?
  • Alternatively, the application will be delivered with an own set of display styles, so it will be ensured the style exists always with the same name. It's right solution when custom display styles will be used, but disadvantages are that extra dgnlib has be installed and the names will be not localized.

With regards,

  Jan

Revision Block tags are not editable through VBA

$
0
0

Hi,

I wrote a Excel VBA code to automate the Revision Block in Microstation Version V8i.

The code have revision block tags. The problem is I cannot edit those tags through code.

The code is not throwing error. I dont know why cant it edit revision block.

I have attached the code.communities.bentley.com/.../void-drawing-updater.xlsm

[CONNECT C++] Determine the offset for a font's DESCENDER justification

$
0
0

When I have text or a textNode that uses one of the Descender justifications (Left-Descender/Center-Descender/Right-Descender), is it possible to determine what that 'Descender' offset is? When you take the TextBlock's NominalRange (textBlock->GetNominalRange()) and transform it by the textBlock's rotation and UserOrigin, the resulting range seems to always have nominalRange.low.x and nominalRange.high.y located at the textBlock's UserOrigin. I'd like to "shift"  that range so it overlays the actual text boundary. Since I know the text height, when the justification is "Top"/"Center"/"Bottom", I know how much to shift the text up/down. However, when the justification is "Descender", I do not know the amount to shift the text up. I could make an assumption for my font, but I suspect that each font will have a specific "descender" distance.

[Connect C#] Attaching Materials

$
0
0

I have gone through the MaterialsExample\MaterialsAttachTool.cpp example provided with the sdk and am trying to create something similar in C#..

I am able to generate a new material just fine, however, when I go to attach the material to my element, it returns success but the material does not get attached. (Using the query material tool says no material attached)

MaterialPropertiesExtension materialProperties = MaterialPropertiesExtension.GetAsMaterialPropertiesExtension(selectedElement as DisplayableElement);
BentleyStatus status = materialProperties.AddMaterialAttachment(new MaterialId(material.Name));

Is there something else that must be called to get the material to attach properly?

I have tried replacing the elemen,  adding a duplicate to the model, and doing nothing extra... they never have a material attached.

Save As Creates 0 KB .mvba File

$
0
0

Hello MicroStation Programming Community,

I am trying to modify the Reference Library Priority for a .mvba program, and am seeing a 0 KB File as a result. Any ideas as to what causes this, and how to successfully complete a modification to a .mvba program? Here is what I can share:

  • I don't see any missing References
  • The .mvba File is not Read-Only
  • The .mvba File is not password protected
  • Using MicroStation V8i (SELECTseries 10) to modify a .mvba File created/modified using MicroStation V8i (SELECTseries 4)
  • Making the change, in attempt to resolve a vba interface error unable to run macro - 0x80040552 error
  • Other VBAs work without error, and use the same Reference Libraries

I should also mention that any change to a Form or Module results in a 0 KB .mvba File.

Many thanks in advance, for your guidance / assistance.

~ Matt

Viewing all 7260 articles
Browse latest View live


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