[Microstation V8i MDL C++ API] Creating complex shape causing my subchildren to connect even though the element is closed.

Hello!

I´m trying to create a complex element consisting of multiple subelements :

  1. Line
  2. Complex chain consisting of N segments
  3. Line
  4. Complex chain consisting of N segments

For that I´m using C++ MDL API.  First I create complex header via mdlComplexChain_createHeader. Then I create my subelements. Lines are created within single mdlLine call, while Complex chains are in loops with multiple mdlLine calls and then appending them to the mother header(The complex chain). After I create them, i append them to the owner with mdlElmdscr_appendDscr() . However, even though my creation is closed element (all lines are connected), microstation keeps adding a line between my two single lines, like the shape wasnt closed or something. Im also attaching a picture describing my problem. The same behavior happens even if i dont add the complex chains...

Thanks for any tips.

Lubo

Parents
  • First I create complex header via mdlComplexChain_createHeader. Then I create my subelements. Lines are created within single mdlLine call, while Complex chains are in loops with multiple mdlLine calls and then appending them to the mother header(The complex chain). After I create them, i append them to the owner with mdlElmdscr_appendDscr()

    It's faster to post a code sample than to describe it.  Also, a code sample removes any ambiguity in our interpretation of what you're doing.

    MicroStation keeps adding a line between my two single lines

    The direction of lines is important.  In the closed shape you are creating, all components must be clockwise or counter-clockwise.

    I use MSVC

    Here's a table of Visual Studio and MicroStation SDK versions.

     
    Regards, Jon Summers
    LA Solutions

  • I tried to play around also with the directions of my lines, sometimes the "connection line"(the problematic one) changes direction too ( changes the vertices that its connecting), but I never got to get rid of it. I also tried to specify in mdlComplexChain_createHeader that I wanted to create complex chain instead of complex shape(in hope of this line disappearing), but didnt work as well. The problem is also that I cant access this problematic line from code, so cant hide it manually after creating my element. 

  • It's like to discuss a problem with playing on piano describing what finger to when put on what key

    Good analogy!

     
    Regards, Jon Summers
    LA Solutions

  • MSElement elem;
    MSElementDescr *pDescr = NULL;
     
    mdlComplexChain_createHeader(&elem, true, 0); // Header for mother element
     
    mdlElmdscr_new(pDescr,NULL,&elem);
     
    /*
    CALCULATE POINT POSITIONS FOR LINES
    */
     
    //Create 1st line - same process goes for line 3 - the short lines
    MSElement line1;
    DPoint3D line1Data; //Calculated point
    MSElementDescr* line1 descr;
    line1_descr = mdlLine_create(&line1, NULL, &line1Data);
    
    mdlElmdscr_appendDscr(pDescr,line1_descr); //Add the created line to my header
    
    //Process for creating the complex chain is :
    MSElement chain1;
    mdlComplexChain_createHeader(&chain1, false, 0);
    
    MSElementDescr * chain1_descr = NULL;
    mdlElmdscr_new(chain1_descr,NULL,&chain1); //create descriptor for first chain
    
    
    //Now create the 2 lines that will be consisted in my complex chain.
    For each line, I use mdlLine_create with given points and also append it to my chain1_descr
    
    //After all the things are completed append created chain to my element:
    mdlElmdscr_appendDscr(pDescr,chain1_descr); //Add the created line to my header

    As the code is pretty robust and due to some privacy issues I cant share it entirely with you guys, I managed to do some "pseudo" idea of how I approached the problem. I know its not much but I hope that it will at least help to explain my approach.

  • I use mdlLine_create with given points

    And what are those points?  Are they supplied externally or from existing DGN elements?  As I wrote already, the direction of elements is important to your question MicroStation keeps adding a line between my two single lines.

    I suggest that, as a development exercise to enhance our understanding of your task, you create DGN elements separately rather than as a complex chain.  Then you can use MicroStation tools to examine those elements and attempt to create a complex chain.

     
    Regards, Jon Summers
    LA Solutions

  • I´ve tried to do that even manually from UI. I created complex chains, then added my lines. Then I used Create complex shape tool, but it didnt let me create complex shape containing other complex element, but it allowed me to select lines one by one, so basically it created complex shape created from lines, not chains+lines.

  • I used Create complex shape tool, but it didnt let me create complex shape containing other complex element

    It worked for me, using MicroStation CONNECT Update 14.2.  Or, more accurately, the tool lets me create a complex shape from a complex string and some lines: the complex string is taken apart and its components are used in the new complex shape.

    Please post a DGN model that includes the lines and line-strings you want to assemble.

    Don't tell us that your data is confidential and can't be posted: prepare an example without confidential information.

     
    Regards, Jon Summers
    LA Solutions

  • Hi Lubo,

    I´ve tried to do that even manually from UI.

    It always recommended to try to simulate code manually, but I think Jon idea was to create (sub)elements by code, but do not join them into complex element, but write to DGN file instead of it. It should allow to check whether elements are created correctly in memory, e.g. their order (points sequence) is right.

    Then I used Create complex shape tool, but it didnt let me create complex shape containing other complex element

    It's not possible create complex shape or complex chain with nested complex elements manually. I guess it's the tool feature, not API or format limitation, because in general, I think DGN V8 format allows to nest complex elements (e.g. cell in cell is quite normal structure).

    But I guess it's not crucial question now, because the shape itself is not created right. So maybe in the first step it makes sense to do not use complex elements nesting and to create equal shape, but from simple elements only, to ensure the code is right.

    I know its not much

    I am missing two things in your code:

    • To check values returned from every used function. Is it in your original code?
    • What I mentioned above: DGN with elements, used as input for the final complex shape.

    With regards,

      Jan

  • One more comment or, better to say, question: Why you want to create complex shape with nested another complex strings (complex chains)?

    Even when MicroStation itself uses nested complex cells sometimes (e.g. TriForma shapes, or SmarSolids) and it's possible to create such structures (because it's allowed by DGN V8 format specification), they are in fact "from the past heritage", when it was the simplest workaround of complex requirements.

    When you will study a presentation from migration workshop (to CE platform):

    In most cases:
    - We found Complex elements to be WRONG during i-model platform optimization
    - Less need to use MSElement and MSElementDescr types (applause)
    - MSElement should only be used for Handlers Only
    
    Nesting = bad

    You can see that in CONNECT Edition, new elements (e.g. parametric modeling) are implemented using relationships, not nesting.

    For normal elements, one level nesting (flat structures inside shapes, chains and cells) is recommended, because it does not require recursion, which is treated as a threat in a code and should be avoided when not really necessary.

    With regards,

      Jan

  • A type 12 CMPLX_STRING_ELM is intended to represent a single open path, a type 14 CMPLX_SHAPE_ELM a single closed loop.

    The components of a complex chain or shape are expected to be connected head to tail, any gaps are filled with a linear stroke to ensure that the element displays as a path or loop..

    It is not valid to add a complex chain or shape as a child of another complex chain or shape, the only valid components are simple open elements, LINE_ELM, LINE_STRING_ELM, CURVE_ELM, ARC_ELM, and open BSPLINE_CURVE_ELM.

    Maybe you want a type 2 CELL_HEADER_ELM for your outermost complex header, or maybe you just want to add the components of the nested chains directly w/o creating nested chains...maybe you just want a type 6 SHAPE_ELM? 

    HTH

    -B



  • I have it like this because i wanted a way to differentiate between parts of my element in VBA.  

    Then I want to apply my VBA macro, where I can simply determine which line am I working with by identifying if Im iterating inside a complex chain or just a simple line. I encapsulated these all lines and chains into another complex shape because in my macro I want to use getIntersectionPoints method from complex shape.

  • It is not valid to add a complex chain or shape as a child of another complex chain or shape
    I have it like this because i wanted a way to differentiate between parts of my element in VBA

     is a member of the core development team.  If he says: "Don't do it that way", then don't do it that way!

    But, rather than debating the merits of nested elements, raise the discussion to a higher level.  Put your problem to us and ask for tips.  For example: "How can I identify the origin or provenance of the components of a complex shape?"

    One way, for example, would be to attach some sort of data tag to those elements.  With MicroStation, you're spoiled for choice — or would be if you didn't want to interrogate the complex chain using VBA. Possibilities include...

    • User Attribute Data
    • DataBlock
    • XDatum

    With CONNECT you might additionally consider Item Types. There's a VBA API for all of those.

     
    Regards, Jon Summers
    LA Solutions

Reply
  • It is not valid to add a complex chain or shape as a child of another complex chain or shape
    I have it like this because i wanted a way to differentiate between parts of my element in VBA

     is a member of the core development team.  If he says: "Don't do it that way", then don't do it that way!

    But, rather than debating the merits of nested elements, raise the discussion to a higher level.  Put your problem to us and ask for tips.  For example: "How can I identify the origin or provenance of the components of a complex shape?"

    One way, for example, would be to attach some sort of data tag to those elements.  With MicroStation, you're spoiled for choice — or would be if you didn't want to interrogate the complex chain using VBA. Possibilities include...

    • User Attribute Data
    • DataBlock
    • XDatum

    With CONNECT you might additionally consider Item Types. There's a VBA API for all of those.

     
    Regards, Jon Summers
    LA Solutions

Children
No Data