I've encountered an issue where, in certain drawings and at certain times (it seems to be related to the complexity and size of the drawing) the accusnap settings will seem to stop working wrt data passed to the code.
The code, which I've included below, uses an iPrimitiveCommandEvents interface to interactively place and rotate a cell, while incrementing a number stored as a tag in that cell. What happens is that the user will move the cell to where it is to be place, and accusnap will appear to work. It will show the yellow snap icon, but when the user clicks, the placement of the cell will be off by a small amount, depending on the zoom level of the view. When I enabled the snapping sounds, I noticed that it clicked rapidly whenever I clicked to provide a data point: 3-4 or more clicks in half a second or so.This occurs even when I set the mouse sensitivity to very low, or even lift up the mouse so that it's not sending any movement data.
I've already checked my lock settings to ensure I don't have any locks turned on, and I've tried setting the snaps in different ways. I've tried restarting MS and my computer, all with no avail. I've found that closing the current drawing and opening a new one causes the problem to go away, until I return to the old drawing. But I had previously used the same command in this drawing without encountering this issue, and AFAIK, the only difference is the amount of geometry in it.
Is anyone else familiar with this bug, or have any advice on dealing with it?
Code I'm using:
Option Explicit Implements IPrimitiveCommandEvents Dim strCellName As String Dim intNum As Integer Dim longScale As Long Dim firstClick As Boolean Dim oCell As CellElement Dim oPoint As Point3d Dim cellNameList(0 To 4) As String Dim cellIndex As Integer Dim baseRotation As Matrix3d Dim baseAngle As Double Dim twoVPCell As Boolean Dim secondVPcell As Boolean Public Property Let cellName(ByRef val As String) strCellName = val End Property Public Property Get cellName() As String cellName = strCellName End Property Public Property Let SheetNum(ByRef val As Integer) intNum = val End Property Public Property Get SheetNum() As Integer SheetNum = intNum End Property Public Property Let cellScale(ByRef val As Long) longScale = val End Property Public Property Get cellScale() As Long cellScale = longScale End Property Private Sub IPrimitiveCommandEvents_Cleanup() End Sub Private Sub IPrimitiveCommandEvents_DataPoint(point As Point3d, ByVal vw As View) EventTrigger point, msdDrawingModeNormal End Sub Private Sub IPrimitiveCommandEvents_Dynamics(point As Point3d, ByVal vw As View, ByVal drawMode As MsdDrawingMode) EventTrigger point, drawMode End Sub Private Sub IPrimitiveCommandEvents_Keyin(ByVal Keyin As String) If IsNumeric(Keyin) Then If Keyin = "0" Then CommandState.AccuDrawHints.SetOrientationByRotation baseRotation Else intNum = CInt(Keyin) If twoVPCell And secondVPcell Then ShowPrompt "Click to place and rotate viewport " & CStr(intNum) & "B" ElseIf twoVPCell Then ShowPrompt "Click to place and rotate viewport " & CStr(intNum) & "A" Else ShowPrompt "Click to place and rotate viewport " & CStr(intNum) End If End If Else Select Case Keyin Case "-" If cellIndex = 0 Then cellIndex = 4 Else cellIndex = cellIndex - 1 End If Case "-" If cellIndex = 0 Then cellIndex = 4 Else cellIndex = cellIndex - 1 End If Case "=" If cellIndex = 4 Then cellIndex = 0 Else cellIndex = cellIndex + 1 End If Case "+" If cellIndex = 4 Then cellIndex = 0 Else cellIndex = cellIndex + 1 End If End Select strCellName = cellNameList(cellIndex) End If End Sub Private Sub IPrimitiveCommandEvents_Reset() If Main.cellLib <> "" Then AttachCellLibrary (Main.cellLib) End If Main.cellLib = "" CommandState.StartDefaultCommand End Sub Private Sub IPrimitiveCommandEvents_Start() firstClick = False If Right(strCellName, 3) = "2VP" Then twoVPCell = True secondVPcell = False Else twoVPCell = False End If CommandState.CommandName = "Place Viewports" ShowCommand CommandState.CommandName ShowPrompt "Click to place and rotate the first viewport" CommandState.StartDynamics CommandState.EnableAccuSnap cellNameList(0) = strCellName & "_MC" cellNameList(1) = strCellName & "_LL" cellNameList(2) = strCellName & "_LR" cellNameList(3) = strCellName & "_UR" cellNameList(4) = strCellName & "_UL" strCellName = strCellName & "_MC" cellIndex = 0 Dim var As Variant Dim vw As View For Each var In ActiveDesignFile.Views Set vw = var If vw.IsSelected Then baseRotation = vw.Rotation Next var CommandState.AccuDrawHints.SetOrientationByRotation baseRotation End Sub Private Sub EventTrigger(ByRef point As Point3d, ByVal drawMode As MsdDrawingMode) 'Put code here to create item Dim rotMatrix As Matrix3d Dim oTags() As TagElement Dim i As Integer Dim scaler As Point3d Dim ang As Double Dim eTag As TagElement If longScale <= 1 Then scaler.x = PCS_Tools.LocalDGNData.DGNScale scaler.y = PCS_Tools.LocalDGNData.DGNScale scaler.z = PCS_Tools.LocalDGNData.DGNScale Else scaler.x = longScale scaler.y = longScale scaler.z = longScale End If If drawMode = msdDrawingModeNormal Then If Not firstClick Then oPoint = point firstClick = True Else ang = GetAngle(oPoint, point) rotMatrix = Matrix3dFromAxisAndRotationAngle(2, ang - baseAngle) Set oCell = CreateCellElement2(strCellName, oPoint, scaler, True, rotMatrix) oCell.Redraw drawMode ActiveModelReference.AddElement oCell If twoVPCell Then If secondVPcell Then oTags = oCell.GetTags For i = LBound(oTags) To UBound(oTags) Set eTag = oTags(i) eTag.Redraw msdDrawingModeErase eTag.Value = CStr(intNum) & "B" eTag.Redraw eTag.Rewrite Next i intNum = intNum + 1 secondVPcell = False Else oTags = oCell.GetTags For i = LBound(oTags) To UBound(oTags) Set eTag = oTags(i) eTag.Redraw msdDrawingModeErase eTag.Value = CStr(intNum) & "A" eTag.Redraw eTag.Rewrite Next i secondVPcell = True End If Else oTags = oCell.GetTags For i = LBound(oTags) To UBound(oTags) Set eTag = oTags(i) eTag.Redraw msdDrawingModeErase eTag.Value = CStr(intNum) eTag.Redraw eTag.Rewrite Next i intNum = intNum + 1 End If firstClick = False rotMatrix = Matrix3dFromAxisAndRotationAngle(2, Abs((2 * Pi) - ang + baseAngle)) CommandState.AccuDrawHints.SetOrientationByRotation rotMatrix If twoVPCell And secondVPcell Then ShowPrompt "Click to place and rotate viewport " & CStr(intNum) & "B" ElseIf twoVPCell Then ShowPrompt "Click to place and rotate viewport " & CStr(intNum) & "A" Else ShowPrompt "Click to place and rotate viewport " & CStr(intNum) End If End If Else If Not firstClick Then rotMatrix = Matrix3dFromAxisAndRotationAngle(2, Abs((2 * Pi) - baseAngle)) Set oCell = CreateCellElement2(strCellName, point, scaler, True, rotMatrix) oCell.Redraw drawMode Else ang = GetAngle(oPoint, point) rotMatrix = Matrix3dFromAxisAndRotationAngle(2, ang - baseAngle) Set oCell = CreateCellElement2(strCellName, oPoint, scaler, True, rotMatrix) oCell.Redraw drawMode End If End If End Sub
This is Microstation V8i SS3, version 08.11.09.714