Hello!
I´m trying to create a complex element consisting of multiple subelements :
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
Hi Lubo,
Lubo B said: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.
Lubo B said: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.
Lubo B said:I know its not much
I am missing two things in your code:
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Lubo B said: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
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.
Lubo B said: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.
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.
Jan Šlegr said:It's like to discuss a problem with playing on piano describing what finger to when put on what key
Good analogy!
Lubo B said:I tried to play around
As Jon wrote: Post your code.
To explain by words what your code does, does not provide any usable details and the problem cannot be analyzed.
It's like to discuss a problem with playing on piano describing what finger to when put on what key, but to do not share music notation. I think you agree it would be time wasting useless discussion.
Regards,
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.
Lubo B said:MSVC
MSVC what?
For all MicroStation V8i versions, Visual Studio 2005 Professional is required.
Even when it's probably not part of the problem, because typically when not supported Visual Studio version is used, MicroStation crashes, it's important always to confirm how the application was built (the best of course is Visual Studio 2005 Pro + bmake).
Sorry for not providing these information at the start. Im using Microstation V8i SS4 version 8.11.09.867. For code I use MSVC.