VBA not reading reference file offset correctly


I have a frustrating issue where VBA is not reading the reference file offset correctly. I'm working with a bunch of existing drawings and need to know this for inserting some cell's in bulk. Some drawings it works perfectly but not for others. Ive checked scales etc as far as I know they are OK.

Ideas? Screen shots below showing the X offset in the reference file dialog vs the VBA result.

Parents Reply
  • on another drawing the offset shown in the drawing properties is 0

    Is that unexpected?  Doesn't that mean that it's a coincident attachment?

    This should be caused by shifted GlobalOrigin in the attachments. Additionally to oAtt.MasterOrigin also oAtt.GlobalOrigin should be analyzed. Please note the values provided for GlobalOrigin are in UOR instead of working units.

    The rules of reference attachments, combined with the possibility of a non-zero global origin (GO), are tricky.  You need to set up some experimental data to cement your understanding and to test your code.   

    Create some attachments first by copying the original, and set the GO to zero.  Then create several attachments of the same model at known offsets so you can analyse the math easily and confirm that your VBA is working.

    Next, create a copy of the attachment and modify its GO by a known amount, and attach with several offsets so you can analyse the math easily and confirm that your VBA is working.

    If you really want to stretch your understanding, repeat the above with the attachment rotated, scaled or both rotated and scaled.  It's then that methods GetMasterToReferenceTransform and GetMasterToReferenceTransformGetReferenceToMasterTransform become especially useful.

    Reference Analyse Example

    I've attached a DGN file that may help.


    The master model has two attachments

    1. First attachment is coincident
    2. Second attachment is offset manually by 10, 10, 10

    I've attached a VBA project to show some attachment settings.


    1. Run the VBA project to see some attachment settings
    2. Examine the VBA project clsAttachmentAnalyser to see how the offset is obtained.

    Regards, Jon Summers
    LA Solutions

    Answer Verified By: Robert Hook