Reference File Attach problem

Hi everyone.

I have a problem with the the'mdlRefFile_attachCoincident' function.
The dgn file is being connected with the'mdlRefFile_attachCoincident' function,
later it is being disconnected with 'mdlRefFile_detach' function and the application error.
The 'mdlRefFile_attachCoincident' function is returning the correct DgnModelRefP
value which is staying sent to the function 'mdlRefFile_detach'.

What difference is between mdlRefFile_beginAttachment/mdlRefFile_completeAttachment functions and
mdlRefFile_attachCoincident.

Any idea?

Thanks for your help

JacekW.

Parents
  • Jacek:
    Hi everyone. I have a problem with the the'mdlRefFile_attachCoincident' function. The dgn file is being connected with the'mdlRefFile_attachCoincident' function, later it is being disconnected with 'mdlRefFile_detach' function and the application error. The 'mdlRefFile_attachCoincident' function is returning the correct DgnModelRefP value which is staying sent to the function 'mdlRefFile_detach'.

    Please post a code snippet that illustrates the problem.

    Jacek:
    Hi everyone. What difference is between mdlRefFile_beginAttachment/mdlRefFile_completeAttachment functions and mdlRefFile_attachCoincident.

    mdlRefFile_beginAttachment is used with mdlRefFile_completeAttachment to wrap a set of operations on an attachment before it is shown to the user.

    
    DgnModelRefP attachment = NULL;
    if (SUCCESS == mdlRefFile_beginAttachment (&attachment, ...))
    {
       // do things with attachment
       mdlRefFile_completeAttachment (attachment);
    }
    
    

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Reply
  • Jacek:
    Hi everyone. I have a problem with the the'mdlRefFile_attachCoincident' function. The dgn file is being connected with the'mdlRefFile_attachCoincident' function, later it is being disconnected with 'mdlRefFile_detach' function and the application error. The 'mdlRefFile_attachCoincident' function is returning the correct DgnModelRefP value which is staying sent to the function 'mdlRefFile_detach'.

    Please post a code snippet that illustrates the problem.

    Jacek:
    Hi everyone. What difference is between mdlRefFile_beginAttachment/mdlRefFile_completeAttachment functions and mdlRefFile_attachCoincident.

    mdlRefFile_beginAttachment is used with mdlRefFile_completeAttachment to wrap a set of operations on an attachment before it is shown to the user.

    
    DgnModelRefP attachment = NULL;
    if (SUCCESS == mdlRefFile_beginAttachment (&attachment, ...))
    {
       // do things with attachment
       mdlRefFile_completeAttachment (attachment);
    }
    
    

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Children
  • Thanks for your answer Jon.

    Code snippet that illustrates the problem:

    if(mdlRefFile_attachCoincident(&file_num, fileName, NULL, NULL, NULL, ON, ON) == SUCCESS)
    {
              if(mdlModelRef_isEmpty(file_num)==FALSE)
              {
                          // scanning file(file_num);
                         mdlRefFile_detach( file_num);   // -> do ERROR
              }
    }

    Whether in Microstation XM preferred connecting referential files is with the help of the functions mdlRefFile_beginAttachment / mdlRefFile_completeAttachment  or with the help of the mdlRefFile_attachCoincident function ?

     

    Regards, JacekW

  • The preferred method is to use the mdlRefFile_beginAttachment and completeAttachment.  However the mdlRefFile_attachXXX functions have been left for convenience and legacy code.  They are simply wrappers which have the begin and complete within them.

    HTH,

    mark anderson [Bentley]

     

  • Jacek:
    
    if(mdlRefFile_attachCoincident(&file_num, fileName, NULL, NULL, NULL, ON, ON) == SUCCESS)
    {
    if(mdlModelRef_isEmpty(file_num)==FALSE)
    {
    // scanning file(file_num);
    mdlRefFile_detach( file_num);   // -> do ERROR
    }
    } 
    
    

    Your code does not detach an attachment that is empty. I doubt that the check for an empty model saves much processing — it has to check various internal data structures that the scan setup also checks.

    Also, you're not provided a logical name for the attachment. Duplicate logical names are illegal, and this could mess up your attachments. Try something like this:

    
    if (SUCCESS == mdlRefFile_attachCoincident(&modelRef, fileName, logicalName /* must be unique */, NULL, NULL, ON, ON))
    {
       // scan file (modelRef);
       mdlRefFile_detach (modelRef); 
    } 
    
    

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Tanks all for answer.

     But I still have problem.

    I am connecting only one referential file with the help of the mdlRefFile_beginAttachment and mdlRefFile_completeAttachment functions.
    After performing an operation on the file I am detaching the file with the help of the mdlRefFile_detach function.
    The MDL application is hanging itself on the mdlRefFile_detach function.

    Whether somebody encountered the similar situation?
    Any suggestions?

     

  • Jacek:
    I am connecting only one referential file with the help of the mdlRefFile_beginAttachment and mdlRefFile_completeAttachment functions. After performing an operation on the file I am detaching the file with the help of the mdlRefFile_detach function. The MDL application is hanging itself on the mdlRefFile_detach function.

    MDL Reference attach and detach work, in my experience, reliably. Since those operations are fundamental to MicroStation, I would be surprised if they did not work correctly.

    So we have to conclude that whatever operation it is you do to a reference, it is somehow corrupting the DgnModelRefP. Here is a simple sanity check: if you comment out the operation, does attach/detach work correctly?

    
    if (SUCCESS == mdlRefFile_attachCoincident(&modelRef, fileName, NULL, NULL, NULL, ON, ON))
    {
    char msg [256];
    sprintf (msg, "File '%s' attached successfully", fileName);
    mdlOutput_messageCenter (MESSAGE_DEBUG, msg, msg, FALSE);
    // scan file (modelRef);
    if (SUCCESS == mdlRefFile_detach (modelRef)
    {
    sprintf (msg, "File '%s' detached successfully", fileName);
    mdlOutput_messageCenter (MESSAGE_DEBUG, msg, msg, FALSE);
    }
    else
    {
    sprintf (msg, "File '%s' detach error", fileName);
    mdlOutput_messageCenter (MESSAGE_ERROR, msg, msg, TRUE);
    }
    } 
    
    

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • The application is attaching a lot of referential files sequentially.
    For the majority of files the application works well.
    The application is hanging itself on one file.
    How to protect oneself against the corrupted file in XM?
    There was an EDG tool for the validation of DGN files in Microstation SE.
    Is there a similar tool in Microstation XM?

     

    Regards, Jacek

  • Jacek:
    The application is hanging itself on one file. How to protect oneself against the corrupted file in XM?

    It's good to read that your application is working correctly.

    However, the issue of a corrupted DGN file is off-topic. Please post to the general MicroStation Forum. Post the DGN file if you can.

    There is a DGN Verify tool for MicroStation V8.  If you search MicroStation help, or the MicroStation Forum, you will find an answer. 

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions