mdlElmdscr_copy element color issue

In a function I wrote, I need to copy element from a workdgn to another work dgn. When I open the file where elements have been copied, element color are altered. For example, color 22 in the first workdgn becomes 6 in the destination, color 34 becomes 58... I can't find a rule...

Some remarks :

  • Color tables are the same in both files
  • The application is written in native code
  • We use MicroStation V8 2004 (the project is in a complex structure with interaction with many other tools)

Source and destination workdgn will be opened and processed like this :

 

// we create the destination
if( mdlWorkDgn_createFile( &pModelRefDest, 

chFichierTemp,
DGNFILE_FORMAT_V8,
pModelRefSeed,
SEED_CopyDefaultData,
NULL,
NULL,
bThreeD ) != SUCCESS )

{

// we open the source file
if( mdlWorkDgn_openFile( &pModelRefSource, NULL, NULL, chTempFilename, NULL, TRUE ) == SUCCESS )
{

CopyContextP  pCC = mdlCopyContext_create(); // a copycontext is created

// we have here a scanner to find elements to copy

// for each element corresponding to the scan criteria, we do:

// element color is correct (pElmdscr->el.hdr.dhdr.symb.color)

if( mdlElmdscr_copy( &pElmdscr, pModelRefSource, pModelRefDest, pCopyContext ) == SUCCESS )
{

// pElmdscr->el.hdr.dhdr.symb.color is different

}

mdlWorkDgn_closeFile( pModelRefSource );

mdlCopyContext_free( &pCopyContext ); // copycontext is freed

}

}

mdlWorkDgn_closeFile( pModelRefDest );

 

In the MDL help file, for the function mdlElmdscr_copy, we found this description for the parameter "elDscrPP :

MSElementDescr** elDscrPP IN OUT element descriptor to copy to the destModelRef. It may be modified by this function. The returned value will be the element descriptor as written to the destination. 

I agree with the sentence in red for levels or linestyle. For the color I don't know if it applies ?

 

My question is : Anybody has encountered this kind of issue ? There is a way to solve it ?

 

Many thanks in advance.

 

Philippe

Parents
  • Never ran into problems, although I have to say that I work a little bit different (I needed the filepos for some reasons).
    So I do it the following way:

    cpyContext = mdlCopyContext_create();
    mdlCopyContext_setWriteElements(cpyContext, FALSE);
    mdlWorkDgn_openFile(&dwdModel, &format, &is3D, dwdName, NULL, TRUE);

    // in loop do
    mdlElmdscr_copy(&edp, dwdModel, destModel, cpyContext);
    UInt32 filePos = mdlElmdscr_addByModelRef(edp, destModel);
    mdlElmdscr_freeAll(&edp);
    // do something with filepos i.e. append engineering or html link or dependency

    mdlCopyContext_free (&cpyContext);
    mdlWorkDgn_closeFile(dwdModel);

    normally this should work the same way as you do without mdlCopyContext_setWriteElements. but maybe worth a try.

    HTH Michael



  • Michael Stark said:
    but maybe worth a try.


    It's not... :)

    Philippe,

    Are you absolutely certain the color tables are identical? Do the remapped color indices have the same rgb value in the source/destination files?

    Whether a 0-255 color index is left alone when an element is copied between files/models vs. remapped to the closest rgb match is based on userPrefsP->refFilePrefs.keepRefColorIndexOnCopy (Workspace->Preference->Reference->Remap Colors on Copy).

    I can't explain what you are seeing if the color tables are really the same...

    HTH

    -B



Reply
  • Michael Stark said:
    but maybe worth a try.


    It's not... :)

    Philippe,

    Are you absolutely certain the color tables are identical? Do the remapped color indices have the same rgb value in the source/destination files?

    Whether a 0-255 color index is left alone when an element is copied between files/models vs. remapped to the closest rgb match is based on userPrefsP->refFilePrefs.keepRefColorIndexOnCopy (Workspace->Preference->Reference->Remap Colors on Copy).

    I can't explain what you are seeing if the color tables are really the same...

    HTH

    -B



Children