RightOffset Example
Sub Example_RightOffset() ' This example returns the right offset of the selected object ' to the grid assembly. ' Use this example with a drawing that contains a window ' assembly and one or more AEC objects attached to the ' assembly. Dim ent As AcadEntity Dim geo As AecGeo Dim anchor As AecAnchor Dim offset As String On Error Resume Next ' Handle errors in code. ' Prompt user to select an object. ThisDrawing.Utility.GetEntity ent, pt, "Select object anchored to window assembly:" ' Make sure user selected an AEC object, and that the object ' is anchored to a grid assembly. If ent Is Nothing Then MsgBox "Nothing was selected.", vbExclamation, "RightOffset Example" ElseIf TypeOf ent Is AecGeo Then Set geo = ent ' Get the anchor the object is attached to. Set anchor = geo.GetAnchor On Error GoTo 0 If anchor Is Nothing Then MsgBox "Selected object is not anchored.", vbExclamation, "RightOffset Example" ElseIf Not TypeOf anchor Is AecAnchorEntToGridAssembly Then MsgBox "Object is anchored, but not to a grid assembly.", vbExclamation, "RightOffset Example" Else MsgBox "Right offset of object: " & anchor.RightOffset, vbInformation, "RightOffset Example" End If Else MsgBox "Object selected is not an AEC entity.", vbInformation, "RightOffset Example" End If
End Sub