[V8i - VBA] Pass array from one dgn to another

Good morning,

I would like to copy some cells from one dgn to another, starting from a particular point, in the target file, chosen by the user.

I thought of linking this functionality to a command button on a form. After pressing the button, the user is asked to indicate the starting point from which to start the copy of the cells.
The idea is to populate an array (CellElements) in the source file and "make it available" in the target dgn.

Is it a possible solution? If yes, how should I do it? If not, instead, what solution would you adopt?

Thanks a lot.

Best regards,

Paolo

  • I would like to copy some cells from one dgn to another

    Here's a suggestion...

    1. Make the target the active DGN model, so you can edit and add elements
    2. Attach the source model as a reference
    3. Place a fence around the elements to be copied
    4. Get the fence contents
    5. Copy elements from the fence ElementEnumerator into the active model

    If you don't want to use a fence then you can use Element Selection

    MicroStation users are familiar with both fence and selection set operation.  If you want to use a different method then make a screenshot(s) that shows your proposed workflow.

     
    Regards, Jon Summers
    LA Solutions

  • Hi Jon,

    thanks for your answer.

    I cannot use a method similar to the "standard" use (with "standard", I mean without use of macros) of Microstation.
    The idea of using an array arises from the fact that:
    - in the source file, I have different models, each of which has at least 4 layers that I want to copy to the destination file;
    - source file is 3D, destination file is 2D;
    - moreover, each of the elements that I have in those levels, lies (in space) in completely different positions from those it will have in the destination file.


    With an array of elements, I can manage their copying, positioning, etc in a relatively simple way ...
    ... but how to pass the array?Thinking

    P

  • Hi Paolo,

    I can manage their copying, positioning, etc in a relatively simple way ...

    Yes. I agree with Jon that to transform the problem to "copy from reference" workflow is the best approach.

    What I see as a problem that you want to discuss (and solved) two different topics in one, which at the end will be confusing:

    • How to correctly copy an element to another dgn file (which is seriously complicated task!)
    • How to copy more elements in one

    I recommend to focus to the first step primarily and when code will work, to add support for "arrays".

    I can manage their copying, positioning, etc in a relatively simple way

    Really? Whereas position is quite simple (dynamics in primitive command), copying is complicated.

    In general, there are two concepts available:

    • To copy element from reference to active model
    • To copy element from / to active model and work DGN (file opened using OpenDesignFileForProgram method)

    Even when one simple element is copied from reference to active model (two mouse clicks are required), it can represent tens or even hundreds steps at background. It's because every element depends on many settings (color table, level, line style...) and also can represent parent element for another data structures (e.g. data are attached, there are associations defined...). At background, MicroStation has to test and decide e.g. whether to create new level definition or to cache it from DGNLIB (and to do the same with any style applied), how to manage color (maintain the same number or to assign the closest color with another number) and many other things.

    VBA simplifies this problem providing CopyContext object.

    It's mandatory to use it when element is copied from reference, but I am not sure whether it's possible (and how it works) when work DGN is used (because work DGN is great because opened at background, but not complete functionality is available in such case). It has to be tested.

    With an array of elements

    I am not sure whether I understand the workflow right. As usually, to provide some screen captures or record short video is much better than to explain by words something, that is very special for your situation.

    But to copy more elements is not different from copying one element.

    With regards,

      Jan