C# Addin - transform ReferenceAttachment Type

AECOsim 10.0.0.118

I have a C# Addin tool that will both move and rotate selected elements as a single operation. It works well with a wide variety of element types (lines, shapes, cells etc.) but is throwing an error on ReferenceAttachment types.

Error is:
An exception of type 'System.Runtime.InteropServices.COMException' occured...
Additional information: Attempting to perform a graphical operation on a non-graphical element

Does element.transform support ReferenceAttachment types?

If not can someone please point me in the right direction on how I might handle moving the referenceattachment element?

The method I am using is shown below:

private void ScaleMoveAndRotate(Element ele, Matrix3d mtrxRotation, Point3d pntFixed, Point3d pntDistance, Point3d pntScaleFactors)
        {
            Matrix3d mtrxScale;
            Matrix3d mtrxCombined;

            Transform3d trns;
            Transform3d trnsMove;

            //Create a scaling matrix
            mtrxScale = app.Matrix3dFromScaleFactors(pntScaleFactors.X, pntScaleFactors.Y, pntScaleFactors.Z);


            //Multiply the matrices to create a matrix that scales and rotates
            mtrxCombined = app.Matrix3dFromMatrix3dTimesMatrix3d(mtrxRotation, mtrxScale);

            //Create a transform to rotate and scale about a fixed point
            trns = app.Transform3dFromMatrix3dAndFixedPoint3d(mtrxCombined, pntFixed);

            //Create a transform for moving the element
            trnsMove = app.Transform3dFromXYZ(pntDistance.X, pntDistance.Y, pntDistance.Z);

            trns = app.Transform3dFromTransform3dTimesTransform3d(trnsMove, trns);
            ele.Transform(trns);
        }

  • This behavior is expected and documented in the MicroStation VBA (COM/interop) Object Model documentation: ..\MicroStation\MicroStationVBA.chm; help topic: "Transform Method".

    The documentation remarks on this topics state to call Transform method only if IsGraphical returns True.

    When encountering a non-graphical Attachment (actually a specialized instance of a Model) as element type (
    msdElementTypeReferenceAttachment) prefer to use an Attachment object to transform (scale, rotate, and/or offset) using e.g. the Move (distance, bClipboundaries) method. Take a look at the help topic: "Changing Reference Origin and Rotation" that provides some sample code showing how to move and rotate using Attachment object methods.

    HTH,
    Bob