VBA - read attachment orientation

Hi All,

Just hoping someone might be able to assist with reading the orientation of a reference attachment. Currently I have some code that requests user input to select an element; and I am hoping to retrieve the orientation of the reference that the element is contained within (it is a saved view attachment). I can return the logical description of the attachment (as shown in italics below) however I cannot find a method for retrieving the saved view name. Potentially I could locate the saved view from the range that element is contained with however this seems a bit cumbersome. Does anyone have any suggestions?

Thanks in advance!

Example:

Set myCIM = myCIQ.GetInput(msdCadInputTypeDataPoint, msdCadInputTypeReset)
Select Case myCIM.InputType
Case msdCadInputTypeDataPoint
pnts(1) = myCIM.point
Set vname = ActiveDesignFile.Views(1)
Set ele = CommandState.LocateElement(pnts(1), vname, True)

refnameA = ele.ModelReference.ParentModelReference.AsAttachment.LogicalDescription

Case msdCadInputTypeReset
 ShowTempMessage msdStatusBarAreaMiddle, "Process Cancelled"
GoTo Finish
End Select

  • Hi Edward,

    at first, please read and follow MicroStation Programming forum best practices, because some information is missing. Maybe not critically important for the discussion, but it's better to always share a standard set of information, at least a product used and its version (build number).

    Also please always use Syntaxhighlighter tool (yellow pencil icon) including correctly selected language when inserting a code into your post. It will ensure the code will be properly displayed and colorized.

    Edward Ashbolt said:
    with reading the orientation of a reference attachment.

    I am not quite sure what do you mean by orientation. Do you want to know the attachment rotation relative to an active (master) model? If yes, every attachment object has Rotation property, which is Matrix3d in the case of attachment, so it contains the complete rotation information.

    Edward Ashbolt said:
    I have some code

    Is there any specific reason why do you this code? A preferred way how to locate an element (the only correct in my opinon) is to implement ILocateCommandEvents object. There are several examples how to do in MicroStation VBA help file.

    Edward Ashbolt said:
    I cannot find a method for retrieving the saved view name.

    How saved view name relates to the attachment orientation? It seems like separate independent issue.

    Edward Ashbolt said:
    Does anyone have any suggestions?

    If ILocateCommandEvents object is used, this is the way how you can receive rotation matrix for the attachment (only code from Accept event is posted):

    Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, Point As Point3d, ByVal View As View)
        If Element.ModelReference.IsAttachment Then
            Dim att As Attachment
            Set att = Element.ModelReference.AsAttachment
            
            Dim rotation As Matrix3d
            rotation = att.rotation
        End If
    End Sub

    With regards,

      Jan