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

[Microstation v8i][VBA] Saving as PDF - File Name

$
0
0

Hi everyone,

I wish to print a DGN file as PDF by VBA code. 

Can I pass by code file name and path to dialog box?

Thanks a lot,

Paolo


[CONNECT C#] Bentley.DgnPlatformNET.Elements.LineElement get start and end points

$
0
0

Going to probably feel stupid when I see the answer but here goes:

When using the Bentley.Interop.MicroStationDGN I could get the start & end point of a LineElement by using LineElement.StartPoint & LineElement.EndPoint.

Now trying to get the same information using Bentley.DgnPlatformNET.Elements.LineElement there are no obvious methods or properties to access that information, how do I get to it? I'm using the ItemInstanceCollector to get a number of different types of elements with ItemType info.

[CONNECT C#] Managed Equivalents for older COM Interop Calls

$
0
0

Hallo,

I am converting existing add-ins that were written in C# using the COM Interop on V8i SS4 to the new CONNECT NET API and I would like to get rid of any remaining calls to the COM Interface where possible. To achieve that goal, I need to find equivalents to some functions we used, such as:

On the LineElement class:
ProjectPointOnPerpendicular

On the application class:
GetFloodBoundary
Point3dInPolygonXY
Segment3dSegment3dClosestApproach
Ray3dRay3dClosestApproach

and a few other calls to the C libraries that I do not see in the SDK documentation, such as:
mdlElement_dropComplex from STDMDLBLTIN.DLL (it is possible that it is just undocumented in the SDK help file)

I have converted the rest of our Native imports to use longs and DPoint3d structs iso Point3d where appropriate so I do not foresee any problems with those.

I would appreciate any help, if someone can point me in the right direction with regards to equivalent calls on the Managed API that I can use to replace the COM Interface calls.

Thanks in advance,
Francois Grobler

[MStn CE U13 NET] Scenarios of IDisposable classes in API

$
0
0


Hi,

this is (again :-) question about API best practices. I apologize for its length, but I tried to formulate it including code snippets to allow to answer in a format [correct | incorrect] ;-)

One from important common NET best practices (and totally ignored by many developers) is: When IDisposable object is used, it should be always disposed as soon as possible explicitly (in code), not waiting for garbage collecting.

In MicroStation NET API, many classes, because they are wrappers around native classes (resources), implement IDisposable.

Therefore, my question is, what are “best practices IDisposable object patterns” in MicroStation CE NET API? Surprisingly, no example in MicroStation SDK uses Dispose, so there is suspicion the code is dirty and does not follow NET best practices. On the other hand, there are classes (at least one found, thanks  for the notice) that logs when Dispose is ignored and not used properly.

Because the answer probably requires a good insight how API is implemented, I hope somebody (?) will be able to forward this question to a proper person ;-)

As an input for the discussion about scenarios, I have thought about 3 different situations plus one extra question. Only situations where MicroStation NET API is involved, were investigated>

  • IDisposable object is created by developer
  • IDisposable object is returned by API method
  • IDisposable object is received as parameter in overridden method
  • DgnTool class is also IDisposable

IDisposable object is created by developer

This scenario is simple in my opinion, because is like normal usage of IDisposable objects.

When e.g. Element (which is IDIsposable) is created, usually the code looks like this:

LineStringElement line = new LineStringElement(activeModel, null, points);
line.AddToModel();

Warning CA2000 is correctly raised for this code by analyzer.

Am I right an explicit disposal is required here, so the correct code should be e.g. this one?

using (LineStringElement line = new LineStringElement(activeModel, null, points))
{
    line.AddToModel();
}

IDisposable object is returned by API method

Many API methods return IDisposable objects, e.g. often used ElementAgenda instance. Example from ModifyFenceContentsTool.cs from SDK (some lines skipped):

FenceParameters fenceParams = new FenceParameters(modelRef, DTransform3d.Identity);
ElementAgenda eAgenda = new ElementAgenda();
DgnModelRef[] modelRefList = new DgnModelRef[1];
FenceManager.BuildAgenda(fenceParams, eAgenda, modelRefList, false, false, false);

Here I assume the object ownership is passed to receiver (custom code), so ElementAgenda (and FenceParameters too) should be disposed by a developer? Again, SA2000 is raised by analyzer for the original version of the code. To solve the warnings, code can be changed to this one:

using (FenceParameters fenceParams = new FenceParameters(modelRef, DTransform3d.Identity))
using (ElementAgenda eAgenda = new ElementAgenda())
{
    DgnModelRef[] modelRefList = new DgnModelRef[1];
    FenceManager.BuildAgenda(fenceParams, eAgenda, modelRefList, false, false, false);
}

Correct?


IDisposable object is received as parameter in overridden method

This is not clear situation and many discussions can be found on Internet about this scenario (IDisposable as method parameter), because it depends how API is implemented.

Let’s discuss very simple code in custom DgnElementSetTool class:

public override StatusInt OnPreElementModify(Element element)
{…
}

My assumption here is that I am not an owner of the element (I do not create the instance), so I am not responsible to dispose the element and it will be disposed by state engine that calls my class from outside. Is it correct?

For the sake of completeness, in OnDataButton the situation is simpler (ModifyGroupedHoleTools.cs from SDK examples used):

protected override bool OnDataButton(Bentley.DgnPlatformNET.DgnButtonEvent ev)
{
  Bentley.DgnPlatformNET.HitPath hitPath = DoLocate(ev, true, 1);…
}

DgnButtonEvent is pure NET class (not implementing IDisposable), so it will be collected normally. And the rest of method is normal NET code, so in fact how hitPath is obtained is incorrect, because HitPath is inherited from DisplayPath that implements IDisposable, so it should be something like:

 protected override bool OnDataButton(Bentley.DgnPlatformNET.DgnButtonEvent ev)
{
  using (Bentley.DgnPlatformNET.HitPath hitPath = DoLocate(ev, true, 1))
  {…
  }
  …
}

DgnTool class is also IDisposable

This is the extra question: DgnTool class, which is a base class for primitive and modification tools, also implements IDisposable, so it should be disposed explicitly. But I think that using this standard code

public static void InstallNewInstance ()
{
    ModifyGroupedHoleTool modifyTool = new ModifyGroupedHoleTool();
    modifyTool.InstallTool();
}

the instance ownership is passed from creator (the class in static method) to API, so MicroStation state engine is responsible to dispose it when another tool become active. Is it correct?

With regards,

  Jan

[C++ Ms Connect] Issue with SetDisplayPriority

$
0
0

Hi everybody,

May can someone help me with this issue...
I don't understand why this function doesn't work:

  StatusInt Elmdscr_setDisplayPriority(
    MSElementDescrH ElmDscrH,
    Int32 priority,
    DgnModelRefP modelRefP)
  {
    if (ElmDscrH==NULL || *ElmDscrH == NULL)
    {
      return ERROR;
    }

    DgnPlatform::EditElementHandle eeh(*ElmDscrH, false, false);
    eeh.SetModelRef(modelRefP);
    ElementPropertiesSetterPtr propSetter = ElementPropertiesSetter::Create();
    propSetter->SetDisplayPriority(priority);
    if(propSetter->Apply(eeh)==true)
      return SUCCESS;
    else
      return ERROR;
  }

My function always return ERROR, and I can't understand why because I use "ElementPropertiesSetterPtr" for the other properties with no problems.
Thanks for your help,

Hervé

We are facing a problem with conversion to shapes

$
0
0

We are facing a problem with conversion to shapes. I have the points in the corner of polygon. From that points it should generate a polygon. Please give us the information about this conversion process including the tools.

CONNECT API - Is there a C# equivalent of the mdl measure.ma to compute minimum distance between Solid / Surface elements?

$
0
0

As per title, I want to port this functionality to Generative Components which is written in C#. None of the libraries I could find seemed to perform this operation (aside from calculating distance between 2 points), any advice on how to achieve this?
Thanks,

Ed

MDL DatePicker

$
0
0

We have several MDL applications with numerous Dialogs. In some of these dialogs the user is asked to enter a date.

So far, we implemented this as a simple textbox, whose contents is parsed by means of a function we wrote.

I would like to know if there's some kind of datepicker. Let's say a combobox that opens a calendar when the user presses the down-arrow.

Something similar to the popup that shows up when the user clicks on the current time within the Windows taskbar.


CE Update 13 VBA - FindItemTypeLibraryFromDesignFileAndDgnLibs

$
0
0

I have not been able to get the code snippet out of the help examples (copied below) to return any value. I am trying to get the ItemTypeLibribry from my dgnlib without having one in my dgn.

Has anyone been able to get this work or is this a bug?  I put '*' instead of '*a*' to try and get any it can find, but that didn't help either.

Sub FindItemTypeLibraryFromDesignFileAndDgnLibs()

    Dim oItemLibs As ItemTypeLibraries
    Dim oItemLib As ItemTypeLibrary
    Dim oDgn As designFile
    Dim oAtt As Attachment
    
    For Each oAtt In ActiveModelReference.Attachments
        Set oDgn = oAtt.designFile
        Set oItemLibs = New ItemTypeLibraries
        Do
            Set oItemLib = oItemLibs.FindForDesignFile("*a*", oDgn, True, oItemLib)
            If oItemLib Is Nothing Then Exit Do
            Debug.Print oItemLib.LibName
        Loop
    Next

End Sub

MDL DatePicker

$
0
0

We have several MDL applications with numerous Dialogs. In some of these dialogs the user is asked to enter a date.

So far, we implemented this as a simple textbox, whose contents is parsed by means of a function we wrote.

I would like to know if there's some kind of datepicker. Let's say a combobox that opens a calendar when the user presses the down-arrow.

Something similar to the popup that shows up when the user clicks on the current time within the Windows taskbar.

[MStn CE U13 C++] How to use IModelPublisher ProcessFileCallback()?

$
0
0

Hi,

when checking new features of i-model Publishing API in CE (and how it has changed from V8i), I found there is ProcessFileCallback() typedef available.

I was not able to find any details or description, so I'd like to ask whether there are any extra info available:

  • What is the functionality (when the callback is invoked)?
  • How ti can be used (even the simplest code snippet would help as a template).

Specifically I am interested in whether it can be used to check when a tree of files (DGN with many references attached)? In V8i this scenario was not supported well.

With regards,

  Jan

[CONNECT] Custom Elements

[CONNECT C#] Cell Origin/Location

$
0
0

Trying to use the non-COM api C# to find the location of a cell in a model. I have the CellHeaderElement but that give me no geometry type information (I'm looking for the placement location point).

Get text value [v8i][VBA]

$
0
0

Good morning,

is it possible get the value of a text field?

how can I recognize several text fields? by name, by position?

Can I organize text fields as "array" like Text(1), Text(2), ..., Text(n)? Or at least Text1, Text2, etc?

Thanks

LA Solutions - Link Error - FindFile


MICROSTATION DIMENSION AUDIT BY SCALE FACTOR

$
0
0

hey guys i was wondering if anyone can help, what i need is a VBA or key-in that can select dimensions by scale factor similar to the dim audit function. 

thanks you 

[CONNECT C++] SelectionSetManager sample code?

$
0
0

I would like to implement a SelectionSetManager to filter certain levels from being added to the selection set. I believe I must call the AddListener() function but cannot find any examples/samples on how to do so. Anyone care to share a code sample?

Thanks in Advance,
Loren.

[MStn CE U13 C#] ElementPropertiesGetter.Thickness raises exception

$
0
0

Hi,

I tried to obtain Thickness property from ElementPropertiesGetter, but it always raises NullReferenceException, which is weird, because it should return struct.

My assumption is that "something", e.g. zero vector, should be returned always.

Can it be analyzed and when it's bug (which I expect), to be recorded as defect?

With regards,

  Jan

[MS8i SS10 C++] issue with mdlDB_openCursorWithID with code 4600 on a server

$
0
0

Hi everybody,

I have this code where mdlDB_openCursorWithID return on a server error code 4600

My database is an oracle database.

  if (mdlDB_isActive() == TRUE)
  {
    char query[2048];
    std::memset(query, 0, sizeof(query));
    CursorID cursorIdFichier;
    MS_sqlda sqldataFichier;

    Alm::Char::Sprintf(query, sizeof(query), "select to_char(emprise_originex,'FM999999999999990.99'),to_char(emprise_originey,'FM999999999999990.99'),to_char(emprise_angle,'FM999999999999990.99'),PROJECTION_CLE from emprise where plan_code =%d", pFichier.planCode);
    if ((errorDb = mdlDB_openCursorWithID(&cursorIdFichier, query)) == SUCCESS)
    {
      while (mdlDB_fetchRowByID(&sqldataFichier, cursorIdFichier) == QUERY_NOT_FINISHED)
      {
        //blah blah blah
      }
    }
    else
    {
      char message[512];
      Alm::Char::Sprintf(message, sizeof(message), "Echec de la requête de l'emprise du plan  error %d", errorDb);
      WriteTraceAppli(message, TypeError::ERREUR);
      memset(message, 0, sizeof(message));
      Alm::Char::Sprintf(message, sizeof(message), "Echec de la requête de l'emprise du plan Query = %s", query);
      WriteTraceAppli(message, TypeError::ERREUR);
    }  
  }

I tried the query with sql developer and it works perfectly with the same credentials.

Anyone know the meaning of error code 4600 ? I canot find anything in dberrs.h

I hope i gave you enought information to help me.

Rgdts

Arnaud

[Microstation CE u13] ElementGraphicsProcessor example in C#

$
0
0

Hi all,

I am trying to extract all of the elements contained within a paramteric cell, and it was suggested that I use the ElementGraphicsProcessor abstract class to achieve this. The objective is to to return all graphical elements from the cell instance in their true location (with the same geometry), along with their associated symbology. Essentially this would have a similar outcome as dropping the cell however the typical workflow for dropping an element programmatically doesn't seem to work on parametric cells unfortunately. Does anyone have any examples or documentation that could enlighten me on how to achieve this?

Thanks!


Ed

Viewing all 7260 articles
Browse latest View live


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