Adding a "Pause" or a wait in a journal

I am trying to write a journal to drag re-position an associated IDSymbol. My thought process was:

1. Grab the origin of the IDSymbol. (idSymbol1.AnnotationOrigin)
2. Grab the associated origin data. (GetAssociativeOrigin)
3. Change the associated origin to AssociativeOriginType.Drag (IdSymbolBuilder)
4. Apply that change and drag the Symbol to its adjusted location. (????)
5. Grab the new origin. (idSymbol1.AnnotationOrigin)
6. Subtract the new X and Y values from the original X and Y values. (ptOld.X-ptNew.X, etc.)
7. Re-associate the Symbol to its original dimension adding in the change in position values. (IdSymbolBuilder)

I am still having some issues getting the GetAssociativeOrigin to work for me, but my real trouble is getting the program to let me drag the symbol before continuing on. I tried using a messagebox, but that did not let me manipulate the symbol. What can I use to pause the journal while I perform this action?

The following link to a comment has some code for specifying a point location:
http://nxjournaling.com/?q=comment/236#comment-236

Also, you may want to look into the UF_UI_specify_screen_position function. I'll post an example if/when I get time.

I did something very similar where the user clicked the new location and the symbol position updated. Unfortunately, the people in my group that have tried it that way complain that they just want to drag the symbol, not click and have it jump. I think they are being picky but I told them I would try.

With the UF_UI_specify_screen_position function, you can define a motion callback and use overlay graphics to track the mouse movements and graphically show the movement. Not quite the same as dragging the symbol, but perhaps it would be received better by your users than the click & jump behavior you see now.

Here is some code based on the GTAC example "drag a note to a new location". Note that this code does no error checking and may give undesired results if cancel is pressed. This is for illustration purposes of dragging a symbol, the code is a bit rough.


Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim idSymbolBuilder1 As Annotations.IdSymbolBuilder

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim myScreenPos(2) As Double
Dim theViewTag As Tag = theSession.Parts.Display.Views.WorkView.Tag
Dim theResponse As Integer

Dim myIdSymbol As Annotations.IdSymbol
If SelectIdSymbol("select ID Symbol", myIdSymbol) = Selection.Response.Cancel Then
Exit Sub
End If

idSymbolBuilder1 = workPart.Annotations.IdSymbols.CreateIdSymbolBuilder(myIdSymbol)

'lw.WriteLine("symbol type: " & idSymbolBuilder1.Type.ToString)
'lw.WriteLine("symbol size: " & idSymbolBuilder1.Size.ToString)
'lw.WriteLine("symbol text: " & idSymbolBuilder1.UpperText)
'lw.WriteLine("symbol origin: " & idSymbolBuilder1.Origin.OriginPoint.ToString)

theUfSession.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

theUfSession.Ui.SpecifyScreenPosition("pick a point", AddressOf MotionCallback, Nothing, myScreenPos, theViewTag, theResponse)

theUfSession.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

idSymbolBuilder1.Destroy()

End Sub

Function SelectIdSymbol(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "Select an ID Symbol"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_drafting_entity_type
.Subtype = UFConstants.UF_draft_id_symbol_subtype
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

Sub MotionCallback(ByVal pos() As Double, _
ByRef motion_cb_data As UFUi.MotionCbData, _
ByVal client_data As System.IntPtr)

Dim point1 As Point3d = New Point3d(pos(0), pos(1), pos(2))

idSymbolBuilder1.Origin.Origin.SetValue(Nothing, Nothing, point1)
idSymbolBuilder1.Commit()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------

End Function

End Module

Were you able to make this work?

I am in need of something similar, if you could share your code I can try to make it work for mine please.