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

Unable to get the angle from cell element.

$
0
0

Hi All,

            I am using Microstation V8i (Select series 4) and c# language. i am trying to get the angle from cell element by using the following code but i didn't get the angle it's return always 0.0 only. Please anyone let me know what i did the mistake here.  I attached my testing dgn also please find it.

BCOM.Application app = BMI.Utilities.ComApp;
BCOM.ElementEnumerator eleEnum = app.ActiveModelReference.GetSelectedElements();
List<BCOM.Element> _lstEles = eleEnum.BuildArrayFromContents().ToList();
foreach (BCOM.Element ele in _lstEles)
{
    double _angle=0.0;
    if(ele.IsCellElement())
    {
        BCOM.Matrix3d cellrot = _ele.AsCellElement().Rotation;
        app.Matrix3dIsXYRotation(cellrot, ref _angle);
    }
}

Thanks & Regards,

Karthik Keyan.

communities.bentley.com/.../1030.Testing.dgn


[V8i VBA] Passing more than one KeyinArgument?

$
0
0

I found this discussion: https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/120244/v8i-vba-pass-command-arguments-to-macro which led me to the KeyinArguments property. But I'd like a little clarification or help with this.

I am looking into an MVBA that I can run through the batch process to replace a certain cell in a number of files. I'd like to pass OldCellName and NewCellName as KeyinArguments but I'm not sure I'm getting the syntax right, and I'm not sure how to pass "verbose" information

My command string for the batch process would look like

vba run RepCellVBA OldCellName NewCellName

From the Help file, it tells me I can use the Split function to break the argument "OldCellName NewCellName" into two separate strings. That will be fine if the cell names are a single word. But some of our cell names are phrases, instead of words (like "IN RW Left"). How does KeyinArguments handle phrases? Can I just use quote marks to delineate the different phrases:

vba run RepCellVBA "Old Cell Name" "New Cell Name"

and will KeyinArguments respect that those are two phrases (not six words)?

Of course, if someone has a macro that works already, or can point me to the keyin sequence to allow me to run replace cell through the batch process, it might save me the extra effort, and would be appreciated mightily!

Thank you for your assistance!
MaryB
MSTN 08.11.09.829

[CONNECT U12 C++] Determining the Tangent of a Point Projected to an Element

$
0
0

One can use CurverVector::ClosestPointBounded() to obtain a CurveLocationDetail that contains the location (CurveLocationDetail.point) of the "spacePoint" projected to the CurveVector. However, in order to obtain the Tangent at that location, one must use FractionToPoint or ComponentFractionToPoint (for LineStrings). In the case of a LineString, ComponentFractionToPoint() returns a DPoint3d "point" that is DIFFERENT from the DPoint3d returned in CurveLocationDetail.point. Why are they different?

recording a macro - parametric cell

$
0
0

Hello,

I tried recording a macro on changing a value of an assigned variable of a parametric cell and then promoted it into VBA, but I did not any results, any reason why or is it even possible for VBA to do this? Im using microstation CE 12

[CONNECT .NET] How to listen to the EnterIdleEvent with the CONNECT .NET API or P/Invoke?

$
0
0

I can't find any way of listening to the EnterIdleEvent with the CONNECT .NET API. I guess it was possible in V8i to P/Invoke  "mdlInput_setFunction (INPUT_ENTER_IDLE, OnEnterIdleState);" to get the same event, but it seems that this function is not exported in CONNECT anymore.

Is there any replacement?

[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, my function 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.

Viewing all 4331 articles
Browse latest View live


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